Skip to content

Rollup of 11 pull requests #142099

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 6, 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
925e761
Ensure stack in `ThirBuildCx::mirror_exprs`
cuviper Jun 4, 2025
af2a85b
Ensure stack in `Parser::parse_ty`
cuviper Jun 4, 2025
64df9e3
compiler: Document the offset invariant of `OperandValue::Pair`
workingjubilee Jun 4, 2025
51acc57
canon_abi: make to_erased_extern_abi just a detail in formatting
RalfJung Jun 5, 2025
1e49ad3
Clean `rustc_attr_parsing` documentation
xizheyin Jun 5, 2025
79fbc38
doc: Fix inverted meaning in E0783.md
maflcko Jun 5, 2025
fd3da4b
Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None
oli-obk Jun 4, 2025
fde8a8d
Optimize `Seek::stream_len` impl for `File`
tbu- May 13, 2024
4b1e28b
Clarify description of `Seek::stream_len`
tbu- Jan 9, 2025
7b8f519
add myself to rotation
jdonszelmann Jun 5, 2025
9770f9b
cleaned up some tests
Kivooeo Jun 3, 2025
911d4a0
Rename `should_show_cast` to `should_fully_qualify`
fmease Jun 5, 2025
95bf127
Support middle::ty assoc const eq predicates again
fmease Jun 5, 2025
46ce08e
Fix AIX build
thaliaarchi Jun 5, 2025
c141cbf
Rollup merge of #125087 - tbu-:pr_file_stream_len, r=ChrisDenton
matthiaskrgr Jun 5, 2025
5e140db
Rollup merge of #141982 - Kivooeo:tf5, r=jieyouxu
matthiaskrgr Jun 5, 2025
c1d1f7a
Rollup merge of #142012 - oli-obk:no-optional-spans, r=fee1-dead
matthiaskrgr Jun 5, 2025
29954af
Rollup merge of #142044 - workingjubilee:document-operandvalue-pair, …
matthiaskrgr Jun 5, 2025
324681b
Rollup merge of #142047 - cuviper:s390x-stack, r=oli-obk
matthiaskrgr Jun 5, 2025
7420ae8
Rollup merge of #142058 - xizheyin:rustc-attr-parsing, r=jdonszelmann
matthiaskrgr Jun 5, 2025
2f7de4f
Rollup merge of #142067 - RalfJung:abi-map-to-str, r=workingjubilee
matthiaskrgr Jun 5, 2025
ed7d1f9
Rollup merge of #142072 - maflcko:patch-1, r=aDotInTheVoid
matthiaskrgr Jun 5, 2025
defec9f
Rollup merge of #142084 - jdonszelmann:add-review-rotation, r=BoxyUwU
matthiaskrgr Jun 5, 2025
9c89555
Rollup merge of #142091 - thaliaarchi:aix-getenv, r=workingjubilee
matthiaskrgr Jun 5, 2025
e12572f
Rollup merge of #142092 - fmease:rustdoc-alias-terms, r=GuillaumeGomez
matthiaskrgr Jun 5, 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
19 changes: 6 additions & 13 deletions compiler/rustc_abi/src/canon_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,10 @@ pub enum CanonAbi {

impl fmt::Display for CanonAbi {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.to_erased_extern_abi().as_str().fmt(f)
}
}

