mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-19 10:00:27 +00:00
Auto merge of #12057 - harpsword:fix_validata_visibility, r=jonas-schievink
fix visibility token validation in trait impl with proc-macro fix #11828
This commit is contained in:
commit
1ad500beb6
1 changed files with 4 additions and 2 deletions
|
@ -11,7 +11,7 @@ use rustc_lexer::unescape::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algo,
|
algo,
|
||||||
ast::{self, HasVisibility},
|
ast::{self, HasAttrs, HasVisibility},
|
||||||
match_ast, AstNode, SyntaxError,
|
match_ast, AstNode, SyntaxError,
|
||||||
SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS},
|
SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS},
|
||||||
SyntaxNode, SyntaxToken, TextSize, T,
|
SyntaxNode, SyntaxToken, TextSize, T,
|
||||||
|
@ -231,7 +231,9 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
if impl_def.trait_().is_some() {
|
// FIXME: disable validation if there's an attribute, since some proc macros use this syntax.
|
||||||
|
// ideally the validation would run only on the fully expanded code, then this wouldn't be necessary.
|
||||||
|
if impl_def.trait_().is_some() && impl_def.attrs().next().is_none() {
|
||||||
errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
|
errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue