Auto merge of #47031 - topecongiro:issue-41719, r=jseyfried

Report an error when resolving non-ident macro path failed

Closes #41719.

Please feel free to bikeshed on the error message.
This commit is contained in:
bors
2017-12-28 10:28:16 +00:00
2 changed files with 27 additions and 1 deletions
+9 -1
View File
@@ -429,7 +429,15 @@ fn resolve_macro_to_def_inner(&mut self, scope: Mark, path: &ast::Path,
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),
+18
View File
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
}