Skip to content

Rollup of 10 pull requests #142392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1d66e66
add `body` to `ClosureDef`
b-naber May 20, 2025
8604e58
add doc comment and a test with a generic closure
b-naber Jun 2, 2025
46326e1
Use non-2015 edition paths in tests that do not test for their resolu…
Veykril Jun 5, 2025
1d7c1b1
Add more missing 2015 edition directives
Veykril Jun 5, 2025
2549962
Add missing `dyn` keywords to tests that do not test for them
Veykril Jun 5, 2025
4882ea4
rustc_resolve: Improve `resolve_const_param_in_non_trivial_anon_const…
Enselic Jun 7, 2025
e9eae28
transmutability: shift abstraction boundary
jswrenn Jun 4, 2025
2c82574
use correct edition when warning for unsafe attributes
folkertdev Jun 9, 2025
f461997
Rename `build` to `host_target`
Kobzol Jun 10, 2025
20e8325
Improve documentation of the `Rustc` step and rename `compiler` to `b…
Kobzol Jun 10, 2025
208f2e4
Remove useless and wrong std crates special casing when un-remap sysroot
Urgau Jun 10, 2025
b88c006
compiler: Change c_int_width to be an integer type
workingjubilee Jun 11, 2025
87feee9
compiler: Update all targets to the new c_int_width type
workingjubilee Jun 11, 2025
0994063
cleaned up some tests
Kivooeo Jun 8, 2025
c6c55cc
cleaned up some tests
Kivooeo Jun 8, 2025
9f6e81c
Rollup merge of #141307 - b-naber:closure-body, r=celinval
matthiaskrgr Jun 12, 2025
bdf7b74
Rollup merge of #142040 - jswrenn:transmute-ty-region-generic, r=comp…
matthiaskrgr Jun 12, 2025
b3ddf3c
Rollup merge of #142066 - ferrocene:lw/edition-2015-tests, r=compiler…
matthiaskrgr Jun 12, 2025
2d9513b
Rollup merge of #142157 - Enselic:trivial-anon-const-use-cases, r=com…
matthiaskrgr Jun 12, 2025
c557695
Rollup merge of #142217 - Kivooeo:tf10, r=jieyouxu
matthiaskrgr Jun 12, 2025
e2e201f
Rollup merge of #142219 - Kivooeo:tf11, r=wesleywiser
matthiaskrgr Jun 12, 2025
75c186b
Rollup merge of #142261 - folkertdev:unstable-attr-correct-edition, r…
matthiaskrgr Jun 12, 2025
bb9dda1
Rollup merge of #142303 - Kobzol:bootstrap-cleanup-1, r=jieyouxu
matthiaskrgr Jun 12, 2025
78d8395
Rollup merge of #142318 - Urgau:cleanup-rust-src-remap, r=jieyouxu
matthiaskrgr Jun 12, 2025
2407761
Rollup merge of #142352 - workingjubilee:c-int-width-is-an-integer, r…
matthiaskrgr Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ pub trait DerivedTypeCodegenMethods<'tcx>:
BaseTypeCodegenMethods + MiscCodegenMethods<'tcx> + HasTyCtxt<'tcx> + HasTypingEnv<'tcx>
{
fn type_int(&self) -> Self::Type {
match &self.sess().target.c_int_width[..] {
"16" => self.type_i16(),
"32" => self.type_i32(),
"64" => self.type_i64(),
match &self.sess().target.c_int_width {
16 => self.type_i16(),
32 => self.type_i32(),
64 => self.type_i64(),
width => bug!("Unsupported c_int_width: {}", width),
}
}
Expand Down
29 changes: 1 addition & 28 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1649,34 +1649,7 @@ impl<'a> CrateMetadataRef<'a> {
old_name
&& let Ok(rest) = virtual_name.strip_prefix(virtual_dir)
{
// The std library crates are in
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
// detect crates from the std libs and handle them specially.
const STD_LIBS: &[&str] = &[
"core",
"alloc",
"std",
"test",
"term",
"unwind",
"proc_macro",
"panic_abort",
"panic_unwind",
"profiler_builtins",
"rtstartup",
"rustc-std-workspace-core",
"rustc-std-workspace-alloc",
"rustc-std-workspace-std",
"backtrace",
];
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));

let new_path = if is_std_lib {
real_dir.join("library").join(rest)
} else {
real_dir.join(rest)
};
let new_path = real_dir.join(rest);

debug!(
"try_to_translate_virtual_to_real: `{}` -> `{}`",
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_parse/src/validate_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,14 @@ pub fn check_attribute_safety(
let diag_span = attr_item.span();

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

if emit_error {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ resolve_const_param_in_enum_discriminant =
const parameters may not be used in enum discriminant values

resolve_const_param_in_non_trivial_anon_const =
const parameters may only be used as standalone arguments, i.e. `{$name}`
const parameters may only be used as standalone arguments here, i.e. `{$name}`

resolve_constructor_private_if_any_field_private =
a constructor is private if any of the fields is private
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_smir/src/stable_mir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@ crate_def! {
pub ClosureDef;
}

impl ClosureDef {
/// Retrieves the body of the closure definition. Returns None if the body
/// isn't available.
pub fn body(&self) -> Option<Body> {
with(|ctx| ctx.has_body(self.0).then(|| ctx.mir_body(self.0)))
}
}

crate_def! {
#[derive(Serialize)]
pub CoroutineDef;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/base/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: "none".into(),
endian: Endian::Little,
c_int_width: "32".into(),
c_int_width: 32,
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
executables: true,
panic_strategy: PanicStrategy::Abort,
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_target/src/spec/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ impl Target {
base.$key_name = s;
}
} );
($key_name:ident = $json_name:expr, u64 as $int_ty:ty) => ( {
let name = $json_name;
if let Some(s) = obj.remove(name).and_then(|b| b.as_u64()) {
base.$key_name = s as $int_ty;
}
} );
($key_name:ident, bool) => ( {
let name = (stringify!($key_name)).replace("_", "-");
if let Some(s) = obj.remove(&name).and_then(|b| b.as_bool()) {
Expand Down Expand Up @@ -554,7 +560,7 @@ impl Target {
}
}

key!(c_int_width = "target-c-int-width");
key!(c_int_width = "target-c-int-width", u64 as u16);
key!(c_enum_min_bits, Option<u64>); // if None, matches c_int_width
key!(os);
key!(env);
Expand Down
20 changes: 6 additions & 14 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2213,18 +2213,10 @@ impl Target {
});
}

dl.c_enum_min_size = self
.c_enum_min_bits
.map_or_else(
|| {
self.c_int_width
.parse()
.map_err(|_| String::from("failed to parse c_int_width"))
},
Ok,
)
.and_then(|i| Integer::from_size(Size::from_bits(i)))
.map_err(|err| TargetDataLayoutErrors::InvalidBitsSize { err })?;
dl.c_enum_min_size = Integer::from_size(Size::from_bits(
self.c_enum_min_bits.unwrap_or(self.c_int_width as _),
))
.map_err(|err| TargetDataLayoutErrors::InvalidBitsSize { err })?;

Ok(dl)
}
Expand Down Expand Up @@ -2286,7 +2278,7 @@ pub struct TargetOptions {
/// Used as the `target_endian` `cfg` variable. Defaults to little endian.
pub endian: Endian,
/// Width of c_int type. Defaults to "32".
pub c_int_width: StaticCow<str>,
pub c_int_width: u16,
/// OS name to use for conditional compilation (`target_os`). Defaults to "none".
/// "none" implies a bare metal target without `std` library.
/// A couple of targets having `std` also use "unknown" as an `os` value,
Expand Down Expand Up @@ -2783,7 +2775,7 @@ impl Default for TargetOptions {
fn default() -> TargetOptions {
TargetOptions {
endian: Endian::Little,
c_int_width: "32".into(),
c_int_width: 32,
os: "none".into(),
env: "".into(),
abi: "".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn target() -> Target {
options: TargetOptions {
os: "vita".into(),
endian: Endian::Little,
c_int_width: "32".into(),
c_int_width: 32,
env: "newlib".into(),
vendor: "sony".into(),
abi: "eabihf".into(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/targets/avr_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
llvm_target: "avr-unknown-unknown".into(),
pointer_width: 16,
options: TargetOptions {
c_int_width: "16".into(),
c_int_width: 16,
exe_suffix: ".elf".into(),
linker: Some("avr-gcc".into()),
eh_frame_header: false,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/targets/msp430_none_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
arch: "msp430".into(),

options: TargetOptions {
c_int_width: "16".into(),
c_int_width: 16,

// The LLVM backend currently can't generate object files. To
// workaround this LLVM generates assembly files which then we feed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {

options: TargetOptions {
endian: Endian::Little,
c_int_width: "32".into(),
c_int_width: 32,
families: cvs!["unix"],
os: "espidf".into(),
env: "newlib".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {

options: TargetOptions {
endian: Endian::Little,
c_int_width: "32".into(),
c_int_width: 32,
families: cvs!["unix"],
os: "espidf".into(),
env: "newlib".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {

options: TargetOptions {
endian: Endian::Little,
c_int_width: "32".into(),
c_int_width: 32,
families: cvs!["unix"],
os: "espidf".into(),
env: "newlib".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2558,32 +2558,31 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
rustc_transmute::Reason::SrcIsNotYetSupported => {
format!("analyzing the transmutability of `{src}` is not yet supported")
}

rustc_transmute::Reason::DstIsNotYetSupported => {
format!("analyzing the transmutability of `{dst}` is not yet supported")
}

rustc_transmute::Reason::DstIsBitIncompatible => {
format!(
"at least one value of `{src}` isn't a bit-valid value of `{dst}`"
)
}

rustc_transmute::Reason::DstUninhabited => {
format!("`{dst}` is uninhabited")
}

rustc_transmute::Reason::DstMayHaveSafetyInvariants => {
format!("`{dst}` may carry safety invariants")
}
rustc_transmute::Reason::DstIsTooBig => {
format!("the size of `{src}` is smaller than the size of `{dst}`")
}
rustc_transmute::Reason::DstRefIsTooBig { src, dst } => {
let src_size = src.size;
let dst_size = dst.size;
rustc_transmute::Reason::DstRefIsTooBig {
src,
src_size,
dst,
dst_size,
} => {
format!(
"the referent size of `{src}` ({src_size} bytes) \
"the size of `{src}` ({src_size} bytes) \
is smaller than that of `{dst}` ({dst_size} bytes)"
)
}
Expand Down
Loading
Loading