diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-07-25 00:33:15 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-07-27 23:01:17 +0300 |
| commit | 1e8a7f68e9c8dea677390b84fa72476ddb4bf1ca (patch) | |
| tree | f3d04e0fb830ba4e6be59ab4bab54e4fbcfd9301 | |
| parent | 128f565daeced02b9d90e1d1a6c0988d25fc1701 (diff) | |
| download | rust-1e8a7f68e9c8dea677390b84fa72476ddb4bf1ca.tar.gz rust-1e8a7f68e9c8dea677390b84fa72476ddb4bf1ca.zip | |
Avoid duplicated errors for generic arguments in macro paths
| -rw-r--r-- | src/librustc_resolve/macros.rs | 19 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/span/macro-ty-params.stderr | 44 |
3 files changed, 16 insertions, 49 deletions
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index f8f9b27f148..4d4f6aadce4 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -385,12 +385,21 @@ impl<'a> Resolver<'a> { 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(); diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 4881170c1d1..7eeafa72c68 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -608,7 +608,7 @@ pub trait Resolver { fn check_unused_macros(&self); } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq)] pub enum Determinacy { Determined, Undetermined, diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index ff3847ce1fa..f7115a04826 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -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 |
