Skip to content

Rollup of 14 pull requests #145681

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

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9370440
stabilize `const_array_each_ref`
fee1-dead Jul 3, 2025
f4b3415
[Doc] Add links to the various collections
QnJ1c2kNCg Jul 31, 2025
8adc296
allow using `target_val!` with a rename
WaffleLapkin Jul 25, 2025
be42f3f
turn pointer width into an integer in target.json
WaffleLapkin Jul 25, 2025
6caa8ff
accept integer `target-pointer-width` in compiletest
WaffleLapkin Jul 25, 2025
51134eb
fix target-pointer-width in tests
WaffleLapkin Jul 31, 2025
e13e1e4
fix(debuginfo): handle false positives in overflow check
adwinwhite Aug 12, 2025
ee7627e
std_detect: RISC-V: implement implication to "C"
a4lg Aug 19, 2025
6a088fd
Defer tail call ret ty equality to check_tail_calls
compiler-errors Aug 19, 2025
5a451b8
Add new `--test-codegen-backend` bootstrap option
GuillaumeGomez Aug 11, 2025
e4cdc0f
Split compiletest `--codegen-backend` into two options `--default-cod…
GuillaumeGomez Aug 18, 2025
27e6726
Do not use effective_visibilities query for Adt types of a local trai…
xizheyin Aug 20, 2025
29f0d8b
Download CI GCC into the correct directory
Kobzol Aug 20, 2025
e1045c2
Fix JS search scripts path
GuillaumeGomez Aug 20, 2025
2da0ec3
Enforce correct number of arguments for `"x86-interrupt"` functions
GrigorenkoPV Aug 20, 2025
7d5c9ca
Consolidate panicking functions in `slice/index.rs`
Kmeakin Jul 25, 2025
992c025
Enable triagebot `[review-changes-since]` feature
Urgau Aug 20, 2025
f34fa22
fix: typo
ttajakka Aug 20, 2025
0968598
Rollup merge of #143383 - fee1-dead-contrib:push-mstmlwuskxyy, r=dtolnay
jhpratt Aug 20, 2025
9a50ad3
Rollup merge of #144443 - WaffleLapkin:integer-target-pointer-width, …
jhpratt Aug 20, 2025
e84281e
Rollup merge of #144758 - QnJ1c2kNCg:master, r=Noratrieb
jhpratt Aug 20, 2025
914612e
Rollup merge of #144915 - compiler-errors:tail-call-ret-ty-equality, …
jhpratt Aug 20, 2025
4ec40b9
Rollup merge of #145137 - Kmeakin:km/optimize-slice-index-panicking, …
jhpratt Aug 20, 2025
e9ac183
Rollup merge of #145256 - GuillaumeGomez:bootstrap-test-codegen-backe…
jhpratt Aug 20, 2025
415a8ac
Rollup merge of #145297 - adwinwhite:recursive-debuginfo, r=wesleywiser
jhpratt Aug 20, 2025
a3c768d
Rollup merge of #145415 - a4lg:riscv-implication-to-c, r=Amanieu
jhpratt Aug 20, 2025
5a45f5a
Rollup merge of #145642 - xizheyin:145611, r=lcnr
jhpratt Aug 20, 2025
fcd44a7
Rollup merge of #145650 - GuillaumeGomez:fix-js-search-scripts-path, …
jhpratt Aug 20, 2025
0920986
Rollup merge of #145654 - Kobzol:gcc-ci-root, r=jieyouxu
jhpratt Aug 20, 2025
08984d5
Rollup merge of #145662 - GrigorenkoPV:x86-interrupt, r=compiler-errors
jhpratt Aug 20, 2025
76d0ee3
Rollup merge of #145674 - Urgau:triagebot-review-changes-since, r=Kobzol
jhpratt Aug 20, 2025
920fe4e
Rollup merge of #145678 - ttajakka:master, r=estebank
jhpratt Aug 20, 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
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub enum TargetDataLayoutErrors<'a> {
MissingAlignment { cause: &'a str },
InvalidAlignment { cause: &'a str, err: AlignFromBytesError },
InconsistentTargetArchitecture { dl: &'a str, target: &'a str },
InconsistentTargetPointerWidth { pointer_size: u64, target: u32 },
InconsistentTargetPointerWidth { pointer_size: u64, target: u16 },
InvalidBitsSize { err: String },
UnknownPointerSpecification { err: String },
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl IntTy {
})
}

pub fn normalize(&self, target_width: u32) -> Self {
pub fn normalize(&self, target_width: u16) -> Self {
match self {
IntTy::Isize => match target_width {
16 => IntTy::I16,
Expand Down Expand Up @@ -148,7 +148,7 @@ impl UintTy {
})
}

pub fn normalize(&self, target_width: u32) -> Self {
pub fn normalize(&self, target_width: u16) -> Self {
match self {
UintTy::Usize => match target_width {
16 => UintTy::U16,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ast_passes_abi_must_not_have_return_type=
.note = functions with the {$abi} ABI cannot have a return type
.help = remove the return type
ast_passes_abi_x86_interrupt =
invalid signature for `extern "x86-interrupt"` function
.note = functions with the "x86-interrupt" ABI must be have either 1 or 2 parameters (but found {$param_count})
ast_passes_assoc_const_without_body =
associated constant in `impl` without body
.suggestion = provide a definition for the constant
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ impl<'a> AstValidator<'a> {
if let InterruptKind::X86 = interrupt_kind {
// "x86-interrupt" is special because it does have arguments.
// FIXME(workingjubilee): properly lint on acceptable input types.
let inputs = &sig.decl.inputs;
let param_count = inputs.len();
if !matches!(param_count, 1 | 2) {
let mut spans: Vec<Span> =
inputs.iter().map(|arg| arg.span).collect();
if spans.is_empty() {
spans = vec![sig.span];
}
self.dcx().emit_err(errors::AbiX86Interrupt { spans, param_count });
}

if let FnRetTy::Ty(ref ret_ty) = sig.decl.output
&& match &ret_ty.kind {
TyKind::Never => false,
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,3 +891,12 @@ pub(crate) struct AbiMustNotHaveReturnType {
pub span: Span,
pub abi: ExternAbi,
}

#[derive(Diagnostic)]
#[diag(ast_passes_abi_x86_interrupt)]
#[note]
pub(crate) struct AbiX86Interrupt {
#[primary_span]
pub spans: Vec<Span>,
pub param_count: usize,
}
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
if !output_ty
.is_privately_uninhabited(self.tcx(), self.infcx.typing_env(self.infcx.param_env))
{
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
span_mirbug!(self, term, "call to non-diverging function {:?} w/o dest", sig);
}
} else {
let dest_ty = destination.ty(self.body, tcx).ty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"unix"
],
"target-mcount": "_mcount",
"target-pointer-width": "32"
"target-pointer-width": 32
}
54 changes: 38 additions & 16 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ pub(super) fn build_type_with_children<'ll, 'tcx>(
&& let ty::Adt(adt_def, args) = ty.kind()
{
let def_id = adt_def.did();
// If any sub type reference the original type definition and the sub type has a type
// If any child type references the original type definition and the child type has a type
// parameter that strictly contains the original parameter, the original type is a recursive
// type that can expanding indefinitely. Example,
// ```
Expand All @@ -285,21 +285,43 @@ pub(super) fn build_type_with_children<'ll, 'tcx>(
// Item(T),
// }
// ```
let is_expanding_recursive = adt_def.is_enum()
&& debug_context(cx).adt_stack.borrow().iter().any(|(parent_def_id, parent_args)| {
if def_id == *parent_def_id {
args.iter().zip(parent_args.iter()).any(|(arg, parent_arg)| {
if let (Some(arg), Some(parent_arg)) = (arg.as_type(), parent_arg.as_type())
{
arg != parent_arg && arg.contains(parent_arg)
} else {
false
}
})
} else {
false
}
});
let is_expanding_recursive = {
let stack = debug_context(cx).adt_stack.borrow();
stack
.iter()
.enumerate()
.rev()
.skip(1)
.filter(|(_, (ancestor_def_id, _))| def_id == *ancestor_def_id)
.any(|(ancestor_index, (_, ancestor_args))| {
args.iter()
.zip(ancestor_args.iter())
.filter_map(|(arg, ancestor_arg)| arg.as_type().zip(ancestor_arg.as_type()))
.any(|(arg, ancestor_arg)|
// Strictly contains.
(arg != ancestor_arg && arg.contains(ancestor_arg))
// Check all types between current and ancestor use the
// ancestor_arg.
// Otherwise, duplicate wrappers in normal recursive type may be
// regarded as expanding.
// ```
// struct Recursive {
// a: Box<Box<Recursive>>,
// }
// ```
// It can produce an ADT stack like this,
// - Box<Recursive>
// - Recursive
// - Box<Box<Recursive>>
&& stack[ancestor_index + 1..stack.len()].iter().all(
|(_, intermediate_args)|
intermediate_args
.iter()
.filter_map(|arg| arg.as_type())
.any(|mid_arg| mid_arg.contains(ancestor_arg))
))
})
};
if is_expanding_recursive {
// FIXME: indicate that this is an expanding recursive type in stub metadata?
return DINodeCreationResult::new(stub_info.metadata, false);
Expand Down
41 changes: 17 additions & 24 deletions compiler/rustc_mir_build/src/check_tail_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,23 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
self.report_abi_mismatch(expr.span, caller_sig.abi, callee_sig.abi);
}

// FIXME(explicit_tail_calls): this currently fails for cases where opaques are used.
// e.g.
// ```
// fn a() -> impl Sized { become b() } // ICE
// fn b() -> u8 { 0 }
// ```
// we should think what is the expected behavior here.
// (we should probably just accept this by revealing opaques?)
if caller_sig.inputs_and_output != callee_sig.inputs_and_output {
if caller_sig.inputs() != callee_sig.inputs() {
self.report_arguments_mismatch(
expr.span,
self.tcx.liberate_late_bound_regions(
CRATE_DEF_ID.to_def_id(),
self.caller_ty.fn_sig(self.tcx),
),
self.tcx
.liberate_late_bound_regions(CRATE_DEF_ID.to_def_id(), ty.fn_sig(self.tcx)),
);
}

// FIXME(explicit_tail_calls): this currently fails for cases where opaques are used.
// e.g.
// ```
// fn a() -> impl Sized { become b() } // ICE
// fn b() -> u8 { 0 }
// ```
// we should think what is the expected behavior here.
// (we should probably just accept this by revealing opaques?)
if caller_sig.output() != callee_sig.output() {
span_bug!(expr.span, "hir typeck should have checked the return type already");
}
self.report_signature_mismatch(
expr.span,
self.tcx.liberate_late_bound_regions(
CRATE_DEF_ID.to_def_id(),
self.caller_ty.fn_sig(self.tcx),
),
self.tcx.liberate_late_bound_regions(CRATE_DEF_ID.to_def_id(), ty.fn_sig(self.tcx)),
);
}

{
Expand Down Expand Up @@ -365,7 +358,7 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
self.found_errors = Err(err);
}

fn report_arguments_mismatch(
fn report_signature_mismatch(
&mut self,
sp: Span,
caller_sig: ty::FnSig<'_>,
Expand Down
25 changes: 10 additions & 15 deletions compiler/rustc_target/src/spec/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ impl Target {
let mut base = Target {
llvm_target: json.llvm_target,
metadata: Default::default(),
pointer_width: json
.target_pointer_width
.parse()
.map_err(|err| format!("invalid target-pointer-width: {err}"))?,
pointer_width: json.target_pointer_width,
data_layout: json.data_layout,
arch: json.arch,
options: Default::default(),
Expand Down Expand Up @@ -245,19 +242,17 @@ impl ToJson for Target {
target.update_to_cli();

macro_rules! target_val {
($attr:ident) => {{
let name = (stringify!($attr)).replace("_", "-");
d.insert(name, target.$attr.to_json());
($attr:ident) => {
target_val!($attr, (stringify!($attr)).replace("_", "-"))
};
($attr:ident, $json_name:expr) => {{
let name = $json_name;
d.insert(name.into(), target.$attr.to_json());
}};
}

macro_rules! target_option_val {
($attr:ident) => {{
let name = (stringify!($attr)).replace("_", "-");
if default.$attr != target.$attr {
d.insert(name, target.$attr.to_json());
}
}};
($attr:ident) => {{ target_option_val!($attr, (stringify!($attr)).replace("_", "-")) }};
($attr:ident, $json_name:expr) => {{
let name = $json_name;
if default.$attr != target.$attr {
Expand Down Expand Up @@ -290,7 +285,7 @@ impl ToJson for Target {

target_val!(llvm_target);
target_val!(metadata);
d.insert("target-pointer-width".to_string(), self.pointer_width.to_string().to_json());
target_val!(pointer_width, "target-pointer-width");
target_val!(arch);
target_val!(data_layout);

Expand Down Expand Up @@ -463,7 +458,7 @@ struct TargetSpecJsonMetadata {
#[serde(deny_unknown_fields)]
struct TargetSpecJson {
llvm_target: StaticCow<str>,
target_pointer_width: String,
target_pointer_width: u16,
data_layout: StaticCow<str>,
arch: StaticCow<str>,

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,7 @@ pub struct Target {
/// Used for generating target documentation.
pub metadata: TargetMetadata,
/// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable.
pub pointer_width: u32,
pub pointer_width: u16,
/// Architecture to use for ABI considerations. Valid options include: "x86",
/// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others.
pub arch: StaticCow<str>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn report_unused_fields() {
"arch": "powerpc64",
"data-layout": "e-m:e-i64:64-n32:64",
"llvm-target": "powerpc64le-elf",
"target-pointer-width": "64",
"target-pointer-width": 64,
"code-mode": "foo"
}
"#;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// we check if `TraitB` can be reachable from `S`
// to determine whether to note `TraitA` is sealed trait.
if let ty::Adt(adt, _) = ty.kind() {
let visibilities = tcx.effective_visibilities(());
let visibilities = &tcx.resolutions(()).effective_visibilities;
visibilities.effective_vis(local).is_none_or(|v| {
v.at_level(Level::Reexported)
.is_accessible_from(adt.did(), tcx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
},
"panic-strategy": "abort",
"relocation-model": "static",
"target-pointer-width": "32"
"target-pointer-width": 32
}
8 changes: 4 additions & 4 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,11 @@ impl<T, const N: usize> [T; N] {
/// assert_eq!(strings.len(), 3);
/// ```
#[stable(feature = "array_methods", since = "1.77.0")]
#[rustc_const_unstable(feature = "const_array_each_ref", issue = "133289")]
#[rustc_const_stable(feature = "const_array_each_ref", since = "CURRENT_RUSTC_VERSION")]
pub const fn each_ref(&self) -> [&T; N] {
let mut buf = [null::<T>(); N];

// FIXME(const-hack): We would like to simply use iterators for this (as in the original implementation), but this is not allowed in constant expressions.
// FIXME(const_trait_impl): We would like to simply use iterators for this (as in the original implementation), but this is not allowed in constant expressions.
let mut i = 0;
while i < N {
buf[i] = &raw const self[i];
Expand All @@ -652,11 +652,11 @@ impl<T, const N: usize> [T; N] {
/// assert_eq!(floats, [0.0, 2.7, -1.0]);
/// ```
#[stable(feature = "array_methods", since = "1.77.0")]
#[rustc_const_unstable(feature = "const_array_each_ref", issue = "133289")]
#[rustc_const_stable(feature = "const_array_each_ref", since = "CURRENT_RUSTC_VERSION")]
pub const fn each_mut(&mut self) -> [&mut T; N] {
let mut buf = [null_mut::<T>(); N];

// FIXME(const-hack): We would like to simply use iterators for this (as in the original implementation), but this is not allowed in constant expressions.
// FIXME(const_trait_impl): We would like to simply use iterators for this (as in the original implementation), but this is not allowed in constant expressions.
let mut i = 0;
while i < N {
buf[i] = &raw mut self[i];
Expand Down
Loading
Loading