Introduce ArgSource for diagnostics.

This commit introduces an `ArgSource` enum that is lowered into the HIR
so that diagnostics can correctly refer to the argument pattern's
original name rather than the generated pattern.
This commit is contained in:
David Wood
2019-03-13 17:10:27 +01:00
parent 92e72df2c1
commit 9d7da824d6
15 changed files with 128 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
use crate::ast::{AngleBracketedArgs, AsyncArgument, ParenthesizedArgs, AttrStyle, BareFnTy};
use crate::ast::{GenericBound, TraitBoundModifier};
use crate::ast::Unsafety;
use crate::ast::{Mod, AnonConst, Arg, Arm, Guard, Attribute, BindingMode, TraitItemKind};
use crate::ast::{Mod, AnonConst, Arg, ArgSource, Arm, Guard, Attribute, BindingMode, TraitItemKind};
use crate::ast::Block;
use crate::ast::{BlockCheckMode, CaptureBy, Movability};
use crate::ast::{Constness, Crate};
@@ -550,7 +550,7 @@ fn dummy_arg(span: Span) -> Arg {
span,
id: ast::DUMMY_NODE_ID
};
Arg { ty: P(ty), pat: pat, id: ast::DUMMY_NODE_ID }
Arg { ty: P(ty), pat: pat, id: ast::DUMMY_NODE_ID, source: ast::ArgSource::Normal }
}
#[derive(Copy, Clone, Debug)]
@@ -2126,7 +2126,7 @@ impl<'a> Parser<'a> {
}
};
Ok(Arg { ty, pat, id: ast::DUMMY_NODE_ID })
Ok(Arg { ty, pat, id: ast::DUMMY_NODE_ID, source: ast::ArgSource::Normal })
}
/// Parses a single function argument.
@@ -2149,7 +2149,8 @@ impl<'a> Parser<'a> {
Ok(Arg {
ty: t,
pat,
id: ast::DUMMY_NODE_ID
id: ast::DUMMY_NODE_ID,
source: ast::ArgSource::Normal,
})
}
@@ -8856,6 +8857,7 @@ impl<'a> Parser<'a> {
),
span,
}),
source: ArgSource::AsyncFn(input.pat.clone()),
};
// Construct a `let <pat> = __argN;` statement to insert at the top of the