Skip to content

Commit 7c26960

Browse files
committed
Auto merge of #154007 - JonathanBrouwer:rollup-WcvGVsy, r=<try>
Rollup of 8 pull requests try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1
2 parents b711f95 + 56840bb commit 7c26960

85 files changed

Lines changed: 1305 additions & 585 deletions

File tree

Some content is hidden

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

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14871487
ident,
14881488
sig,
14891489
);
1490+
1491+
if let Some(attr) = attr::find_by_name(fi.attrs(), sym::track_caller)
1492+
&& self.extern_mod_abi != Some(ExternAbi::Rust)
1493+
{
1494+
self.dcx().emit_err(errors::RequiresRustAbi {
1495+
track_caller_span: attr.span,
1496+
extern_abi_span: self.current_extern_span(),
1497+
});
1498+
}
14901499
}
14911500
ForeignItemKind::TyAlias(box TyAlias {
14921501
defaultness,
@@ -1672,10 +1681,19 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
16721681
}
16731682

16741683
if let FnKind::Fn(ctxt, _, fun) = fk
1675-
&& let Extern::Explicit(str_lit, _) = fun.sig.header.ext
1684+
&& let Extern::Explicit(str_lit, extern_abi_span) = fun.sig.header.ext
16761685
&& let Ok(abi) = ExternAbi::from_str(str_lit.symbol.as_str())
16771686
{
16781687
self.check_extern_fn_signature(abi, ctxt, &fun.ident, &fun.sig);
1688+
1689+
if let Some(attr) = attr::find_by_name(attrs, sym::track_caller)
1690+
&& abi != ExternAbi::Rust
1691+
{
1692+
self.dcx().emit_err(errors::RequiresRustAbi {
1693+
track_caller_span: attr.span,
1694+
extern_abi_span,
1695+
});
1696+
}
16791697
}
16801698

16811699
self.check_c_variadic_type(fk, attrs);

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,3 +1140,13 @@ pub(crate) struct ScalableVectorBadArch {
11401140
#[primary_span]
11411141
pub span: Span,
11421142
}
1143+
1144+
#[derive(Diagnostic)]
1145+
#[diag("`#[track_caller]` can only be used with the Rust ABI", code = E0737)]
1146+
pub(crate) struct RequiresRustAbi {
1147+
#[primary_span]
1148+
#[label("using `#[track_caller]` here")]
1149+
pub track_caller_span: Span,
1150+
#[label("not using the Rust ABI because of this")]
1151+
pub extern_abi_span: Span,
1152+
}

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ impl<S: Stage> SingleAttributeParser<S> for SanitizeParser {
671671
item.path().span(),
672672
&[
673673
sym::address,
674+
sym::kernel_address,
674675
sym::cfi,
675676
sym::kcfi,
676677
sym::memory,

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ pub(crate) fn parse_unstability<S: Stage>(
376376
let mut reason = None;
377377
let mut issue = None;
378378
let mut issue_num = None;
379-
let mut is_soft = false;
380379
let mut implied_by = None;
381380
let mut old_name = None;
382381

@@ -423,12 +422,6 @@ pub(crate) fn parse_unstability<S: Stage>(
423422
},
424423
};
425424
}
426-
Some(sym::soft) => {
427-
if let Err(span) = args.no_args() {
428-
cx.emit_err(session_diagnostics::SoftNoArgs { span });
429-
}
430-
is_soft = true;
431-
}
432425
Some(sym::implied_by) => {
433426
insert_value_into_option_or_error(cx, &param, &mut implied_by, word.unwrap())?
434427
}
@@ -438,14 +431,7 @@ pub(crate) fn parse_unstability<S: Stage>(
438431
_ => {
439432
cx.expected_specific_argument(
440433
param.span(),
441-
&[
442-
sym::feature,
443-
sym::reason,
444-
sym::issue,
445-
sym::soft,
446-
sym::implied_by,
447-
sym::old_name,
448-
],
434+
&[sym::feature, sym::reason, sym::issue, sym::implied_by, sym::old_name],
449435
);
450436
return None;
451437
}
@@ -468,7 +454,6 @@ pub(crate) fn parse_unstability<S: Stage>(
468454
let level = StabilityLevel::Unstable {
469455
reason: UnstableReason::from_opt_reason(reason),
470456
issue: issue_num,
471-
is_soft,
472457
implied_by,
473458
old_name,
474459
};

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,6 @@ pub(crate) struct InvalidSince {
374374
pub span: Span,
375375
}
376376

377-
#[derive(Diagnostic)]
378-
#[diag("`soft` should not have any arguments")]
379-
pub(crate) struct SoftNoArgs {
380-
#[primary_span]
381-
pub span: Span,
382-
}
383-
384377
#[derive(Diagnostic)]
385378
#[diag("unknown version literal format, assuming it refers to a future version")]
386379
pub(crate) struct UnknownVersionLiteral {

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ fn process_builtin_attrs(
150150
&& let Some(fn_sig) = try_fn_sig(tcx, did, *attr_span)
151151
&& fn_sig.skip_binder().abi() != ExternAbi::Rust
152152
{
153-
tcx.dcx().emit_err(errors::RequiresRustAbi { span: *attr_span });
153+
// This error is already reported in `rustc_ast_passes/src/ast_validation.rs`.
154+
tcx.dcx().delayed_bug("`#[track_caller]` requires the Rust ABI");
154155
}
155156
if is_closure
156157
&& !tcx.features().closure_track_caller()

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ pub(crate) struct NoSavedObjectFile<'a> {
112112
pub cgu_name: &'a str,
113113
}
114114

115-
#[derive(Diagnostic)]
116-
#[diag("`#[track_caller]` requires Rust ABI", code = E0737)]
117-
pub(crate) struct RequiresRustAbi {
118-
#[primary_span]
119-
pub span: Span,
120-
}
121-
122115
#[derive(Diagnostic)]
123116
#[diag("unable to copy {$source_file} to {$output_path}: {$error}")]
124117
pub(crate) struct CopyPathBuf {

compiler/rustc_errors/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ impl Suggestions {
138138
Suggestions::Disabled => Vec::new(),
139139
}
140140
}
141+
142+
pub fn len(&self) -> usize {
143+
match self {
144+
Suggestions::Enabled(suggestions) => suggestions.len(),
145+
Suggestions::Sealed(suggestions) => suggestions.len(),
146+
Suggestions::Disabled => 0,
147+
}
148+
}
141149
}
142150

143151
impl Default for Suggestions {

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,15 @@ impl Default for MacroUseArgs {
277277
}
278278

279279
#[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)]
280-
pub struct StrippedCfgItem<ModId = DefId> {
281-
pub parent_module: ModId,
280+
pub struct StrippedCfgItem<ScopeId = DefId> {
281+
pub parent_scope: ScopeId,
282282
pub ident: Ident,
283283
pub cfg: (CfgEntry, Span),
284284
}
285285

286-
impl<ModId> StrippedCfgItem<ModId> {
287-
pub fn map_mod_id<New>(self, f: impl FnOnce(ModId) -> New) -> StrippedCfgItem<New> {
288-
StrippedCfgItem { parent_module: f(self.parent_module), ident: self.ident, cfg: self.cfg }
286+
impl<ScopeId> StrippedCfgItem<ScopeId> {
287+
pub fn map_scope_id<New>(self, f: impl FnOnce(ScopeId) -> New) -> StrippedCfgItem<New> {
288+
StrippedCfgItem { parent_scope: f(self.parent_scope), ident: self.ident, cfg: self.cfg }
289289
}
290290
}
291291

compiler/rustc_hir/src/stability.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pub enum StabilityLevel {
112112
reason: UnstableReason,
113113
/// Relevant `rust-lang/rust` issue.
114114
issue: Option<NonZero<u32>>,
115-
is_soft: bool,
116115
/// If part of a feature is stabilized and a new feature is added for the remaining parts,
117116
/// then the `implied_by` attribute is used to indicate which now-stable feature previously
118117
/// contained an item.

0 commit comments

Comments
 (0)