Skip to content

Commit e484632

Browse files
authored
Merge branch 'rust-lang:master' into master
2 parents 0f30e6f + 6c6b302 commit e484632

File tree

386 files changed

+4495
-2153
lines changed

Some content is hidden

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

386 files changed

+4495
-2153
lines changed

Cargo.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ dependencies = [
210210

211211
[[package]]
212212
name = "ar_archive_writer"
213-
version = "0.1.5"
213+
version = "0.2.0"
214214
source = "registry+https://github.com/rust-lang/crates.io-index"
215-
checksum = "9792d37ca5173d7e7f4fe453739a0671d0557915a030a383d6b866476bbc3e71"
215+
checksum = "f0c269894b6fe5e9d7ada0cf69b5bf847ff35bc25fc271f08e1d080fce80339a"
216216
dependencies = [
217217
"object 0.32.2",
218218
]
@@ -3342,6 +3342,7 @@ name = "run_make_support"
33423342
version = "0.0.0"
33433343
dependencies = [
33443344
"object 0.34.0",
3345+
"regex",
33453346
"wasmparser",
33463347
]
33473348

@@ -3364,9 +3365,9 @@ dependencies = [
33643365

33653366
[[package]]
33663367
name = "rustc-build-sysroot"
3367-
version = "0.4.5"
3368+
version = "0.4.6"
33683369
source = "registry+https://github.com/rust-lang/crates.io-index"
3369-
checksum = "a26170e1d79ea32f7ccec3188dd13cfc1f18c82764a9cbc1071667c0f865a4ea"
3370+
checksum = "a9bf37423495cd3a6a9ef8c75fc4566de0d26de0ab75f36f67a426e58df5768c"
33703371
dependencies = [
33713372
"anyhow",
33723373
"rustc_version",

compiler/rustc_ast/src/ast.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use rustc_macros::HashStable_Generic;
3636
use rustc_span::source_map::{respan, Spanned};
3737
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3838
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
39+
use std::cmp;
3940
use std::fmt;
4041
use std::mem;
4142
use thin_vec::{thin_vec, ThinVec};
@@ -63,7 +64,7 @@ impl fmt::Debug for Label {
6364

6465
/// A "Lifetime" is an annotation of the scope in which variable
6566
/// can be used, e.g. `'a` in `&'a i32`.
66-
#[derive(Clone, Encodable, Decodable, Copy, PartialEq, Eq)]
67+
#[derive(Clone, Encodable, Decodable, Copy, PartialEq, Eq, Hash)]
6768
pub struct Lifetime {
6869
pub id: NodeId,
6970
pub ident: Ident,
@@ -731,6 +732,13 @@ impl BindingAnnotation {
731732
Self::MUT_REF_MUT => "mut ref mut ",
732733
}
733734
}
735+
736+
pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self {
737+
if let ByRef::Yes(old_mutbl) = &mut self.0 {
738+
*old_mutbl = cmp::min(*old_mutbl, mutbl);
739+
}
740+
self
741+
}
734742
}
735743

736744
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -2132,7 +2140,7 @@ pub enum TyKind {
21322140
/// The `NodeId` exists to prevent lowering from having to
21332141
/// generate `NodeId`s on the fly, which would complicate
21342142
/// the generation of opaque `type Foo = impl Trait` items significantly.
2135-
ImplTrait(NodeId, GenericBounds),
2143+
ImplTrait(NodeId, GenericBounds, Option<P<(ThinVec<PreciseCapturingArg>, Span)>>),
21362144
/// No-op; kept solely so that we can pretty-print faithfully.
21372145
Paren(P<Ty>),
21382146
/// Unused for now.
@@ -2188,6 +2196,14 @@ pub enum TraitObjectSyntax {
21882196
None,
21892197
}
21902198

2199+
#[derive(Clone, Encodable, Decodable, Debug)]
2200+
pub enum PreciseCapturingArg {
2201+
/// Lifetime parameter
2202+
Lifetime(Lifetime),
2203+
/// Type or const parameter
2204+
Arg(Path, NodeId),
2205+
}
2206+
21912207
/// Inline assembly operand explicit register or register class.
21922208
///
21932209
/// E.g., `"eax"` as in `asm!("mov eax, 2", out("eax") result)`.

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ pub trait MutVisitor: Sized {
259259
noop_visit_param_bound(tpb, self);
260260
}
261261

262+
fn visit_precise_capturing_arg(&mut self, arg: &mut PreciseCapturingArg) {
263+
noop_visit_precise_capturing_arg(arg, self);
264+
}
265+
262266
fn visit_mt(&mut self, mt: &mut MutTy) {
263267
noop_visit_mt(mt, self);
264268
}
@@ -518,9 +522,14 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
518522
TyKind::TraitObject(bounds, _syntax) => {
519523
visit_vec(bounds, |bound| vis.visit_param_bound(bound))
520524
}
521-
TyKind::ImplTrait(id, bounds) => {
525+
TyKind::ImplTrait(id, bounds, precise_capturing) => {
522526
vis.visit_id(id);
523527
visit_vec(bounds, |bound| vis.visit_param_bound(bound));
528+
if let Some((precise_capturing, _span)) = precise_capturing.as_deref_mut() {
529+
for arg in precise_capturing {
530+
vis.visit_precise_capturing_arg(arg);
531+
}
532+
}
524533
}
525534
TyKind::MacCall(mac) => vis.visit_mac_call(mac),
526535
TyKind::AnonStruct(id, fields) | TyKind::AnonUnion(id, fields) => {
@@ -914,6 +923,18 @@ pub fn noop_visit_param_bound<T: MutVisitor>(pb: &mut GenericBound, vis: &mut T)
914923
}
915924
}
916925

926+
pub fn noop_visit_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg, vis: &mut T) {
927+
match arg {
928+
PreciseCapturingArg::Lifetime(lt) => {
929+
vis.visit_lifetime(lt);
930+
}
931+
PreciseCapturingArg::Arg(path, id) => {
932+
vis.visit_path(path);
933+
vis.visit_id(id);
934+
}
935+
}
936+
}
937+
917938
pub fn noop_flat_map_generic_param<T: MutVisitor>(
918939
mut param: GenericParam,
919940
vis: &mut T,

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub enum Delimiter {
5151
Brace,
5252
/// `[ ... ]`
5353
Bracket,
54-
/// `Ø ... Ø`
54+
/// ` ... `
5555
/// An invisible delimiter, that may, for example, appear around tokens coming from a
5656
/// "macro variable" `$var`. It is important to preserve operator priorities in cases like
5757
/// `$var * 3` where `$var` is `1 + 2`.

compiler/rustc_ast/src/visit.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ pub trait Visitor<'ast>: Sized {
184184
fn visit_param_bound(&mut self, bounds: &'ast GenericBound, _ctxt: BoundKind) -> Self::Result {
185185
walk_param_bound(self, bounds)
186186
}
187+
fn visit_precise_capturing_arg(&mut self, arg: &'ast PreciseCapturingArg) {
188+
walk_precise_capturing_arg(self, arg);
189+
}
187190
fn visit_poly_trait_ref(&mut self, t: &'ast PolyTraitRef) -> Self::Result {
188191
walk_poly_trait_ref(self, t)
189192
}
@@ -457,8 +460,13 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) -> V::Result {
457460
TyKind::TraitObject(bounds, ..) => {
458461
walk_list!(visitor, visit_param_bound, bounds, BoundKind::TraitObject);
459462
}
460-
TyKind::ImplTrait(_, bounds) => {
463+
TyKind::ImplTrait(_, bounds, precise_capturing) => {
461464
walk_list!(visitor, visit_param_bound, bounds, BoundKind::Impl);
465+
if let Some((precise_capturing, _span)) = precise_capturing.as_deref() {
466+
for arg in precise_capturing {
467+
try_visit!(visitor.visit_precise_capturing_arg(arg));
468+
}
469+
}
462470
}
463471
TyKind::Typeof(expression) => try_visit!(visitor.visit_anon_const(expression)),
464472
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Dummy | TyKind::Err(_) => {}
@@ -637,6 +645,20 @@ pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericB
637645
}
638646
}
639647

648+
pub fn walk_precise_capturing_arg<'a, V: Visitor<'a>>(
649+
visitor: &mut V,
650+
arg: &'a PreciseCapturingArg,
651+
) {
652+
match arg {
653+
PreciseCapturingArg::Lifetime(lt) => {
654+
visitor.visit_lifetime(lt, LifetimeCtxt::GenericArg);
655+
}
656+
PreciseCapturingArg::Arg(path, id) => {
657+
visitor.visit_path(path, *id);
658+
}
659+
}
660+
}
661+
640662
pub fn walk_generic_param<'a, V: Visitor<'a>>(
641663
visitor: &mut V,
642664
param: &'a GenericParam,

compiler/rustc_ast_lowering/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ ast_lowering_never_pattern_with_guard =
127127
a guard on a never pattern will never be run
128128
.suggestion = remove this guard
129129
130+
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed on argument-position `impl Trait`
131+
130132
ast_lowering_previously_used_here = previously used here
131133
132134
ast_lowering_register1 = register `{$reg1_name}`

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,10 @@ pub(crate) struct AsyncBoundOnlyForFnTraits {
414414
#[primary_span]
415415
pub span: Span,
416416
}
417+
418+
#[derive(Diagnostic)]
419+
#[diag(ast_lowering_no_precise_captures_on_apit)]
420+
pub(crate) struct NoPreciseCapturesOnApit {
421+
#[primary_span]
422+
pub span: Span,
423+
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_ast::*;
1414
use rustc_data_structures::stack::ensure_sufficient_stack;
1515
use rustc_hir as hir;
1616
use rustc_hir::def::{DefKind, Res};
17+
use rustc_hir::HirId;
1718
use rustc_middle::span_bug;
1819
use rustc_session::errors::report_lit_error;
1920
use rustc_span::source_map::{respan, Spanned};
@@ -701,8 +702,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
701702
pub(super) fn maybe_forward_track_caller(
702703
&mut self,
703704
span: Span,
704-
outer_hir_id: hir::HirId,
705-
inner_hir_id: hir::HirId,
705+
outer_hir_id: HirId,
706+
inner_hir_id: HirId,
706707
) {
707708
if self.tcx.features().async_fn_track_caller
708709
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
@@ -1048,7 +1049,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10481049
binder: &ClosureBinder,
10491050
capture_clause: CaptureBy,
10501051
closure_id: NodeId,
1051-
closure_hir_id: hir::HirId,
1052+
closure_hir_id: HirId,
10521053
coroutine_kind: CoroutineKind,
10531054
decl: &FnDecl,
10541055
body: &Expr,
@@ -2036,7 +2037,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
20362037
&mut self,
20372038
sp: Span,
20382039
ident: Ident,
2039-
binding: hir::HirId,
2040+
binding: HirId,
20402041
) -> &'hir hir::Expr<'hir> {
20412042
self.arena.alloc(self.expr_ident_mut(sp, ident, binding))
20422043
}
@@ -2045,7 +2046,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
20452046
&mut self,
20462047
span: Span,
20472048
ident: Ident,
2048-
binding: hir::HirId,
2049+
binding: HirId,
20492050
) -> hir::Expr<'hir> {
20502051
let hir_id = self.next_id();
20512052
let res = Res::Local(binding);

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,21 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
385385
fn visit_pattern_type_pattern(&mut self, p: &'hir hir::Pat<'hir>) {
386386
self.visit_pat(p)
387387
}
388+
389+
fn visit_precise_capturing_arg(
390+
&mut self,
391+
arg: &'hir PreciseCapturingArg<'hir>,
392+
) -> Self::Result {
393+
match arg {
394+
PreciseCapturingArg::Lifetime(_) => {
395+
// This is represented as a `Node::Lifetime`, intravisit will get to it below.
396+
}
397+
PreciseCapturingArg::Param(param) => self.insert(
398+
param.ident.span,
399+
param.hir_id,
400+
Node::PreciseCapturingNonLifetimeArg(param),
401+
),
402+
}
403+
intravisit::walk_precise_capturing_arg(self, arg);
404+
}
388405
}

0 commit comments

Comments
 (0)