Skip to content

Commit 3b05974

Browse files
authored
Merge branch 'rust-lang:main' into unconstrained-parameter-fix
2 parents c8905fa + 2636cb4 commit 3b05974

File tree

714 files changed

+6847
-4086
lines changed

Some content is hidden

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

714 files changed

+6847
-4086
lines changed

‎.github/workflows/post-merge.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name: Post merge analysis
66
on:
77
push:
88
branches:
9-
- master
9+
- main
1010

1111
jobs:
1212
analysis:

‎.mailmap‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ Christian Poveda <[email protected]> <[email protected].
139139
140140
Christian Vallentin <[email protected]>
141141
Christoffer Buchholz <[email protected]>
142-
Christopher Durham <[email protected]>
143142
144143
Clement Miao <[email protected]>
145144
Clément Renault <[email protected]>
@@ -148,6 +147,7 @@ Clinton Ryan <[email protected]>
148147
149148
150149
Crazycolorz5 <[email protected]>
150+
Crystal Durham <[email protected]>
151151
152152
Cyryl Płotnicki <[email protected]>
153153
Damien Schoof <[email protected]>

‎bootstrap.example.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
#build.npm = "npm"
321321

322322
# Python interpreter to use for various tasks throughout the build, notably
323-
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
323+
# rustdoc tests, and some dist bits and pieces.
324324
#
325325
# Defaults to the Python interpreter used to execute x.py.
326326
#build.python = "python"

