Skip to content

Commit fe5c95d

Browse files
committed
Auto merge of #142392 - matthiaskrgr:rollup-9jrfqnu, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #141307 (Add method to retrieve body of closure in stable-mir) - #142040 (transmutability: shift abstraction boundary) - #142066 (More simple 2015 edition test decoupling) - #142157 (rustc_resolve: Improve `resolve_const_param_in_non_trivial_anon_const` wording) - #142217 (`tests/ui`: A New Order [10/N]) - #142219 (`tests/ui`: A New Order [11/N]) - #142261 (use correct edition when warning for unsafe attributes) - #142303 (Assorted bootstrap cleanups (step 1)) - #142318 (Cleanup `rust-src` remapping and real dir) - #142352 (compiler: Make `c_int_width` an integer) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1434630 + 2407761 commit fe5c95d

File tree

228 files changed

+1648
-1393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+1648
-1393
lines changed

compiler/rustc_codegen_ssa/src/traits/type_.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ pub trait DerivedTypeCodegenMethods<'tcx>:
4444
BaseTypeCodegenMethods + MiscCodegenMethods<'tcx> + HasTyCtxt<'tcx> + HasTypingEnv<'tcx>
4545
{
4646
fn type_int(&self) -> Self::Type {
47-
match &self.sess().target.c_int_width[..] {
48-
"16" => self.type_i16(),
49-
"32" => self.type_i32(),
50-
"64" => self.type_i64(),
47+
match &self.sess().target.c_int_width {
48+
16 => self.type_i16(),
49+
32 => self.type_i32(),
50+
64 => self.type_i64(),
5151
width => bug!("Unsupported c_int_width: {}", width),
5252
}
5353
}

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,34 +1649,7 @@ impl<'a> CrateMetadataRef<'a> {
16491649
old_name
16501650
&& let Ok(rest) = virtual_name.strip_prefix(virtual_dir)
16511651
{
1652-
// The std library crates are in
1653-
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
1654-
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
1655-
// detect crates from the std libs and handle them specially.
1656-
const STD_LIBS: &[&str] = &[
1657-
"core",
1658-
"alloc",
1659-
"std",
1660-
"test",
1661-
"term",
1662-
"unwind",
1663-
"proc_macro",
1664-
"panic_abort",
1665-
"panic_unwind",
1666-
"profiler_builtins",
1667-
"rtstartup",
1668-
"rustc-std-workspace-core",
1669-
"rustc-std-workspace-alloc",
1670-
"rustc-std-workspace-std",
1671-
"backtrace",
1672-
];
1673-
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));
1674-
1675-
let new_path = if is_std_lib {
1676-
real_dir.join("library").join(rest)
1677-
} else {
1678-
real_dir.join(rest)
1679-
};
1652+
let new_path = real_dir.join(rest);
16801653

16811654
debug!(
16821655
"try_to_translate_virtual_to_real: `{}` -> `{}`",

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,14 @@ pub fn check_attribute_safety(
180180
let diag_span = attr_item.span();
181181

182182
// Attributes can be safe in earlier editions, and become unsafe in later ones.
183+
//
184+
// Use the span of the attribute's name to determine the edition: the span of the
185+
// attribute as a whole may be inaccurate if it was emitted by a macro.
186+
//
187+
// See https://github.com/rust-lang/rust/issues/142182.
183188
let emit_error = match unsafe_since {
184189
None => true,
185-
Some(unsafe_since) => attr.span.edition() >= unsafe_since,
190+
Some(unsafe_since) => path_span.edition() >= unsafe_since,
186191
};
187192

188193
if emit_error {

compiler/rustc_resolve/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ resolve_const_param_in_enum_discriminant =
119119
const parameters may not be used in enum discriminant values
120120
121121
resolve_const_param_in_non_trivial_anon_const =
122-
const parameters may only be used as standalone arguments, i.e. `{$name}`
122+
const parameters may only be used as standalone arguments here, i.e. `{$name}`
123123
124124
resolve_constructor_private_if_any_field_private =
125125
a constructor is private if any of the fields is private

compiler/rustc_smir/src/stable_mir/ty.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,14 @@ crate_def! {
743743
pub ClosureDef;
744744
}
745745

746+
impl ClosureDef {
747+
/// Retrieves the body of the closure definition. Returns None if the body
748+
/// isn't available.
749+
pub fn body(&self) -> Option<Body> {
750+
with(|ctx| ctx.has_body(self.0).then(|| ctx.mir_body(self.0)))
751+
}
752+
}
753+
746754
crate_def! {
747755
#[derive(Serialize)]
748756
pub CoroutineDef;

compiler/rustc_target/src/spec/base/xtensa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn opts() -> TargetOptions {
66
TargetOptions {
77
os: "none".into(),
88
endian: Endian::Little,
9-
c_int_width: "32".into(),
9+
c_int_width: 32,
1010
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
1111
executables: true,
1212
panic_strategy: PanicStrategy::Abort,

compiler/rustc_target/src/spec/json.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ impl Target {
8080
base.$key_name = s;
8181
}
8282
} );
83+
($key_name:ident = $json_name:expr, u64 as $int_ty:ty) => ( {
84+
let name = $json_name;
85+
if let Some(s) = obj.remove(name).and_then(|b| b.as_u64()) {
86+
base.$key_name = s as $int_ty;
87+
}
88+
} );
8389
($key_name:ident, bool) => ( {
8490
let name = (stringify!($key_name)).replace("_", "-");
8591
if let Some(s) = obj.remove(&name).and_then(|b| b.as_bool()) {
@@ -554,7 +560,7 @@ impl Target {
554560
}
555561
}
556562

557-
key!(c_int_width = "target-c-int-width");
563+
key!(c_int_width = "target-c-int-width", u64 as u16);
558564
key!(c_enum_min_bits, Option<u64>); // if None, matches c_int_width
559565
key!(os);
560566
key!(env);

compiler/rustc_target/src/spec/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,18 +2213,10 @@ impl Target {
22132213
});
22142214
}
22152215

2216-
dl.c_enum_min_size = self
2217-
.c_enum_min_bits
2218-
.map_or_else(
2219-
|| {
2220-
self.c_int_width
2221-
.parse()
2222-
.map_err(|_| String::from("failed to parse c_int_width"))
2223-
},
2224-
Ok,
2225-
)
2226-
.and_then(|i| Integer::from_size(Size::from_bits(i)))
2227-
.map_err(|err| TargetDataLayoutErrors::InvalidBitsSize { err })?;
2216+
dl.c_enum_min_size = Integer::from_size(Size::from_bits(
2217+
self.c_enum_min_bits.unwrap_or(self.c_int_width as _),
2218+
))
2219+
.map_err(|err| TargetDataLayoutErrors::InvalidBitsSize { err })?;
22282220

22292221
Ok(dl)
22302222
}
@@ -2286,7 +2278,7 @@ pub struct TargetOptions {
22862278
/// Used as the `target_endian` `cfg` variable. Defaults to little endian.
22872279
pub endian: Endian,
22882280
/// Width of c_int type. Defaults to "32".
2289-
pub c_int_width: StaticCow<str>,
2281+
pub c_int_width: u16,
22902282
/// OS name to use for conditional compilation (`target_os`). Defaults to "none".
22912283
/// "none" implies a bare metal target without `std` library.
22922284
/// A couple of targets having `std` also use "unknown" as an `os` value,
@@ -2783,7 +2775,7 @@ impl Default for TargetOptions {
27832775
fn default() -> TargetOptions {
27842776
TargetOptions {
27852777
endian: Endian::Little,
2786-
c_int_width: "32".into(),
2778+
c_int_width: 32,
27872779
os: "none".into(),
27882780
env: "".into(),
27892781
abi: "".into(),

compiler/rustc_target/src/spec/targets/armv7_sony_vita_newlibeabihf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(crate) fn target() -> Target {
3131
options: TargetOptions {
3232
os: "vita".into(),
3333
endian: Endian::Little,
34-
c_int_width: "32".into(),
34+
c_int_width: 32,
3535
env: "newlib".into(),
3636
vendor: "sony".into(),
3737
abi: "eabihf".into(),

compiler/rustc_target/src/spec/targets/avr_none.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
1313
llvm_target: "avr-unknown-unknown".into(),
1414
pointer_width: 16,
1515
options: TargetOptions {
16-
c_int_width: "16".into(),
16+
c_int_width: 16,
1717
exe_suffix: ".elf".into(),
1818
linker: Some("avr-gcc".into()),
1919
eh_frame_header: false,

compiler/rustc_target/src/spec/targets/msp430_none_elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
1616
arch: "msp430".into(),
1717

1818
options: TargetOptions {
19-
c_int_width: "16".into(),
19+
c_int_width: 16,
2020

2121
// The LLVM backend currently can't generate object files. To
2222
// workaround this LLVM generates assembly files which then we feed

compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
1313

1414
options: TargetOptions {
1515
endian: Endian::Little,
16-
c_int_width: "32".into(),
16+
c_int_width: 32,
1717
families: cvs!["unix"],
1818
os: "espidf".into(),
1919
env: "newlib".into(),

compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
1313

1414
options: TargetOptions {
1515
endian: Endian::Little,
16-
c_int_width: "32".into(),
16+
c_int_width: 32,
1717
families: cvs!["unix"],
1818
os: "espidf".into(),
1919
env: "newlib".into(),

compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
1313

1414
options: TargetOptions {
1515
endian: Endian::Little,
16-
c_int_width: "32".into(),
16+
c_int_width: 32,
1717
families: cvs!["unix"],
1818
os: "espidf".into(),
1919
env: "newlib".into(),

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,32 +2558,31 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
25582558
rustc_transmute::Reason::SrcIsNotYetSupported => {
25592559
format!("analyzing the transmutability of `{src}` is not yet supported")
25602560
}
2561-
25622561
rustc_transmute::Reason::DstIsNotYetSupported => {
25632562
format!("analyzing the transmutability of `{dst}` is not yet supported")
25642563
}
2565-
25662564
rustc_transmute::Reason::DstIsBitIncompatible => {
25672565
format!(
25682566
"at least one value of `{src}` isn't a bit-valid value of `{dst}`"
25692567
)
25702568
}
2571-
25722569
rustc_transmute::Reason::DstUninhabited => {
25732570
format!("`{dst}` is uninhabited")
25742571
}
2575-
25762572
rustc_transmute::Reason::DstMayHaveSafetyInvariants => {
25772573
format!("`{dst}` may carry safety invariants")
25782574
}
25792575
rustc_transmute::Reason::DstIsTooBig => {
25802576
format!("the size of `{src}` is smaller than the size of `{dst}`")
25812577
}
2582-
rustc_transmute::Reason::DstRefIsTooBig { src, dst } => {
2583-
let src_size = src.size;
2584-
let dst_size = dst.size;
2578+
rustc_transmute::Reason::DstRefIsTooBig {
2579+
src,
2580+
src_size,
2581+
dst,
2582+
dst_size,
2583+
} => {
25852584
format!(
2586-
"the referent size of `{src}` ({src_size} bytes) \
2585+
"the size of `{src}` ({src_size} bytes) \
25872586
is smaller than that of `{dst}` ({dst_size} bytes)"
25882587
)
25892588
}

0 commit comments

Comments
 (0)