Change:
When on latest rust nightly , you get an ICE when compiling .
Its a pretty recent regression, it can't be reproduced with .
Okay, managed to minimize it: Looks like a regression of . cc any ideas on this?
Yeah, this was caused by an oversight in -- fixed in .

Discussion:
match view_path.node { ViewPathSimple(binding, ref full_path) => { <del> let source_name = full_path.segments.last().unwrap().identifier.name; if source_name.as_str() == "mod" || source_name.as_str() == "self" { </del> <ins> let mut source = full_path.segments.last().unwrap().identifier; let source_name = source.name.as_str(); if source_name == "mod" || source_name == "self" { </ins> resolve_error(self, view_path.span, ResolutionError::SelfImportsOnlyAllowedWithin); <ins> } else if source_name == "$crate" && full_path.segments.len() == 1 { let crate_root = self.resolve_crate_var(source.ctxt); let crate_name = match crate_root.kind { ModuleKind::Def(_, name) => name, ModuleKind::Block(..) => unreachable!(), }; source.name = crate_name; self.session.struct_span_warn(item.span, "`$crate` may not be imported") .note("`use $crate;` was erroneously allowed and  will become a hard error in a future release") .emit(); </ins> } <del> let subclass = ImportDirectiveSubclass::single(binding.name, source_name); </del> <ins> let subclass = ImportDirectiveSubclass::single(binding.name, source.name); </ins> let span = view_path.span; self.add_import_directive(module_path, subclass, span, item.id, vis); }

legacy_imports: LegacyMacroImports, allow_shadowing: bool) { let import_macro = |this: &mut Self, name, ext: Rc<_>, span| { <ins> this.used_crates.insert(module.def_id().unwrap().krate); </ins> if let SyntaxExtension::NormalTT(..) = *ext { this.macro_names.insert(name); }

_ => false, } } <ins> fn is_local(&self) -> bool { self.normal_ancestor_id.is_some() } </ins> } impl<'a> fmt::Debug for ModuleS<'a> {

fn resolve_module_prefix(&mut self, module_path: &[Ident], span: Option<Span>) -> ResolveResult<ModulePrefixResult<'a>> { if &*module_path[0].name.as_str() == "$crate" { <del> let mut ctxt = module_path[0].ctxt; while ctxt.source().0 != SyntaxContext::empty() { 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 }; return Success(PrefixFound(crate_root, 1)) </del> <ins> return Success(PrefixFound(self.resolve_crate_var(module_path[0].ctxt), 1)); </ins> } // Start at the current module if we see `self` or `super`, or at the

return Success(PrefixFound(containing_module, i)); } <ins> fn resolve_crate_var(&mut self, mut crate_var_ctxt: SyntaxContext) -> Module<'a> { while crate_var_ctxt.source().0 != SyntaxContext::empty() { crate_var_ctxt = crate_var_ctxt.source().0; } let module = self.invocations[&crate_var_ctxt.source().1].module.get(); if module.is_local() { self.graph_root } else { module } } </ins> // AST resolution // // We maintain a list of value ribs and type ribs.

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) { <del> (Ok(binding), Some(ref ud)) if binding.def() == ud.def => { </del> <ins> (Ok(binding), Some(ref ud)) if binding.def() == ud.def && segments[0].identifier.name.as_str() != "$crate" => { </ins> self.session .add_lint(lint::builtin::UNUSED_QUALIFICATIONS, id,

<ins> // Copyright 2016 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. #[macro_export] macro_rules! m { () => { use $crate; } } </ins>

<ins> // Copyright 2016 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. // aux-build:import_crate_var.rs // error-pattern: `$crate` may not be imported // error-pattern: `use $crate;` was erroneously allowed and will become a hard error #![feature(rustc_attrs)] #[macro_use] extern crate import_crate_var; m!(); #[rustc_error] fn main() {} </ins>

use foo::bar; foo::bar(); //~ ERROR: unnecessary qualification bar(); <ins> let _ = || -> Result<(), ()> { try!(Ok(())); Ok(()) }; // issue #37345 macro_rules! m { () => { $crate::foo::bar(); } } m!(); // issue #37357 </ins> }

extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used <ins> #[macro_use] extern crate core; // no error, the `#[macro_use]` marks it as used </ins> #[allow(unused_imports)] use rand::isaac::IsaacRng;