impl CanonAbi {
/// convert to the ExternAbi that *shares a string* with this CanonAbi
///
/// A target-insensitive mapping of CanonAbi to ExternAbi, convenient for "forwarding" impls.
/// Importantly, the set of CanonAbi values is a logical *subset* of ExternAbi values,
/// so this is injective: if you take an ExternAbi to a CanonAbi and back, you have lost data.
const fn to_erased_extern_abi(self) -> ExternAbi {
match self {
// convert to the ExternAbi that *shares a string* with this CanonAbi.
// FIXME: ideally we'd avoid printing `CanonAbi`, and preserve `ExternAbi` everywhere
// that we need to generate error messages.
let erased_abi = match self {
CanonAbi::C => ExternAbi::C { unwind: false },
CanonAbi::Rust => ExternAbi::Rust,
CanonAbi::RustCold => ExternAbi::RustCold,
Expand All @@ -87,7 +79,8 @@ impl CanonAbi {
X86Call::Vectorcall => ExternAbi::Vectorcall { unwind: false },
X86Call::Win64 => ExternAbi::Win64 { unwind: false },
},
}
};
erased_abi.as_str().fmt(f)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
span: Span,
args: Option<&'hir hir::GenericArgs<'hir>>,
) -> &'hir hir::Path<'hir> {
let def_id = self.tcx.require_lang_item(lang_item, Some(span));
let def_id = self.tcx.require_lang_item(lang_item, span);
let def_kind = self.tcx.def_kind(def_id);
let res = Res::Def(def_kind, def_id);
self.arena.alloc(hir::Path {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(crate) trait AttributeParser: Default + 'static {
pub(crate) trait SingleAttributeParser: 'static {
const PATH: &'static [Symbol];

/// Caled when a duplicate attribute is found.
/// Called when a duplicate attribute is found.
///
/// `first_span` is the span of the first occurrence of this attribute.
// FIXME(jdonszelmann): default error
Expand Down
72 changes: 36 additions & 36 deletions compiler/rustc_attr_parsing/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
//! Centralized logic for parsing and attributes.
//!
//! Part of a series of crates:
//! - rustc_attr_data_structures: contains types that the parsers parse into
//! - rustc_attr_parsing: this crate
//! - (in the future): rustc_attr_validation
//! ## Architecture
//! This crate is part of a series of crates that handle attribute processing.
//! - [rustc_attr_data_structures](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_data_structures/index.html): Defines the data structures that store parsed attributes
//! - [rustc_attr_parsing](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html): This crate, handles the parsing of attributes
//! - (planned) rustc_attr_validation: Will handle attribute validation
//!
//! History: Check out [#131229](https://github.com/rust-lang/rust/issues/131229).
//! There used to be only one definition of attributes in the compiler: `ast::Attribute`.
//! These were then parsed or validated or both in places distributed all over the compiler.
//! This was a mess...
//! The separation between data structures and parsing follows the principle of separation of concerns.
//! Data structures (`rustc_attr_data_structures`) define what attributes look like after parsing.
//! This crate (`rustc_attr_parsing`) handles how to convert raw tokens into those structures.
//! This split allows other parts of the compiler to use the data structures without needing
//! the parsing logic, making the codebase more modular and maintainable.
//!
//! Attributes are markers on items.
//! Many of them are actually attribute-like proc-macros, and are expanded to some other rust syntax.
//! This could either be a user provided proc macro, or something compiler provided.
//! `derive` is an example of one that the compiler provides.
//! These are built-in, but they have a valid expansion to Rust tokens and are thus called "active".
//! I personally like calling these *active* compiler-provided attributes, built-in *macros*,
//! because they still expand, and this helps to differentiate them from built-in *attributes*.
//! However, I'll be the first to admit that the naming here can be confusing.
//! ## Background
//! Previously, the compiler had a single attribute definition (`ast::Attribute`) with parsing and
//! validation scattered throughout the codebase. This was reorganized for better maintainability
//! (see [#131229](https://github.com/rust-lang/rust/issues/131229)).
//!
//! The alternative to active attributes, are inert attributes.
//! These can occur in user code (proc-macro helper attributes).
//! But what's important is, many built-in attributes are inert like this.
//! There is nothing they expand to during the macro expansion process,
//! sometimes because they literally cannot expand to something that is valid Rust.
//! They are really just markers to guide the compilation process.
//! An example is `#[inline(...)]` which changes how code for functions is generated.
//! ## Types of Attributes
//! In Rust, attributes are markers that can be attached to items. They come in two main categories.
//!
//! ### 1. Active Attributes
//! These are attribute-like proc-macros that expand into other Rust code.
//! They can be either user-defined or compiler-provided. Examples of compiler-provided active attributes:
//! - `#[derive(...)]`: Expands into trait implementations
//! - `#[cfg()]`: Expands based on configuration
//! - `#[cfg_attr()]`: Conditional attribute application
//!
//! ### 2. Inert Attributes
//! These are pure markers that don't expand into other code. They guide the compilation process.
//! They can be user-defined (in proc-macro helpers) or built-in. Examples of built-in inert attributes:
//! - `#[stable()]`: Marks stable API items
//! - `#[inline()]`: Suggests function inlining
//! - `#[repr()]`: Controls type representation
//!
//! ```text
//! Active Inert
//! ┌──────────────────────┬──────────────────────┐
//! │ (mostly in) │ these are parsed │
//! │ rustc_builtin_macros │ here! │
//! │ │ │
//! │ │ │
//! │ #[derive(...)] │ #[stable()] │
//! Built-in │ #[cfg()] │ #[inline()] │
//! │ #[cfg_attr()] │ #[repr()] │
//! │ │ │
//! │ │ │
//! │ │ │
//! ├──────────────────────┼──────────────────────┤
//! │ │ │
//! │ │ │
//! │ │ `b` in │
//! │ │ #[proc_macro_derive( │
//! User created │ #[proc_macro_attr()] │ a, │
//! │ │ attributes(b) │
//! │ │ ] │
//! │ │ │
//! │ │ │
//! │ │ │
//! └──────────────────────┴──────────────────────┘
//! ```
//!
//! ## How This Crate Works
//! In this crate, syntactical attributes (sequences of tokens that look like
//! `#[something(something else)]`) are parsed into more semantic attributes, markers on items.
//! Multiple syntactic attributes might influence a single semantic attribute. For example,
Expand All @@ -63,18 +64,17 @@
//! and `#[unstable()]` syntactic attributes, and at the end produce a single
//! [`AttributeKind::Stability`](rustc_attr_data_structures::AttributeKind::Stability).
//!
//! As a rule of thumb, when a syntactical attribute can be applied more than once, they should be
//! combined into a single semantic attribute. For example:
//! When multiple instances of the same attribute are allowed, they're combined into a single
//! semantic attribute. For example:
//!
//! ```
//! ```rust
//! #[repr(C)]
//! #[repr(packed)]
//! struct Meow {}
//! ```
//!
//! should result in a single `AttributeKind::Repr` containing a list of repr annotations, in this
//! case `C` and `packed`. This is equivalent to writing `#[repr(C, packed)]` in a single
//! syntactical annotation.
//! This is equivalent to `#[repr(C, packed)]` and results in a single `AttributeKind::Repr`
//! containing both `C` and `packed` annotations.
// tidy-alphabetical-start
#![allow(internal_features)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// something that already has `Fn`-like bounds (or is a closure), so we can't
// restrict anyways.
} else {
let copy_did = self.infcx.tcx.require_lang_item(LangItem::Copy, Some(span));
let copy_did = self.infcx.tcx.require_lang_item(LangItem::Copy, span);
self.suggest_adding_bounds(&mut err, ty, copy_did, span);
}

Expand Down Expand Up @@ -1915,7 +1915,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {

let local_ty = self.body.local_decls[place.local].ty;
let typeck_results = tcx.typeck(self.mir_def_id());
let clone = tcx.require_lang_item(LangItem::Clone, Some(body.span));
let clone = tcx.require_lang_item(LangItem::Clone, body.span);
for expr in expr_finder.clones {
if let hir::ExprKind::MethodCall(_, rcvr, _, span) = expr.kind
&& let Some(rcvr_ty) = typeck_results.node_type_opt(rcvr.hir_id)
Expand Down
22 changes: 8 additions & 14 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
if !self.unsized_feature_enabled() {
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
tcx.require_lang_item(LangItem::Sized, self.last_span),
[place_ty],
);
self.prove_trait_ref(
Expand Down Expand Up @@ -1010,7 +1010,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let ty = place.ty(self.body, tcx).ty;
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Copy, Some(span)),
tcx.require_lang_item(LangItem::Copy, span),
[ty],
);

Expand All @@ -1025,11 +1025,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}

&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Sized, Some(span)),
[ty],
);
let trait_ref =
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, span), [ty]);

