mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Apply stylistic changes suggested
This commit is contained in:
parent
e570267515
commit
3d9c2beb8e
2 changed files with 14 additions and 17 deletions
|
@ -54,7 +54,7 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
|
||||||
|
|
||||||
// test block_items
|
// test block_items
|
||||||
// fn a() { fn b() {} }
|
// fn a() { fn b() {} }
|
||||||
let mut m = p.start();
|
let m = p.start();
|
||||||
let has_attrs = p.at(POUND);
|
let has_attrs = p.at(POUND);
|
||||||
attributes::outer_attributes(p);
|
attributes::outer_attributes(p);
|
||||||
if p.at(LET_KW) {
|
if p.at(LET_KW) {
|
||||||
|
@ -62,9 +62,9 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m = match items::maybe_item(p, m, items::ItemFlavor::Mod) {
|
let m = match items::maybe_item(p, m, items::ItemFlavor::Mod) {
|
||||||
Some(m) => m,
|
Ok(()) => continue,
|
||||||
None => continue,
|
Err(m) => m,
|
||||||
};
|
};
|
||||||
|
|
||||||
// test pub_expr
|
// test pub_expr
|
||||||
|
|
|
@ -35,11 +35,11 @@ pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![
|
||||||
];
|
];
|
||||||
|
|
||||||
pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) {
|
pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) {
|
||||||
let mut m = p.start();
|
let m = p.start();
|
||||||
attributes::outer_attributes(p);
|
attributes::outer_attributes(p);
|
||||||
m = match maybe_item(p, m, flavor) {
|
let m = match maybe_item(p, m, flavor) {
|
||||||
Some(m) => m,
|
Ok(()) => return,
|
||||||
None => return,
|
Err(m) => m,
|
||||||
};
|
};
|
||||||
if paths::is_path_start(p) {
|
if paths::is_path_start(p) {
|
||||||
match macro_call(p) {
|
match macro_call(p) {
|
||||||
|
@ -66,11 +66,11 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Option<Marker> {
|
pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Result<(), Marker> {
|
||||||
opt_visibility(p);
|
opt_visibility(p);
|
||||||
if let Some(kind) = items_without_modifiers(p) {
|
if let Some(kind) = items_without_modifiers(p) {
|
||||||
m.complete(p, kind);
|
m.complete(p, kind);
|
||||||
return None;
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut has_mods = false;
|
let mut has_mods = false;
|
||||||
|
@ -124,7 +124,6 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Optio
|
||||||
FN_KW => {
|
FN_KW => {
|
||||||
fn_def(p, flavor);
|
fn_def(p, flavor);
|
||||||
m.complete(p, FN_DEF);
|
m.complete(p, FN_DEF);
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// test unsafe_trait
|
// test unsafe_trait
|
||||||
|
@ -138,7 +137,6 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Optio
|
||||||
TRAIT_KW => {
|
TRAIT_KW => {
|
||||||
traits::trait_def(p);
|
traits::trait_def(p);
|
||||||
m.complete(p, TRAIT_DEF);
|
m.complete(p, TRAIT_DEF);
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// test unsafe_impl
|
// test unsafe_impl
|
||||||
|
@ -152,18 +150,17 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Optio
|
||||||
IMPL_KW => {
|
IMPL_KW => {
|
||||||
traits::impl_block(p);
|
traits::impl_block(p);
|
||||||
m.complete(p, IMPL_BLOCK);
|
m.complete(p, IMPL_BLOCK);
|
||||||
None
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if has_mods {
|
if !has_mods {
|
||||||
|
return Err(m);
|
||||||
|
} else {
|
||||||
p.error("expected fn, trait or impl");
|
p.error("expected fn, trait or impl");
|
||||||
m.complete(p, ERROR);
|
m.complete(p, ERROR);
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
|
fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue