mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Parse default unsafe & default const
This commit is contained in:
parent
65a3cc21ed
commit
fb632c747d
2 changed files with 45 additions and 15 deletions
|
@ -118,7 +118,15 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
|||
&& p.at_contextual_kw("default")
|
||||
&& (match p.nth(1) {
|
||||
T![impl] => true,
|
||||
T![fn] | T![type] => {
|
||||
T![unsafe] => {
|
||||
if T![impl] == p.nth(2) {
|
||||
p.bump_remap(T![default]);
|
||||
p.bump_remap(T![unsafe]);
|
||||
has_mods = true;
|
||||
}
|
||||
false
|
||||
}
|
||||
T![fn] | T![type] | T![const] => {
|
||||
if let ItemFlavor::Mod = flavor {
|
||||
true
|
||||
} else {
|
||||
|
@ -187,6 +195,9 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
|||
// test default_impl
|
||||
// default impl Foo {}
|
||||
|
||||
// test default_unsafe_impl
|
||||
// default unsafe impl Foo {}
|
||||
|
||||
// test_err default_fn_type
|
||||
// trait T {
|
||||
// default type T = Bar;
|
||||
|
@ -199,6 +210,19 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
|||
// default fn foo() {}
|
||||
// }
|
||||
|
||||
// test_err default_const
|
||||
// trait T {
|
||||
// default const f: u8 = 0;
|
||||
// }
|
||||
|
||||
// test default_const
|
||||
// impl T for Foo {
|
||||
// default const f: u8 = 0;
|
||||
// }
|
||||
T![const] => {
|
||||
consts::const_def(p, m);
|
||||
}
|
||||
|
||||
// test unsafe_default_impl
|
||||
// unsafe default impl Foo {}
|
||||
T![impl] => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue