about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-09-11 09:04:28 +0000
committerbors <bors@rust-lang.org>2025-09-11 09:04:28 +0000
commit76c5ed2847cdb26ef2822a3a165d710f6b772217 (patch)
treee7eaf5da90738ef6953b28d81471a12d3a9296fc /compiler/rustc_parse/src
parent5e33838ccad070f1536ed82336dd0133e2681233 (diff)
parent613a3b6a42b5c7413fe4a8ffd4f16ec39c32a814 (diff)
downloadrust-76c5ed2847cdb26ef2822a3a165d710f6b772217.tar.gz
rust-76c5ed2847cdb26ef2822a3a165d710f6b772217.zip
Auto merge of #146429 - Zalathar:rollup-eivhl6u, r=Zalathar
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#142315 (core::ptr: deduplicate docs for as_ref, addr, and as_uninit_ref)
 - rust-lang/rust#146335 (disable core dumps for panic-uninitialized-zeroed)
 - rust-lang/rust#146347 (report duplicate symbols added by the driver)
 - rust-lang/rust#146370 (Update the LoongArch target documentation)
 - rust-lang/rust#146379 (Fix `compare_against_sw_vers` test)
 - rust-lang/rust#146380 (Unify and deduplicate bits conv float tests)
 - rust-lang/rust#146415 (s390x: mark soft-float target feature as incompatible)
 - rust-lang/rust#146422 (Less greedily parse `[const]` bounds)
 - rust-lang/rust#146424 (Improve `core::ops` coverage)
 - rust-lang/rust#146425 (Improve `core::array` coverage)
 - rust-lang/rust#146428 (Revert `assert!` desugaring changes (rust-lang/rust#122661))

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/ty.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs
index 6168647183f..23aaafac934 100644
--- a/compiler/rustc_parse/src/parser/ty.rs
+++ b/compiler/rustc_parse/src/parser/ty.rs
@@ -92,10 +92,10 @@ fn can_continue_type_after_non_fn_ident(t: &Token) -> bool {
 }
 
 fn can_begin_dyn_bound_in_edition_2015(t: &Token) -> bool {
-    // `Not`, `Tilde` & `Const` are deliberately not part of this list to
+    // `!`, `const`, `[`, `async` are deliberately not part of this list to
     // contain the number of potential regressions esp. in MBE code.
-    // `Const` would regress `rfc-2632-const-trait-impl/mbe-dyn-const-2015.rs`.
-    // `Not` would regress `dyn!(...)` macro calls in Rust 2015.
+    // `const` and `[` would regress UI test `macro-dyn-const-2015.rs`.
+    // `!` would regress `dyn!(...)` macro calls in Rust 2015.
     t.is_path_start()
         || t.is_lifetime()
         || t == &TokenKind::Question
@@ -1015,12 +1015,18 @@ impl<'a> Parser<'a> {
             || self.check(exp!(Tilde))
             || self.check_keyword(exp!(For))
             || self.check(exp!(OpenParen))
-            || self.check(exp!(OpenBracket))
+            || self.can_begin_maybe_const_bound()
             || self.check_keyword(exp!(Const))
             || self.check_keyword(exp!(Async))
             || self.check_keyword(exp!(Use))
     }
 
+    fn can_begin_maybe_const_bound(&mut self) -> bool {
+        self.check(exp!(OpenBracket))
+            && self.look_ahead(1, |t| t.is_keyword(kw::Const))
+            && self.look_ahead(2, |t| *t == token::CloseBracket)
+    }
+
     /// Parse a bound.
     ///
     /// ```ebnf
@@ -1199,10 +1205,7 @@ impl<'a> Parser<'a> {
             let span = tilde.to(self.prev_token.span);
             self.psess.gated_spans.gate(sym::const_trait_impl, span);
             BoundConstness::Maybe(span)
-        } else if self.check(exp!(OpenBracket))
-            && self.look_ahead(1, |t| t.is_keyword(kw::Const))
-            && self.look_ahead(2, |t| *t == token::CloseBracket)
-        {
+        } else if self.can_begin_maybe_const_bound() {
             let start = self.token.span;
             self.bump();
             self.expect_keyword(exp!(Const)).unwrap();