提交 199ed20a 编写于 作者: J Jeffrey Seyfried

Fix `$crate`-related regressions.

上级 67f26f7e
......@@ -845,6 +845,10 @@ fn is_trait(&self) -> bool {
_ => false,
}
}
fn is_local(&self) -> bool {
self.normal_ancestor_id.is_some()
}
}
impl<'a> fmt::Debug for ModuleS<'a> {
......@@ -1585,8 +1589,7 @@ fn resolve_module_prefix(&mut self, module_path: &[Ident], span: Option<Span>)
ctxt = ctxt.source().0;
}
let module = self.invocations[&ctxt.source().1].module.get();
let crate_root =
if module.def_id().unwrap().is_local() { self.graph_root } else { module };
let crate_root = if module.is_local() { self.graph_root } else { module };
return Success(PrefixFound(crate_root, 1))
}
......@@ -2569,7 +2572,8 @@ fn resolve_path(&mut self, id: NodeId, path: &Path, path_depth: usize, namespace
let unqualified_def = resolve_identifier_with_fallback(self, None);
let qualified_binding = self.resolve_module_relative_path(span, segments, namespace);
match (qualified_binding, unqualified_def) {
(Ok(binding), Some(ref ud)) if binding.def() == ud.def => {
(Ok(binding), Some(ref ud)) if binding.def() == ud.def &&
segments[0].identifier.name.as_str() != "$crate" => {
self.session
.add_lint(lint::builtin::UNUSED_QUALIFICATIONS,
id,
......
......@@ -18,4 +18,11 @@ fn main() {
use foo::bar;
foo::bar(); //~ ERROR: unnecessary qualification
bar();
let _ = || -> Result<(), ()> { try!(Ok(())); Ok(()) }; // issue #37345
macro_rules! m {
() => { $crate::foo::bar(); }
}
m!(); // issue #37357
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册