self.prove_trait_ref(
trait_ref,
Expand All @@ -1041,11 +1038,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
&Rvalue::NullaryOp(NullOp::UbChecks, _) => {}

Rvalue::ShallowInitBox(_operand, ty) => {
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Sized, Some(span)),
[*ty],
);
let trait_ref =
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, span), [*ty]);

self.prove_trait_ref(
trait_ref,
Expand Down Expand Up @@ -1222,7 +1216,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let &ty = ty;
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::CoerceUnsized, Some(span)),
tcx.require_lang_item(LangItem::CoerceUnsized, span),
[op.ty(self.body, tcx), ty],
);

Expand Down Expand Up @@ -1811,7 +1805,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Copy, Some(self.last_span)),
tcx.require_lang_item(LangItem::Copy, self.last_span),
[place_ty.ty],
);

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
// (as it's created inside the body itself, not passed in from outside).
if let DefiningTy::FnDef(def_id, _) = defining_ty {
if self.infcx.tcx.fn_sig(def_id).skip_binder().c_variadic() {
let va_list_did = self.infcx.tcx.require_lang_item(
LangItem::VaList,
Some(self.infcx.tcx.def_span(self.mir_def)),
);
let va_list_did = self
.infcx
.tcx
.require_lang_item(LangItem::VaList, self.infcx.tcx.def_span(self.mir_def));

let reg_vid = self
.infcx
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
rustc_hir::LangItem::PanicBoundsCheck,
&[index, len, location],
*unwind,
Some(source_info.span),
source_info.span,
);
}
AssertKind::MisalignedPointerDereference { ref required, ref found } => {
Expand All @@ -393,7 +393,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
rustc_hir::LangItem::PanicMisalignedPointerDereference,
&[required, found, location],
*unwind,
Some(source_info.span),
source_info.span,
);
}
AssertKind::NullPointerDereference => {
Expand All @@ -404,7 +404,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
rustc_hir::LangItem::PanicNullPointerDereference,
&[location],
*unwind,
Some(source_info.span),
source_info.span,
)
}
_ => {
Expand All @@ -415,7 +415,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
msg.panic_function(),
&[location],
*unwind,
Some(source_info.span),
source_info.span,
);
}
}
Expand Down Expand Up @@ -531,7 +531,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
);
}
TerminatorKind::UnwindTerminate(reason) => {
codegen_unwind_terminate(fx, Some(source_info.span), *reason);
codegen_unwind_terminate(fx, source_info.span, *reason);
}
TerminatorKind::UnwindResume => {
// FIXME implement unwinding
Expand Down Expand Up @@ -1074,7 +1074,7 @@ pub(crate) fn codegen_operand<'tcx>(
pub(crate) fn codegen_panic_nounwind<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
msg_str: &str,
span: Option<Span>,
span: Span,
) {
let msg_ptr = fx.anonymous_str(msg_str);
let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap());
Expand All @@ -1091,7 +1091,7 @@ pub(crate) fn codegen_panic_nounwind<'tcx>(

