Skip to content

Commit 1603311

Browse files
committed
Parse const unsafe trait properly
Previously, this was greedily stolen by the `fn` parsing logic.
1 parent 6380899 commit 1603311

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/rustc_parse/src/parser/item.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,10 @@ impl<'a> Parser<'a> {
26642664
// Rule out `unsafe extern {`.
26652665
&& !self.is_unsafe_foreign_mod()
26662666
// Rule out `async gen {` and `async gen move {`
2667-
&& !self.is_async_gen_block())
2667+
&& !self.is_async_gen_block()
2668+
// Rule out `const unsafe auto` and `const unsafe trait`.
2669+
&& !self.is_keyword_ahead(2, &[kw::Auto, kw::Trait])
2670+
)
26682671
})
26692672
// `extern ABI fn`
26702673
|| self.check_keyword_case(exp!(Extern), case)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Test that `const unsafe trait` and `const unsafe auto trait` works.
2+
3+
//@ check-pass
4+
5+
#![feature(const_trait_impl)]
6+
#![feature(auto_traits)]
7+
8+
pub const unsafe trait Owo {}
9+
const unsafe trait OwO {}
10+
pub const unsafe auto trait UwU {}
11+
const unsafe auto trait Uwu {}
12+
13+
fn main() {}

0 commit comments

Comments
 (0)