提交 1e8a7f68 编写于 作者: V Vadim Petrochenkov

Avoid duplicated errors for generic arguments in macro paths

上级 128f565d
......@@ -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| {
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册