|
3 | 3 | mod block; |
4 | 4 |
|
5 | 5 | use crate::{ |
6 | | - algo, ast, match_ast, AstNode, SyntaxError, |
| 6 | + algo, |
| 7 | + ast::{self, VisibilityOwner}, |
| 8 | + match_ast, AstNode, SyntaxError, |
7 | 9 | SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS}, |
8 | 10 | SyntaxNode, SyntaxToken, TextSize, T, |
9 | 11 | }; |
@@ -99,6 +101,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> { |
99 | 101 | ast::RefType(it) => validate_trait_object_ref_ty(it, &mut errors), |
100 | 102 | ast::PtrType(it) => validate_trait_object_ptr_ty(it, &mut errors), |
101 | 103 | ast::FnPtrType(it) => validate_trait_object_fn_ptr_ret_ty(it, &mut errors), |
| 104 | + ast::MacroRules(it) => validate_macro_rules(it, &mut errors), |
102 | 105 | _ => (), |
103 | 106 | } |
104 | 107 | } |
@@ -350,3 +353,12 @@ fn validate_trait_object_ty(ty: ast::DynTraitType) -> Option<SyntaxError> { |
350 | 353 | } |
351 | 354 | None |
352 | 355 | } |
| 356 | + |
| 357 | +fn validate_macro_rules(mac: ast::MacroRules, errors: &mut Vec<SyntaxError>) { |
| 358 | + if let Some(vis) = mac.visibility() { |
| 359 | + errors.push(SyntaxError::new( |
| 360 | + "visibilities are not allowed on `macro_rules!` items", |
| 361 | + vis.syntax().text_range(), |
| 362 | + )); |
| 363 | + } |
| 364 | +} |
0 commit comments