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)
|
fn resolve_macro_to_def(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, force: bool)
|
||||||
-> Result<Def, Determinacy> {
|
-> Result<Def, Determinacy> {
|
||||||
let ast::Path { ref segments, span } = *path;
|
let def = self.resolve_macro_to_def_inner(scope, path, kind, force);
|
||||||
segments.iter().find(|segment| segment.parameters.is_some()).map(|segment| {
|
if def != Err(Determinacy::Undetermined) {
|
||||||
self.session.span_err(segment.parameters.as_ref().unwrap().span(),
|
// Do not report duplicated errors on every undetermined resolution.
|
||||||
"generic arguments in macro path");
|
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 path: Vec<_> = segments.iter().map(|seg| respan(seg.span, seg.identifier)).collect();
|
||||||
let invocation = self.invocations[&scope];
|
let invocation = self.invocations[&scope];
|
||||||
self.current_module = invocation.module.get();
|
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);
|
fn check_unused_macros(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
pub enum Determinacy {
|
pub enum Determinacy {
|
||||||
Determined,
|
Determined,
|
||||||
Undetermined,
|
Undetermined,
|
||||||
|
@ -16,47 +16,5 @@ error: generic arguments in macro path
|
|||||||
26 | m!(MyTrait<>);
|
26 | m!(MyTrait<>);
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error: generic arguments in macro path
|
error: aborting due to 3 previous errors
|
||||||
--> $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
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user