Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f87d382

Browse files
committed
Auto merge of rust-lang#129660 - compiler-errors:crater-rollup, r=<try>
[CRATER] Crater Rollup This is a " crater rollup" of: * rust-lang#126452 * rust-lang#128784 * rust-lang#129392 * rust-lang#129422 * rust-lang#129543 * rust-lang#129604 **What is a crater rollup?** It's simply a crater job that is run on all of the containing PRs *together*, and then we can set the crates list for each of these jobs to just the failures after it's done. It should cut out on the bulk of "normal" crates that do nothing and simply just take time to build. r? `@ghost`
2 parents 1f12b9b + 3dc10b8 commit f87d382

File tree

67 files changed

+1375
-205
lines changed

Some content is hidden

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

67 files changed

+1375
-205
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ fn visit_lazy_tts<T: MutVisitor>(vis: &mut T, lazy_tts: &mut Option<LazyAttrToke
752752
pub fn visit_token<T: MutVisitor>(vis: &mut T, t: &mut Token) {
753753
let Token { kind, span } = t;
754754
match kind {
755-
token::Ident(name, _ /*raw*/) | token::Lifetime(name) => {
755+
token::Ident(name, _ /* raw */) | token::Lifetime(name, _ /* raw */) => {
756756
let mut ident = Ident::new(*name, *span);
757757
vis.visit_ident(&mut ident);
758758
*name = ident.name;
@@ -762,7 +762,7 @@ pub fn visit_token<T: MutVisitor>(vis: &mut T, t: &mut Token) {
762762
token::NtIdent(ident, _is_raw) => {
763763
vis.visit_ident(ident);
764764
}
765-
token::NtLifetime(ident) => {
765+
token::NtLifetime(ident, _is_raw) => {
766766
vis.visit_ident(ident);
767767
}
768768
token::Interpolated(nt) => {

compiler/rustc_ast/src/token.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ pub enum TokenKind {
331331
/// Do not forget about `NtLifetime` when you want to match on lifetime identifiers.
332332
/// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to
333333
/// treat regular and interpolated lifetime identifiers in the same way.
334-
Lifetime(Symbol),
334+
Lifetime(Symbol, IdentIsRaw),
335335
/// This identifier (and its span) is the lifetime passed to the
336336
/// declarative macro. The span in the surrounding `Token` is the span of
337337
/// the `lifetime` metavariable in the macro's RHS.
338-
NtLifetime(Ident),
338+
NtLifetime(Ident, IdentIsRaw),
339339

340340
/// An embedded AST node, as produced by a macro. This only exists for
341341
/// historical reasons. We'd like to get rid of it, for multiple reasons.
@@ -458,7 +458,7 @@ impl Token {
458458
/// if they keep spans or perform edition checks.
459459
pub fn uninterpolated_span(&self) -> Span {
460460
match self.kind {
461-
NtIdent(ident, _) | NtLifetime(ident) => ident.span,
461+
NtIdent(ident, _) | NtLifetime(ident, _) => ident.span,
462462
Interpolated(ref nt) => nt.use_span(),
463463
_ => self.span,
464464
}
@@ -646,7 +646,9 @@ impl Token {
646646
pub fn uninterpolate(&self) -> Cow<'_, Token> {
647647
match self.kind {
648648
NtIdent(ident, is_raw) => Cow::Owned(Token::new(Ident(ident.name, is_raw), ident.span)),
649-
NtLifetime(ident) => Cow::Owned(Token::new(Lifetime(ident.name), ident.span)),
649+
NtLifetime(ident, is_raw) => {
650+
Cow::Owned(Token::new(Lifetime(ident.name, is_raw), ident.span))
651+
}
650652
_ => Cow::Borrowed(self),
651653
}
652654
}
@@ -664,11 +666,11 @@ impl Token {
664666

665667
/// Returns a lifetime identifier if this token is a lifetime.
666668
#[inline]
667-
pub fn lifetime(&self) -> Option<Ident> {
669+
pub fn lifetime(&self) -> Option<(Ident, IdentIsRaw)> {
668670
// We avoid using `Token::uninterpolate` here because it's slow.
669671
match self.kind {
670-
Lifetime(name) => Some(Ident::new(name, self.span)),
671-
NtLifetime(ident) => Some(ident),
672+
Lifetime(name, is_raw) => Some((Ident::new(name, self.span), is_raw)),
673+
NtLifetime(ident, is_raw) => Some((ident, is_raw)),
672674
_ => None,
673675
}
674676
}
@@ -850,7 +852,7 @@ impl Token {
850852
_ => return None,
851853
},
852854
SingleQuote => match joint.kind {
853-
Ident(name, IdentIsRaw::No) => Lifetime(Symbol::intern(&format!("'{name}"))),
855+
Ident(name, is_raw) => Lifetime(Symbol::intern(&format!("'{name}")), is_raw),
854856
_ => return None,
855857
},
856858

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,11 @@ impl TokenStream {
482482
token::NtIdent(ident, is_raw) => {
483483
TokenTree::Token(Token::new(token::Ident(ident.name, is_raw), ident.span), spacing)
484484
}
485-
token::NtLifetime(ident) => TokenTree::Delimited(
485+
token::NtLifetime(ident, is_raw) => TokenTree::Delimited(
486486
DelimSpan::from_single(token.span),
487487
DelimSpacing::new(Spacing::JointHidden, spacing),
488488
Delimiter::Invisible,
489-
TokenStream::token_alone(token::Lifetime(ident.name), ident.span),
489+
TokenStream::token_alone(token::Lifetime(ident.name, is_raw), ident.span),
490490
),
491491
token::Interpolated(ref nt) => TokenTree::Delimited(
492492
DelimSpan::from_single(token.span),

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use std::borrow::Cow;
1111
use ast::TraitBoundModifiers;
1212
use rustc_ast::attr::AttrIdGenerator;
1313
use rustc_ast::ptr::P;
14-
use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, Token, TokenKind};
14+
use rustc_ast::token::{
15+
self, BinOpToken, CommentKind, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind,
16+
};
1517
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
1618
use rustc_ast::util::classify;
1719
use rustc_ast::util::comments::{Comment, CommentStyle};
@@ -947,8 +949,13 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
947949
token::NtIdent(ident, is_raw) => {
948950
IdentPrinter::for_ast_ident(ident, is_raw.into()).to_string().into()
949951
}
950-
token::Lifetime(name) => name.to_string().into(),
951-
token::NtLifetime(ident) => ident.name.to_string().into(),
952+
953+
token::Lifetime(name, IdentIsRaw::No)
954+
| token::NtLifetime(Ident { name, .. }, IdentIsRaw::No) => name.to_string().into(),
955+
token::Lifetime(name, IdentIsRaw::Yes)
956+
| token::NtLifetime(Ident { name, .. }, IdentIsRaw::Yes) => {
957+
format!("'r#{}", &name.as_str()[1..]).into()
958+
}
952959

953960
/* Other */
954961
token::DocComment(comment_kind, attr_style, data) => {

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,10 @@ pub(crate) enum NamedMatch {
398398
fn token_name_eq(t1: &Token, t2: &Token) -> bool {
399399
if let (Some((ident1, is_raw1)), Some((ident2, is_raw2))) = (t1.ident(), t2.ident()) {
400400
ident1.name == ident2.name && is_raw1 == is_raw2
401-
} else if let (Some(ident1), Some(ident2)) = (t1.lifetime(), t2.lifetime()) {
402-
ident1.name == ident2.name
401+
} else if let (Some((ident1, is_raw1)), Some((ident2, is_raw2))) =
402+
(t1.lifetime(), t2.lifetime())
403+
{
404+
ident1.name == ident2.name && is_raw1 == is_raw2
403405
} else {
404406
t1.kind == t2.kind
405407
}

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ pub(super) fn transcribe<'a>(
283283
let kind = token::NtIdent(*ident, *is_raw);
284284
TokenTree::token_alone(kind, sp)
285285
}
286-
MatchedSingle(ParseNtResult::Lifetime(ident)) => {
286+
MatchedSingle(ParseNtResult::Lifetime(ident, is_raw)) => {
287287
marker.visit_span(&mut sp);
288-
let kind = token::NtLifetime(*ident);
288+
let kind = token::NtLifetime(*ident, *is_raw);
289289
TokenTree::token_alone(kind, sp)
290290
}
291291
MatchedSingle(ParseNtResult::Nt(nt)) => {

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,16 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
229229
span: ident.span,
230230
})),
231231

232-
Lifetime(name) => {
232+
Lifetime(name, is_raw) => {
233233
let ident = symbol::Ident::new(name, span).without_first_quote();
234234
trees.extend([
235235
TokenTree::Punct(Punct { ch: b'\'', joint: true, span }),
236-
TokenTree::Ident(Ident { sym: ident.name, is_raw: false, span }),
236+
TokenTree::Ident(Ident { sym: ident.name, is_raw: is_raw.into(), span }),
237237
]);
238238
}
239-
NtLifetime(ident) => {
240-
let stream = TokenStream::token_alone(token::Lifetime(ident.name), ident.span);
239+
NtLifetime(ident, is_raw) => {
240+
let stream =
241+
TokenStream::token_alone(token::Lifetime(ident.name, is_raw), ident.span);
241242
trees.push(TokenTree::Group(Group {
242243
delimiter: pm::Delimiter::None,
243244
stream: Some(stream),

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
5151
});
5252
}
5353
}
54-
55-
// This ABI is only allowed on function pointers
56-
if abi == Abi::CCmseNonSecureCall {
57-
struct_span_code_err!(
58-
tcx.dcx(),
59-
span,
60-
E0781,
61-
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"
62-
)
63-
.emit();
64-
}
6554
}
6655

6756
fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId) {

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,17 +1481,21 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
14811481

14821482
// Figure out if this is a type/trait segment,
14831483
// which requires object lifetime defaults.
1484-
let type_def_id = match res {
1485-
Res::Def(DefKind::AssocTy, def_id) if depth == 1 => Some(self.tcx.parent(def_id)),
1486-
Res::Def(DefKind::Variant, def_id) if depth == 0 => Some(self.tcx.parent(def_id)),
1487-
Res::Def(
1488-
DefKind::Struct
1489-
| DefKind::Union
1490-
| DefKind::Enum
1491-
| DefKind::TyAlias
1492-
| DefKind::Trait,
1493-
def_id,
1494-
) if depth == 0 => Some(def_id),
1484+
let type_def_id = match (res, depth) {
1485+
(Res::Def(DefKind::AssocTy, def_id), 1) => Some(self.tcx.parent(def_id)),
1486+
(Res::Def(DefKind::Variant, def_id), 0) => Some(self.tcx.parent(def_id)),
1487+
(
1488+
Res::Def(
1489+
DefKind::Struct
1490+
| DefKind::Union
1491+
| DefKind::Enum
1492+
| DefKind::TyAlias
1493+
| DefKind::Trait
1494+
| DefKind::AssocTy,
1495+
def_id,
1496+
),
1497+
0,
1498+
) => Some(def_id),
14951499
_ => None,
14961500
};
14971501

@@ -1535,9 +1539,6 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
15351539
let map = &self.map;
15361540
let generics = self.tcx.generics_of(def_id);
15371541

1538-
// `type_def_id` points to an item, so there is nothing to inherit generics from.
1539-
debug_assert_eq!(generics.parent_count, 0);
1540-
15411542
let set_to_region = |set: ObjectLifetimeDefault| match set {
15421543
ObjectLifetimeDefault::Empty => {
15431544
if in_body {
@@ -1548,8 +1549,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
15481549
}
15491550
ObjectLifetimeDefault::Static => Some(ResolvedArg::StaticLifetime),
15501551
ObjectLifetimeDefault::Param(param_def_id) => {
1551-
// This index can be used with `generic_args` since `parent_count == 0`.
15521552
let index = generics.param_def_id_to_index[&param_def_id] as usize;
1553+
let index = index - generics.parent_count;
15531554
generic_args.args.get(index).and_then(|arg| match arg {
15541555
GenericArg::Lifetime(lt) => map.defs.get(&lt.hir_id).copied(),
15551556
_ => None,

compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use rustc_errors::DiagCtxtHandle;
2-
use rustc_hir as hir;
3-
use rustc_hir::HirId;
1+
use rustc_errors::{struct_span_code_err, DiagCtxtHandle, E0781};
2+
use rustc_hir::{self as hir, HirId};
43
use rustc_middle::ty::layout::LayoutError;
54
use rustc_middle::ty::{self, ParamEnv, TyCtxt};
65
use rustc_span::Span;
@@ -26,7 +25,19 @@ pub(crate) fn validate_cmse_abi<'tcx>(
2625
..
2726
}) = hir_node
2827
else {
29-
// might happen when this ABI is used incorrectly. That will be handled elsewhere
28+
let span = match tcx.parent_hir_node(hir_id) {
29+
hir::Node::Item(hir::Item {
30+
kind: hir::ItemKind::ForeignMod { .. }, span, ..
31+
}) => *span,
32+
_ => tcx.hir().span(hir_id),
33+
};
34+
struct_span_code_err!(
35+
tcx.dcx(),
36+
span,
37+
E0781,
38+
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"
39+
)
40+
.emit();
3041
return;
3142
};
3243

0 commit comments

Comments
 (0)