Avoid duplicated errors for generic arguments in macro paths
This commit is contained in:
parent
128f565dae
commit
1e8a7f68e9
@ -385,12 +385,21 @@ fn resolve_invoc_to_def(&mut self, invoc: &mut Invocation, scope: Mark, force: b
|
||||
|
||||
fn resolve_macro_to_def(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, force: bool)
|
||||
-> Result<Def, Determinacy> {
|
||||
let ast::Path { ref segments, span } = *path;
|
||||
segments.iter().find(|segment| segment.parameters.is_some()).map(|segment| {
|
||||
self.session.span_err(segment.parameters.as_ref().unwrap().span(),
|
||||
"generic arguments in macro path");
|
||||
});
|
||||
let def = self.resolve_macro_to_def_inner(scope, path, kind, force);
|
||||
if def != Err(Determinacy::Undetermined) {
|
||||
// Do not report duplicated errors on every undetermined resolution.
|
||||
path.segments.iter().find(|segment| segment.parameters.is_some()).map(|segment| {
|
||||
self.session.span_err(segment.parameters.as_ref().unwrap().span(),
|
||||
"generic arguments in macro path");
|
||||
});
|
||||
}
|
||||
def
|
||||
}
|
||||
|
||||
fn resolve_macro_to_def_inner(&mut self, scope: Mark, path: &ast::Path,
|
||||
kind: MacroKind, force: bool)
|
||||
-> Result<Def, Determinacy> {
|
||||
let ast::Path { ref segments, span } = *path;
|
||||
let path: Vec<_> = segments.iter().map(|seg| respan(seg.span, seg.identifier)).collect();
|
||||
let invocation = self.invocations[&scope];
|
||||
self.current_module = invocation.module.get();
|
||||
|
@ -608,7 +608,7 @@ fn resolve_macro(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, forc
|
||||
fn check_unused_macros(&self);
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum Determinacy {
|
||||
Determined,
|
||||
Undetermined,
|
||||
|
@ -16,47 +16,5 @@ error: generic arguments in macro path
|
||||
26 | m!(MyTrait<>);
|
||||
| ^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
--> $DIR/macro-ty-params.rs:26:15
|
||||
|
|
||||
26 | m!(MyTrait<>);
|
||||
| ^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
--> $DIR/macro-ty-params.rs:26:15
|
||||
|
|
||||
26 | m!(MyTrait<>);
|
||||
| ^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
--> $DIR/macro-ty-params.rs:22:8
|
||||
|
|
||||
22 | foo::<>!();
|
||||
| ^^^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
--> $DIR/macro-ty-params.rs:18:8
|
||||
|
|
||||
18 | foo::<T>!();
|
||||
| ^^^^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
--> $DIR/macro-ty-params.rs:18:8
|
||||
|
|
||||
18 | foo::<T>!();
|
||||
| ^^^^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
--> $DIR/macro-ty-params.rs:22:8
|
||||
|
|
||||
22 | foo::<>!();
|
||||
| ^^^^
|
||||
|
||||
error: generic arguments in macro path
|
||||
--> $DIR/macro-ty-params.rs:26:15
|
||||
|
|
||||
26 | m!(MyTrait<>);
|
||||
| ^^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user