diff options
| author | bors <bors@rust-lang.org> | 2022-04-27 13:09:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-27 13:09:31 +0000 |
| commit | 1ad500beb68fa5cc0807a6691237459fe2bf6c5c (patch) | |
| tree | 5a58eeff6728bb507d916f95748d539ca9d4127f /crates/syntax/src | |
| parent | 6c6aaeee7af19ab14914db52ca826bfa36532190 (diff) | |
| parent | b1f858118b9e23f78110e7bc0bacadd1313c7fec (diff) | |
| download | rust-1ad500beb68fa5cc0807a6691237459fe2bf6c5c.tar.gz rust-1ad500beb68fa5cc0807a6691237459fe2bf6c5c.zip | |
Auto merge of #12057 - harpsword:fix_validata_visibility, r=jonas-schievink
fix visibility token validation in trait impl with proc-macro fix #11828
Diffstat (limited to 'crates/syntax/src')
| -rw-r--r-- | crates/syntax/src/validation.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs index 3ea5844c951..286affbba92 100644 --- a/crates/syntax/src/validation.rs +++ b/crates/syntax/src/validation.rs @@ -11,7 +11,7 @@ use rustc_lexer::unescape::{ use crate::{ algo, - ast::{self, HasVisibility}, + ast::{self, HasAttrs, HasVisibility}, match_ast, AstNode, SyntaxError, SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS}, SyntaxNode, SyntaxToken, TextSize, T, @@ -231,7 +231,9 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) { Some(it) => it, 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())); } } |