‎compiler/rustc_ast/src/ast.rs‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,10 @@ impl Pat {
648648
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
649649
PatKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
650650
// `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
651-
PatKind::Ref(pat, mutbl) => {
652-
pat.to_ty().map(|ty| TyKind::Ref(None, MutTy { ty, mutbl: *mutbl }))?
653-
}
651+
PatKind::Ref(pat, pinned, mutbl) => pat.to_ty().map(|ty| match pinned {
652+
Pinnedness::Not => TyKind::Ref(None, MutTy { ty, mutbl: *mutbl }),
653+
Pinnedness::Pinned => TyKind::PinnedRef(None, MutTy { ty, mutbl: *mutbl }),
654+
})?,
654655
// A slice/array pattern `[P]` can be reparsed as `[T]`, an unsized array,
655656
// when `P` can be reparsed as a type `T`.
656657
PatKind::Slice(pats) if let [pat] = pats.as_slice() => {
@@ -696,7 +697,7 @@ impl Pat {
696697
// Trivial wrappers over inner patterns.
697698
PatKind::Box(s)
698699
| PatKind::Deref(s)
699-
| PatKind::Ref(s, _)
700+
| PatKind::Ref(s, _, _)
700701
| PatKind::Paren(s)
701702
| PatKind::Guard(s, _) => s.walk(it),
702703

@@ -717,7 +718,7 @@ impl Pat {
717718
/// Strip off all reference patterns (`&`, `&mut`) and return the inner pattern.
718719
pub fn peel_refs(&self) -> &Pat {
719720
let mut current = self;
720-
while let PatKind::Ref(inner, _) = &current.kind {
721+
while let PatKind::Ref(inner, _, _) = &current.kind {
721722
current = inner;
722723
}
723724
current
@@ -765,7 +766,9 @@ impl Pat {
765766
PatKind::Missing => unreachable!(),
766767
PatKind::Wild => Some("_".to_string()),
767768
PatKind::Ident(BindingMode::NONE, ident, None) => Some(format!("{ident}")),
768-
PatKind::Ref(pat, mutbl) => pat.descr().map(|d| format!("&{}{d}", mutbl.prefix_str())),
769+
PatKind::Ref(pat, pinned, mutbl) => {
770+
pat.descr().map(|d| format!("&{}{d}", pinned.prefix_str(*mutbl)))
771+
}
769772
_ => None,
770773
}
771774
}
@@ -913,7 +916,7 @@ pub enum PatKind {
913916
Deref(Box<Pat>),
914917

915918
/// A reference pattern (e.g., `&mut (a, b)`).
916-
Ref(Box<Pat>, Mutability),
919+
Ref(Box<Pat>, Pinnedness, Mutability),
917920

918921
/// A literal, const block or path.
919922
Expr(Box<Expr>),

‎compiler/rustc_ast_ir/src/lib.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,15 @@ impl Pinnedness {
317317
pub fn is_pinned(self) -> bool {
318318
matches!(self, Self::Pinned)
319319
}
320+
321+
/// Returns `""` (empty string), "mut", `"pin mut "` or `"pin const "` depending
322+
/// on the pinnedness and mutability.
323+
pub fn prefix_str(self, mutbl: Mutability) -> &'static str {
324+
match (self, mutbl) {
325+
(Pinnedness::Pinned, Mutability::Mut) => "pin mut ",
326+
(Pinnedness::Pinned, Mutability::Not) => "pin const ",
327+
(Pinnedness::Not, Mutability::Mut) => "mut ",
328+
(Pinnedness::Not, Mutability::Not) => "",
329+
}
330+
}
320331
}

‎compiler/rustc_ast_lowering/src/index.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
125125
}
126126

127127
impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
128-
/// Because we want to track parent items and so forth, enable
129-
/// deep walking so that we walk nested items in the context of
130-
/// their outer items.
128+
// Because we want to track parent items and so forth, enable
129+
// deep walking so that we walk nested items in the context of
130+
// their outer items.
131131

132132
fn visit_nested_item(&mut self, item: ItemId) {
133133
debug!("visit_nested_item: {:?}", item);

‎compiler/rustc_ast_lowering/src/pat.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
124124
PatKind::Deref(inner) => {
125125
break hir::PatKind::Deref(self.lower_pat(inner));
126126
}
127-
PatKind::Ref(inner, mutbl) => {
128-
break hir::PatKind::Ref(self.lower_pat(inner), *mutbl);
127+
PatKind::Ref(inner, pinned, mutbl) => {
128+
break hir::PatKind::Ref(self.lower_pat(inner), *pinned, *mutbl);
129129
}
130130
PatKind::Range(e1, e2, Spanned { node: end, .. }) => {
131131
break hir::PatKind::Range(

‎compiler/rustc_ast_passes/messages.ftl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ ast_passes_trait_fn_const =
290290
*[false] {""}
291291
}
292292
.make_impl_const_sugg = ... and declare the impl to be const instead
293-
.make_trait_const_sugg = ... and declare the trait to be a `#[const_trait]` instead
293+
.make_trait_const_sugg = ... and declare the trait to be const instead
294294
295295
ast_passes_trait_object_single_bound = only a single explicit lifetime bound is permitted
296296

‎compiler/rustc_ast_passes/src/ast_validation.rs‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum SelfSemantic {
4848
}
4949

5050
enum TraitOrTraitImpl {
51-
Trait { span: Span, constness: Const },
51+
Trait { vis: Span, constness: Const },
5252
TraitImpl { constness: Const, polarity: ImplPolarity, trait_ref_span: Span },
5353
}
5454

@@ -109,10 +109,10 @@ impl<'a> AstValidator<'a> {
109109
self.outer_trait_or_trait_impl = old;
110110
}
111111

112-
fn with_in_trait(&mut self, span: Span, constness: Const, f: impl FnOnce(&mut Self)) {
112+
fn with_in_trait(&mut self, vis: Span, constness: Const, f: impl FnOnce(&mut Self)) {
113113
let old = mem::replace(
114114
&mut self.outer_trait_or_trait_impl,
115-
Some(TraitOrTraitImpl::Trait { span, constness }),
115+
Some(TraitOrTraitImpl::Trait { vis, constness }),
116116
);
117117
f(self);
118118
self.outer_trait_or_trait_impl = old;
@@ -265,10 +265,12 @@ impl<'a> AstValidator<'a> {
265265
None
266266
};
267267

268+
let map = self.sess.source_map();
269+
268270
let make_trait_const_sugg = if const_trait_impl
269-
&& let TraitOrTraitImpl::Trait { span, constness: ast::Const::No } = parent
271+
&& let &TraitOrTraitImpl::Trait { vis, constness: ast::Const::No } = parent
270272
{
271-
Some(span.shrink_to_lo())
273+
Some(map.span_extend_while_whitespace(vis).shrink_to_hi())
272274
} else {
273275
None
274276
};
@@ -279,7 +281,7 @@ impl<'a> AstValidator<'a> {
279281
in_impl: matches!(parent, TraitOrTraitImpl::TraitImpl { .. }),
280282
const_context_label: parent_constness,
281283
remove_const_sugg: (
282-
self.sess.source_map().span_extend_while_whitespace(span),
284+
map.span_extend_while_whitespace(span),
283285
match parent_constness {
284286
Some(_) => rustc_errors::Applicability::MachineApplicable,
285287
None => rustc_errors::Applicability::MaybeIncorrect,
@@ -1165,13 +1167,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11651167
..
11661168
}) => {
11671169
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
1168-
// FIXME(const_trait_impl) remove this
1169-
let alt_const_trait_span =
1170-
attr::find_by_name(&item.attrs, sym::const_trait).map(|attr| attr.span);
1171-
let constness = match (*constness, alt_const_trait_span) {
1172-
(Const::Yes(span), _) | (Const::No, Some(span)) => Const::Yes(span),
1173-
(Const::No, None) => Const::No,
1174-
};
11751170
if *is_auto == IsAuto::Yes {
11761171
// Auto traits cannot have generics, super traits nor contain items.
11771172
self.deny_generic_params(generics, ident.span);
@@ -1188,7 +1183,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11881183
this.visit_generics(generics);
11891184
walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits)
11901185
});
1191-
self.with_in_trait(item.span, constness, |this| {
1186+
self.with_in_trait(item.vis.span, *constness, |this| {
11921187
walk_list!(this, visit_assoc_item, items, AssocCtxt::Trait);
11931188
});
11941189
}

‎compiler/rustc_ast_passes/src/errors.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub(crate) struct TraitFnConst {
5656
pub make_impl_const_sugg: Option<Span>,
5757
#[suggestion(
5858
ast_passes_make_trait_const_sugg,
59-
code = "#[const_trait]\n",
59+
code = "const ",
6060
applicability = "maybe-incorrect"
6161
)]
6262
pub make_trait_const_sugg: Option<Span>,

0 commit comments

Comments
 (0)