Parse const unsafe trait properly
Previously, this was greedily stolen by the `fn` parsing logic.
This commit is contained in:
parent
6380899f32
commit
b145213cee
2 changed files with 17 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
13
tests/ui/traits/const-traits/parse-const-unsafe-trait.rs
Normal file
13
tests/ui/traits/const-traits/parse-const-unsafe-trait.rs
Normal 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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue