diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 260a0cd7cd7..14b5c6c9a5e 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -429,7 +429,15 @@ impl<'a> Resolver<'a> { let def = match self.resolve_path(&path, Some(MacroNS), false, span) { PathResult::NonModule(path_res) => match path_res.base_def() { Def::Err => Err(Determinacy::Determined), - def @ _ => Ok(def), + def @ _ => { + if path_res.unresolved_segments() > 0 { + self.found_unresolved_macro = true; + self.session.span_err(span, "fail to resolve non-ident macro path"); + Err(Determinacy::Determined) + } else { + Ok(def) + } + } }, PathResult::Module(..) => unreachable!(), PathResult::Indeterminate if !force => return Err(Determinacy::Undetermined), diff --git a/src/test/compile-fail/extern-macro.rs b/src/test/compile-fail/extern-macro.rs new file mode 100644 index 00000000000..4267103ab9a --- /dev/null +++ b/src/test/compile-fail/extern-macro.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #41719 + +#![feature(use_extern_macros)] + +fn main() { + enum Foo {} + let _ = Foo::bar!(); //~ ERROR fail to resolve non-ident macro path +}