Parse const unsafe trait properly

Previously, this was greedily stolen by the `fn` parsing logic.
This commit is contained in:
Deadbeef 2025-10-18 23:35:23 +00:00
parent 6380899f32
commit b145213cee
2 changed files with 17 additions and 1 deletions

View file

@ -2664,7 +2664,10 @@ impl<'a> Parser<'a> {
// Rule out `unsafe extern {`.
&& !self.is_unsafe_foreign_mod()
// Rule out `async gen {` and `async gen move {`
&& !self.is_async_gen_block())
&& !self.is_async_gen_block()
// Rule out `const unsafe auto` and `const unsafe trait`.
&& !self.is_keyword_ahead(2, &[kw::Auto, kw::Trait])
)
})
// `extern ABI fn`
|| self.check_keyword_case(exp!(Extern), case)

View file

@ -0,0 +1,13 @@
// Test that `const unsafe trait` and `const unsafe auto trait` works.
//@ check-pass
#![feature(const_trait_impl)]
#![feature(auto_traits)]
pub const unsafe trait Owo {}
const unsafe trait OwO {}
pub const unsafe auto trait UwU {}
const unsafe auto trait Uwu {}
fn main() {}