Skip to content

Commit e88afc0

Browse files
author
The rustc-josh-sync Cronjob Bot
committed
Merge ref 'b1b464d6f61e' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: b1b464d Filtered ref: f94cd4e7de0695f11c7f0bf0d33bb39ce736c581 Upstream diff: 4068baf...b1b464d This merge was created using https://github.com/rust-lang/josh-sync.
2 parents b12f711 + b1b464d commit e88afc0

File tree

556 files changed

+9657
-7132
lines changed

Some content is hidden

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

556 files changed

+9657
-7132
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ Marcell Pardavi <[email protected]>
427427
Marco Ieni <[email protected]>
428428
Marcus Klaas de Vries <[email protected]>
429429
Margaret Meyerhofer <[email protected]> <mmeyerho@andrew>
430+
430431
Mark Mansi <[email protected]>
431432
432433
Mark Rousskov <[email protected]>

Cargo.lock

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
7575
checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4"
7676
dependencies = [
7777
"anstyle",
78-
"unicode-width 0.2.1",
78+
"unicode-width 0.2.2",
79+
]
80+
81+
[[package]]
82+
name = "annotate-snippets"
83+
version = "0.12.7"
84+
source = "registry+https://github.com/rust-lang/crates.io-index"
85+
checksum = "47224528f74de27d1d06aad6a5dda4f865b6ebe2e56c538943d746a7270cb67e"
86+
dependencies = [
87+
"anstyle",
88+
"unicode-width 0.2.2",
7989
]
8090

