Skip to content

Commit 1ad500b

Browse files
committed
Auto merge of rust-lang#12057 - harpsword:fix_validata_visibility, r=jonas-schievink
fix visibility token validation in trait impl with proc-macro fix rust-lang#11828
2 parents 6c6aaee + b1f8581 commit 1ad500b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/syntax/src/validation.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_lexer::unescape::{
1111

1212
use crate::{
1313
algo,
14-
ast::{self, HasVisibility},
14+
ast::{self, HasAttrs, HasVisibility},
1515
match_ast, AstNode, SyntaxError,
1616
SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS},
1717
SyntaxNode, SyntaxToken, TextSize, T,
@@ -231,7 +231,9 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
231231
Some(it) => it,
232232
None => return,
233233
};
234-
if impl_def.trait_().is_some() {
234+
// FIXME: disable validation if there's an attribute, since some proc macros use this syntax.
235+
// ideally the validation would run only on the fully expanded code, then this wouldn't be necessary.
236+
if impl_def.trait_().is_some() && impl_def.attrs().next().is_none() {
235237
errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
236238
}
237239
}

0 commit comments

Comments
 (0)