Skip to content

Commit a0569fa

Browse files
committed
Auto merge of #122830 - matthiaskrgr:rollup-uk2by3f, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #122402 (Make `#[diagnostic::on_unimplemented]` format string parsing more robust) - #122644 (pattern analysis: add a custom test harness) - #122733 (Strip placeholders from hidden types before remapping generic parameter) - #122752 (Interpolated cleanups) - #122771 (add some comments to hir::ModuleItems) - #122793 (Implement macro-based deref!() syntax for deref patterns) - #122810 (Remove `target_override`) - #122827 (Remove unnecessary braces from `bug`/`span_bug`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7d01878 + 6ae51a5 commit a0569fa

File tree

83 files changed

+1480
-422
lines changed

Some content is hidden

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

83 files changed

+1480
-422
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4440,6 +4440,8 @@ dependencies = [
44404440
"rustc_target",
44414441
"smallvec",
44424442
"tracing",
4443+
"tracing-subscriber",
4444+
"tracing-tree",
44434445
]
44444446

44454447
[[package]]

compiler/rustc_ast/src/ast.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,9 @@ impl Pat {
621621
| PatKind::Or(s) => s.iter().for_each(|p| p.walk(it)),
622622

623623
// Trivial wrappers over inner patterns.
624-
PatKind::Box(s) | PatKind::Ref(s, _) | PatKind::Paren(s) => s.walk(it),
624+
PatKind::Box(s) | PatKind::Deref(s) | PatKind::Ref(s, _) | PatKind::Paren(s) => {
625+
s.walk(it)
626+
}
625627

626628
// These patterns do not contain subpatterns, skip.
627629
PatKind::Wild
@@ -792,6 +794,9 @@ pub enum PatKind {
792794
/// A `box` pattern.
793795
Box(P<Pat>),
794796

797+
/// A `deref` pattern (currently `deref!()` macro-based syntax).
798+
Deref(P<Pat>),
799+
795800
/// A reference pattern (e.g., `&mut (a, b)`).
796801
Ref(P<Pat>, Mutability),
797802

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
12951295
fields.flat_map_in_place(|field| vis.flat_map_pat_field(field));
12961296
}
12971297
PatKind::Box(inner) => vis.visit_pat(inner),
1298+
PatKind::Deref(inner) => vis.visit_pat(inner),
12981299
PatKind::Ref(inner, _mutbl) => vis.visit_pat(inner),
12991300
PatKind::Range(e1, e2, Spanned { span: _, node: _ }) => {
13001301
visit_opt(e1, |e| vis.visit_expr(e));

compiler/rustc_ast/src/token.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl Lit {
105105
}
106106
}
107107

108-
/// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation.
108+
/// Keep this in sync with `Token::can_begin_literal_maybe_minus` excluding unary negation.
109109
pub fn from_token(token: &Token) -> Option<Lit> {
110110
match token.uninterpolate().kind {
111111
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)),
@@ -664,7 +664,7 @@ impl Token {
664664
}
665665

666666
/// Returns `true` if the token is an interpolated path.
667-
fn is_path(&self) -> bool {
667+
fn is_whole_path(&self) -> bool {
668668
if let Interpolated(nt) = &self.kind
669669
&& let NtPath(..) = &nt.0
670670
{
@@ -710,7 +710,7 @@ impl Token {
710710
pub fn is_path_start(&self) -> bool {
711711
self == &ModSep
712712
|| self.is_qpath_start()
713-
|| self.is_path()
713+
|| self.is_whole_path()
714714
|| self.is_path_segment_keyword()
715715
|| self.is_ident() && !self.is_reserved_ident()
716716
}

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,7 @@ use smallvec::{smallvec, SmallVec};
2828
use std::borrow::Cow;
2929
use std::{cmp, fmt, iter};
3030

31-
/// When the main Rust parser encounters a syntax-extension invocation, it
32-
/// parses the arguments to the invocation as a token tree. This is a very
33-
/// loose structure, such that all sorts of different AST fragments can
34-
/// be passed to syntax extensions using a uniform type.
35-
///
36-
/// If the syntax extension is an MBE macro, it will attempt to match its
37-
/// LHS token tree against the provided token tree, and if it finds a
38-
/// match, will transcribe the RHS token tree, splicing in any captured
39-
/// `macro_parser::matched_nonterminals` into the `SubstNt`s it finds.
40-
///
41-
/// The RHS of an MBE macro is the only place `SubstNt`s are substituted.
42-
/// Nothing special happens to misnamed or misplaced `SubstNt`s.
31+
/// Part of a `TokenStream`.
4332
#[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
4433
pub enum TokenTree {
4534
/// A single token. Should never be `OpenDelim` or `CloseDelim`, because

compiler/rustc_ast/src/visit.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,10 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
576576
try_visit!(visitor.visit_path(path, pattern.id));
577577
walk_list!(visitor, visit_pat_field, fields);
578578
}
579-
PatKind::Box(subpattern) | PatKind::Ref(subpattern, _) | PatKind::Paren(subpattern) => {
579+
PatKind::Box(subpattern)
580+
| PatKind::Deref(subpattern)
581+
| PatKind::Ref(subpattern, _)
582+
| PatKind::Paren(subpattern) => {
580583
try_visit!(visitor.visit_pat(subpattern));
581584
}
582585
PatKind::Ident(_, ident, optional_subpattern) => {

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
9191
PatKind::Box(inner) => {
9292
break hir::PatKind::Box(self.lower_pat(inner));
9393
}
94+
PatKind::Deref(inner) => {
95+
break hir::PatKind::Deref(self.lower_pat(inner));
96+
}
9497
PatKind::Ref(inner, mutbl) => {
9598
break hir::PatKind::Ref(self.lower_pat(inner), *mutbl);
9699
}

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
413413
}
414414
}
415415
PatKind::Box(..) => {
416-
if !self.features.deref_patterns {
417-
// Allow box patterns under `deref_patterns`.
418-
gate!(&self, box_patterns, pattern.span, "box pattern syntax is experimental");
419-
}
416+
gate!(&self, box_patterns, pattern.span, "box pattern syntax is experimental");
420417
}
421418
PatKind::Range(_, Some(_), Spanned { node: RangeEnd::Excluded, .. }) => {
422419
gate!(
@@ -610,10 +607,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
610607
};
611608
}
612609

613-
if !visitor.features.deref_patterns {
614-
// Allow box patterns under `deref_patterns`.
615-
gate_all_legacy_dont_use!(box_patterns, "box pattern syntax is experimental");
616-
}
610+
gate_all_legacy_dont_use!(box_patterns, "box pattern syntax is experimental");
617611
gate_all_legacy_dont_use!(trait_alias, "trait aliases are experimental");
618612
// Despite being a new feature, `where T: Trait<Assoc(): Sized>`, which is RTN syntax now,
619613
// used to be gated under associated_type_bounds, which are right above, so RTN needs to

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,12 @@ impl<'a> State<'a> {
16261626
self.word("box ");
16271627
self.print_pat(inner);
16281628
}
1629+
PatKind::Deref(inner) => {
1630+
self.word("deref!");
1631+
self.popen();
1632+
self.print_pat(inner);
1633+
self.pclose();
1634+
}
16291635
PatKind::Ref(inner, mutbl) => {
16301636
self.word("&");
16311637
if mutbl.is_mut() {

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
192192
.find(|ur_vid| self.eval_equal(vid, **ur_vid))
193193
.and_then(|ur_vid| self.definitions[*ur_vid].external_name)
194194
.unwrap_or(infcx.tcx.lifetimes.re_erased),
195+
ty::RePlaceholder(_) => ty::Region::new_error_with_message(
196+
infcx.tcx,
197+
concrete_type.span,
198+
"hidden type contains placeholders, we don't support higher kinded opaques yet",
199+
),
195200
_ => region,
196201
});
197202
debug!(?universal_concrete_type);

0 commit comments

Comments
 (0)