8191
[[package]]
@@ -95,9 +105,9 @@ dependencies = [
95105

96106
[[package]]
97107
name = "anstyle"
98-
version = "1.0.11"
108+
version = "1.0.13"
99109
source = "registry+https://github.com/rust-lang/crates.io-index"
100-
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
110+
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
101111

102112
[[package]]
103113
name = "anstyle-lossy"
@@ -136,7 +146,7 @@ dependencies = [
136146
"anstyle-lossy",
137147
"anstyle-parse",
138148
"html-escape",
139-
"unicode-width 0.2.1",
149+
"unicode-width 0.2.2",
140150
]
141151

142152
[[package]]
@@ -677,7 +687,7 @@ checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
677687
dependencies = [
678688
"serde",
679689
"termcolor",
680-
"unicode-width 0.2.1",
690+
"unicode-width 0.2.2",
681691
]
682692

683693
[[package]]
@@ -808,7 +818,7 @@ dependencies = [
808818
"encode_unicode",
809819
"libc",
810820
"once_cell",
811-
"unicode-width 0.2.1",
821+
"unicode-width 0.2.2",
812822
"windows-sys 0.59.0",
813823
]
814824

@@ -1485,7 +1495,7 @@ version = "0.2.24"
14851495
source = "registry+https://github.com/rust-lang/crates.io-index"
14861496
checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df"
14871497
dependencies = [
1488-
"unicode-width 0.2.1",
1498+
"unicode-width 0.2.2",
14891499
]
14901500

14911501
[[package]]
@@ -1887,7 +1897,7 @@ dependencies = [
18871897
"console",
18881898
"number_prefix",
18891899
"portable-atomic",
1890-
"unicode-width 0.2.1",
1900+
"unicode-width 0.2.2",
18911901
"web-time",
18921902
]
18931903

@@ -3756,7 +3766,9 @@ dependencies = [
37563766
name = "rustc_errors"
37573767
version = "0.0.0"
37583768
dependencies = [
3759-
"annotate-snippets 0.11.5",
3769+
"annotate-snippets 0.12.7",
3770+
"anstream",
3771+
"anstyle",
37603772
"derive_setters",
37613773
"rustc_abi",
37623774
"rustc_ast",
@@ -3773,7 +3785,6 @@ dependencies = [
37733785
"rustc_span",
37743786
"serde",
37753787
"serde_json",
3776-
"termcolor",
37773788
"termize",
37783789
"tracing",
37793790
"windows 0.61.3",
@@ -4327,11 +4338,10 @@ dependencies = [
43274338
"rustc_macros",
43284339
"rustc_session",
43294340
"rustc_span",
4330-
"termcolor",
43314341
"thin-vec",
43324342
"tracing",
43334343
"unicode-normalization",
4334-
"unicode-width 0.2.1",
4344+
"unicode-width 0.2.2",
43354345
]
43364346

43374347
[[package]]
@@ -4590,7 +4600,7 @@ dependencies = [
45904600
"sha1",
45914601
"sha2",
45924602
"tracing",
4593-
"unicode-width 0.2.1",
4603+
"unicode-width 0.2.2",
45944604
]
45954605

45964606
[[package]]
@@ -5936,9 +5946,9 @@ checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
59365946

59375947
[[package]]
59385948
name = "unicode-width"
5939-
version = "0.2.1"
5949+
version = "0.2.2"
59405950
source = "registry+https://github.com/rust-lang/crates.io-index"
5941-
checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c"
5951+
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
59425952

59435953
[[package]]
59445954
name = "unicode-xid"
@@ -6223,7 +6233,7 @@ dependencies = [
62236233
"bumpalo",
62246234
"leb128fmt",
62256235
"memchr",
6226-
"unicode-width 0.2.1",
6236+
"unicode-width 0.2.2",
62276237
"wasm-encoder 0.240.0",
62286238
]
62296239

compiler/rustc_ast/src/ast.rs

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,6 +2579,9 @@ pub enum TyPatKind {
25792579
/// A range pattern (e.g., `1...2`, `1..2`, `1..`, `..2`, `1..=2`, `..=2`).
25802580
Range(Option<Box<AnonConst>>, Option<Box<AnonConst>>, Spanned<RangeEnd>),
25812581

2582+
/// A `!null` pattern for raw pointers.
2583+
NotNull,
2584+
25822585
Or(ThinVec<TyPat>),
25832586

25842587
/// Placeholder for a pattern that wasn't syntactically well formed in some way.
@@ -3633,49 +3636,26 @@ pub struct Trait {
36333636
pub items: ThinVec<Box<AssocItem>>,
36343637
}
36353638

3636-
/// The location of a where clause on a `TyAlias` (`Span`) and whether there was
3637-
/// a `where` keyword (`bool`). This is split out from `WhereClause`, since there
3638-
/// are two locations for where clause on type aliases, but their predicates
3639-
/// are concatenated together.
3640-
///
3641-
/// Take this example:
3642-
/// ```ignore (only-for-syntax-highlight)
3643-
/// trait Foo {
3644-
/// type Assoc<'a, 'b> where Self: 'a, Self: 'b;
3645-
/// }
3646-
/// impl Foo for () {
3647-
/// type Assoc<'a, 'b> where Self: 'a = () where Self: 'b;
3648-
/// // ^^^^^^^^^^^^^^ first where clause
3649-
/// // ^^^^^^^^^^^^^^ second where clause
3650-
/// }
3651-
/// ```
3652-
///
3653-
/// If there is no where clause, then this is `false` with `DUMMY_SP`.
3654-
#[derive(Copy, Clone, Encodable, Decodable, Debug, Default, Walkable)]
3655-
pub struct TyAliasWhereClause {
3656-
pub has_where_token: bool,
3657-
pub span: Span,
3658-
}
3659-
3660-
/// The span information for the two where clauses on a `TyAlias`.
3661-
#[derive(Copy, Clone, Encodable, Decodable, Debug, Default, Walkable)]
3662-
pub struct TyAliasWhereClauses {
3663-
/// Before the equals sign.
3664-
pub before: TyAliasWhereClause,
3665-
/// After the equals sign.
3666-
pub after: TyAliasWhereClause,
3667-
/// The index in `TyAlias.generics.where_clause.predicates` that would split
3668-
/// into predicates from the where clause before the equals sign and the ones
3669-
/// from the where clause after the equals sign.
3670-
pub split: usize,
3671-
}
3672-
36733639
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
36743640
pub struct TyAlias {
36753641
pub defaultness: Defaultness,
36763642
pub ident: Ident,
36773643
pub generics: Generics,
3678-
pub where_clauses: TyAliasWhereClauses,
3644+
/// There are two locations for where clause on type aliases. This represents the second
3645+
/// where clause, before the semicolon. The first where clause is stored inside `generics`.
3646+
///
3647+
/// Take this example:
3648+
/// ```ignore (only-for-syntax-highlight)
3649+
/// trait Foo {
3650+
/// type Assoc<'a, 'b> where Self: 'a, Self: 'b;
3651+
/// }
3652+
/// impl Foo for () {
3653+
/// type Assoc<'a, 'b> where Self: 'a = () where Self: 'b;
3654+
/// // ^^^^^^^^^^^^^^ before where clause
3655+
/// // ^^^^^^^^^^^^^^ after where clause
3656+
/// }
3657+
/// ```
3658+
pub after_where_clause: WhereClause,
36793659
#[visitable(extra = BoundKind::Bound)]
36803660
pub bounds: GenericBounds,
36813661
pub ty: Option<Box<Ty>>,

compiler/rustc_ast/src/visit.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,6 @@ macro_rules! common_visitor_and_walkers {
471471
TraitBoundModifiers,
472472
TraitObjectSyntax,
473473
TyAlias,
474-
TyAliasWhereClause,
475-
TyAliasWhereClauses,
476474
TyKind,
477475
TyPatKind,
478476
UnOp,

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
77
use rustc_hir as hir;
88
use rustc_hir::attrs::AttributeKind;
99
use rustc_hir::def::{DefKind, Res};
10+
use rustc_hir::definitions::DefPathData;
1011
use rustc_hir::{HirId, Target, find_attr};
1112
use rustc_middle::span_bug;
1213
use rustc_middle::ty::TyCtxt;
@@ -461,7 +462,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
461462
for (idx, arg) in args.iter().cloned().enumerate() {
462463
if legacy_args_idx.contains(&idx) {
463464
let node_id = self.next_node_id();
464-
self.create_def(node_id, None, DefKind::AnonConst, f.span);
465+
self.create_def(
466+
node_id,
467+
None,
468+
DefKind::AnonConst,
469+
DefPathData::LateAnonConst,
470+
f.span,
471+
);
465472
let mut visitor = WillCreateDefIdsVisitor {};
466473
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
467474
Box::new(Expr {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,18 @@ pub(super) struct ItemLowerer<'a, 'hir> {
3636
/// clause if it exists.
3737
fn add_ty_alias_where_clause(
3838
generics: &mut ast::Generics,
39-
mut where_clauses: TyAliasWhereClauses,
39+
after_where_clause: &ast::WhereClause,
4040
prefer_first: bool,
4141
) {
42+
generics.where_clause.predicates.extend_from_slice(&after_where_clause.predicates);
43+
44+
let mut before = (generics.where_clause.has_where_token, generics.where_clause.span);
45+
let mut after = (after_where_clause.has_where_token, after_where_clause.span);
4246
if !prefer_first {
43-
(where_clauses.before, where_clauses.after) = (where_clauses.after, where_clauses.before);
47+
(before, after) = (after, before);
4448
}
45-
let where_clause =
46-
if where_clauses.before.has_where_token || !where_clauses.after.has_where_token {
47-
where_clauses.before
48-
} else {
49-
where_clauses.after
50-
};
51-
generics.where_clause.has_where_token = where_clause.has_where_token;
52-
generics.where_clause.span = where_clause.span;
49+
(generics.where_clause.has_where_token, generics.where_clause.span) =
50+
if before.0 || !after.0 { before } else { after };
5351
}
5452

5553
impl<'a, 'hir> ItemLowerer<'a, 'hir> {
@@ -271,7 +269,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
271269
self.lower_body(|this| (&[], this.expr(span, hir::ExprKind::InlineAsm(asm))));
272270
hir::ItemKind::GlobalAsm { asm, fake_body }
273271
}
274-
ItemKind::TyAlias(box TyAlias { ident, generics, where_clauses, ty, .. }) => {
272+
ItemKind::TyAlias(box TyAlias { ident, generics, after_where_clause, ty, .. }) => {
275273
// We lower
276274
//
277275
// type Foo = impl Trait
@@ -282,7 +280,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
282280
// opaque type Foo1: Trait
283281
let ident = self.lower_ident(*ident);
284282
let mut generics = generics.clone();
285-
add_ty_alias_where_clause(&mut generics, *where_clauses, true);
283+
add_ty_alias_where_clause(&mut generics, after_where_clause, true);
286284
let (generics, ty) = self.lower_generics(
287285
&generics,
288286
id,
@@ -901,10 +899,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
901899
)
902900
}
903901
AssocItemKind::Type(box TyAlias {
904-
ident, generics, where_clauses, bounds, ty, ..
902+
ident,
903+
generics,
904+
after_where_clause,
905+
bounds,
906+
ty,
907+
..
905908
}) => {
906909
let mut generics = generics.clone();
907-
add_ty_alias_where_clause(&mut generics, *where_clauses, false);
910+
add_ty_alias_where_clause(&mut generics, after_where_clause, false);
908911
let (generics, kind) = self.lower_generics(
909912
&generics,
910913
i.id,
@@ -1070,9 +1073,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
10701073

10711074
(*ident, (generics, hir::ImplItemKind::Fn(sig, body_id)))
10721075
}
1073-
AssocItemKind::Type(box TyAlias { ident, generics, where_clauses, ty, .. }) => {
1076+
AssocItemKind::Type(box TyAlias {
1077+
ident, generics, after_where_clause, ty, ..
1078+
}) => {
10741079
let mut generics = generics.clone();
1075-
add_ty_alias_where_clause(&mut generics, *where_clauses, false);
1080+
add_ty_alias_where_clause(&mut generics, after_where_clause, false);
10761081
(
10771082
*ident,
10781083
self.lower_generics(

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use rustc_data_structures::tagged_ptr::TaggedRef;
5151
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
5252
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5353
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
54+
use rustc_hir::definitions::{DefPathData, DisambiguatorState};
5455
use rustc_hir::lints::DelayedLint;
5556
use rustc_hir::{
5657
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
@@ -93,6 +94,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
9394
struct LoweringContext<'a, 'hir> {
9495
tcx: TyCtxt<'hir>,
9596
resolver: &'a mut ResolverAstLowering,
97+
disambiguator: DisambiguatorState,
9698

9799
/// Used to allocate HIR nodes.
98100
arena: &'hir hir::Arena<'hir>,
@@ -155,6 +157,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
155157
// Pseudo-globals.
156158
tcx,
157159
resolver,
160+
disambiguator: DisambiguatorState::new(),
158161
arena: tcx.hir_arena,
159162

160163
// HirId handling.
@@ -546,6 +549,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
546549
node_id: ast::NodeId,
547550
name: Option<Symbol>,
548551
def_kind: DefKind,
552+
def_path_data: DefPathData,
549553
span: Span,
550554
) -> LocalDefId {
551555
let parent = self.current_hir_id_owner.def_id;
@@ -561,7 +565,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
561565
let def_id = self
562566
.tcx
563567
.at(span)
564-
.create_def(parent, name, def_kind, None, &mut self.resolver.disambiguator)
568+
.create_def(parent, name, def_kind, Some(def_path_data), &mut self.disambiguator)
565569
.def_id();
566570

567571
debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
@@ -846,6 +850,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
846850
param,
847851
Some(kw::UnderscoreLifetime),
848852
DefKind::LifetimeParam,
853+
DefPathData::DesugaredAnonymousLifetime,
849854
ident.span,
850855
);
851856
debug!(?_def_id);
@@ -2290,7 +2295,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22902295
// We're lowering a const argument that was originally thought to be a type argument,
22912296
// so the def collector didn't create the def ahead of time. That's why we have to do
22922297
// it here.
2293-
let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
2298+
let def_id = self.create_def(
2299+
node_id,
2300+
None,
2301+
DefKind::AnonConst,
2302+
DefPathData::LateAnonConst,
2303+
span,
2304+
);
22942305
let hir_id = self.lower_node_id(node_id);
22952306

22962307
let path_expr = Expr {

0 commit comments

Comments
 (0)