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:
@@ -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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user