Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
works with any tool attr also compiles but it probably... shouldn't.
label +S-bug-has-mcve
Triaged with . Steps performed: Reproduced: Formatted: No change, already formatted Reduced: Bisected: Regression in nightly-2022-04-17 couldn't nail down the particular commit: <details<summaryDetails</summary<prustc version: Icemelter version: v0.2.0 Icemelter command line: Do you have feedback about this report? Please ! </p</details
another one `

Discussion:
resolve_indeterminate = cannot determine resolution for the visibility <ins> resolve_tool_module_imported = cannot use a tool module through an import .note = the tool module imported here </ins> resolve_module_only = visibility must resolve to a module

pub(crate) struct Indeterminate(#[primary_span] pub(crate) Span); #[derive(Diagnostic)] <ins> #[diag(resolve_tool_module_imported)] pub(crate) struct ToolModuleImported { #[primary_span] pub(crate) span: Span, #[note] pub(crate) import: Span, } #[derive(Diagnostic)] </ins> #[diag(resolve_module_only)] pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span);

ConstantHasGenerics, ConstantItemKind, HasGenericParams, PathSource, Rib, RibKind, }; use crate::macros::{sub_namespace_match, MacroRulesScope}; <del> use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize}; </del> <ins> use crate::{errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize}; </ins> use crate::{Import, ImportKind, LexicalScopeBinding, Module, ModuleKind, ModuleOrUniformRoot}; use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PrivacyError, Res}; use crate::{ResolutionError, Resolver, Scope, ScopeSet, Segment, ToNameBinding, Weak};

} }; <del> let is_last = i == path.len() - 1; </del> <ins> let is_last = i + 1 == path.len(); </ins> let ns = if is_last { opt_ns.unwrap_or(TypeNS) } else { TypeNS }; let name = ident.name;

if let Some(next_module) = binding.module() { module = Some(ModuleOrUniformRoot::Module(next_module)); record_segment_res(self, res); <del> } else if res == Res::ToolMod && i + 1 != path.len() { </del> <ins> } else if res == Res::ToolMod && !is_last && opt_ns.is_some() { </ins> if binding.is_import() { <del> self.tcx .sess .struct_span_err( ident.span, "cannot use a tool module through an import", ) .span_note(binding.span, "the tool module imported here") .emit(); </del> <ins> self.tcx.sess.emit_err(errors::ToolModuleImported { span: ident.span, import: binding.span, }); </ins> } let res = Res::NonMacroAttr(NonMacroAttrKind::Tool); return PathResult::NonModule(PartialRes::new(res));

<ins> // edition: 2018 use clippy::time::Instant; //~^ `clippy` is a tool module fn main() { Instant::now(); } </ins>

<ins> error[E0433]: failed to resolve: `clippy` is a tool module, not a module --> $DIR/tool-import.rs:3:5 | LL | use clippy::time::Instant; |     ^^^^^^ `clippy` is a tool module, not a module error: aborting due to previous error For more information about this error, try `rustc --explain E0433`. </ins>