Diagnose private field accesses

This commit is contained in:
Lukas Wirth 2022-12-31 14:20:59 +01:00
parent ec125fe46a
commit e3d144d17f
6 changed files with 86 additions and 11 deletions

View file

@ -10,7 +10,7 @@ use hir_def::path::ModPath;
use hir_expand::{name::Name, HirFileId, InFile};
use syntax::{ast, AstPtr, SyntaxNodePtr, TextRange};
use crate::{MacroKind, Type};
use crate::{Field, MacroKind, Type};
macro_rules! diagnostics {
($($diag:ident,)*) => {
@ -41,6 +41,7 @@ diagnostics![
MissingMatchArms,
MissingUnsafe,
NoSuchField,
PrivateField,
ReplaceFilterMapNextWithFindMap,
TypeMismatch,
UnimplementedBuiltinMacro,
@ -121,6 +122,12 @@ pub struct NoSuchField {
pub field: InFile<AstPtr<ast::RecordExprField>>,
}
#[derive(Debug)]
pub struct PrivateField {
pub expr: InFile<AstPtr<ast::Expr>>,
pub field: Field,
}
#[derive(Debug)]
pub struct BreakOutsideOfLoop {
pub expr: InFile<AstPtr<ast::Expr>>,