pub(crate) fn codegen_unwind_terminate<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
span: Option<Span>,
span: Span,
reason: UnwindTerminateReason,
) {
codegen_panic_inner(fx, reason.lang_item(), &[], UnwindAction::Unreachable, span);
Expand All @@ -1102,7 +1102,7 @@ fn codegen_panic_inner<'tcx>(
lang_item: rustc_hir::LangItem,
args: &[Value],
_unwind: UnwindAction,
span: Option<Span>,
span: Span,
) {
fx.bcx.set_cold_block(fx.bcx.current_block().unwrap());

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/intrinsics/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
See https://github.com/rust-lang/rustc_codegen_cranelift/issues/171\n\
Please open an issue at https://github.com/rust-lang/rustc_codegen_cranelift/issues"
);
crate::base::codegen_panic_nounwind(fx, &msg, None);
crate::base::codegen_panic_nounwind(fx, &msg, span);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ pub(super) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
See https://github.com/rust-lang/rustc_codegen_cranelift/issues/171\n\
Please open an issue at https://github.com/rust-lang/rustc_codegen_cranelift/issues"
);
crate::base::codegen_panic_nounwind(fx, &msg, None);
crate::base::codegen_panic_nounwind(fx, &msg, fx.mir.span);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ pub(super) fn codegen_x86_llvm_intrinsic_call<'tcx>(
See https://github.com/rust-lang/rustc_codegen_cranelift/issues/171\n\
Please open an issue at https://github.com/rust-lang/rustc_codegen_cranelift/issues"
);
crate::base::codegen_panic_nounwind(fx, &msg, None);
crate::base::codegen_panic_nounwind(fx, &msg, span);
return;
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
}
})
});
crate::base::codegen_panic_nounwind(fx, &msg_str, Some(source_info.span));
crate::base::codegen_panic_nounwind(fx, &msg_str, source_info.span);
return Ok(());
}
}
Expand Down Expand Up @@ -884,7 +884,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
crate::base::codegen_panic_nounwind(
fx,
"128bit atomics not yet supported",
None,
source_info.span,
);
return Ok(());
} else {
Expand Down Expand Up @@ -919,7 +919,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
crate::base::codegen_panic_nounwind(
fx,
"128bit atomics not yet supported",
None,
source_info.span,
);
return Ok(());
} else {
Expand Down
Loading
Loading