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. --I got a very large poc file, and reduce it into following code. But after reducing (via a simple delta debugging tech), the code looks kind of confusing. Please let me know if anyone prefers a better-formed but long test-case, and I will try me best to get one. md5: <!-- 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. --The bug is reproduced with nightly and beta versions, but not with stable version. : The output is from nightly. <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
This can be "solved" by using and create a instead of panicking.
Assigning as discussed as part of the and removing .
A reproduction with fewer errors:
The provided examples do not panic anymore, can this issue be closed or does it need tests?
lets keep it open purely to track adding regression tests for these.

Discussion:
} impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> { <ins> fn visit_attribute(&mut self, _: &'a Attribute) { // We do not want to lower expressions that appear in attributes, // as they are not accessible to the rest of the HIR. } </ins> fn visit_item(&mut self, item: &'a Item) { let hir_id = self.lctx.with_hir_id_owner(item.id, |lctx| { let node = lctx.without_in_scope_lifetime_defs(|lctx| lctx.lower_item(item));

/// Walks the whole crate in DFS order, visiting each item, resolving names as it goes. impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { <ins> fn visit_attribute(&mut self, _: &'ast Attribute) { // We do not want to resolve expressions that appear in attributes, // as they do not correspond to actual code. } </ins> fn visit_item(&mut self, item: &'ast Item) { let prev = replace(&mut self.diagnostic_metadata.current_item, Some(item)); // Always report errors in items we just entered.

<ins> #![u=||{static d=||1;}] //~^ unexpected token //~| cannot find attribute `u` in this scope //~| `main` function not found in crate `issue_90873` //~| missing type for `static` item #![a={impl std::ops::Neg for i8 {}}] //~^ ERROR unexpected token //~| ERROR cannot find attribute `a` in this scope </ins>

<ins> error: unexpected token: `|| { static d: _ = || 1; }` --> $DIR/issue-90873.rs:1:6 | LL | #![u=||{static d=||1;}] |      ^^^^^^^^^^^^^^^^^ error: unexpected token: `{ impl std::ops::Neg for i8 { } }` --> $DIR/issue-90873.rs:7:6 | LL | #![a={impl std::ops::Neg for i8 {}}] |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `u` in this scope --> $DIR/issue-90873.rs:1:4 | LL | #![u=||{static d=||1;}] |    ^ error: cannot find attribute `a` in this scope --> $DIR/issue-90873.rs:7:4 | LL | #![a={impl std::ops::Neg for i8 {}}] |    ^ error[E0601]: `main` function not found in crate `issue_90873` --> $DIR/issue-90873.rs:1:1 | LL | / #![u=||{static d=||1;}] LL | | LL | | LL | | LL | | LL | | LL | | #![a={impl std::ops::Neg for i8 {}}] | |____________________________________^ consider adding a `main` function to `$DIR/issue-90873.rs` error: missing type for `static` item --> $DIR/issue-90873.rs:1:16 | LL | #![u=||{static d=||1;}] |                ^ help: provide a type for the item: `d: <type>` error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0601`. </ins>

#![l=|x|[b;x ]] //~ ERROR unexpected token: `|x| [b; x]` //~^ ERROR cannot find attribute `l` in this scope <del> //~^^ ERROR attempt to use a non-constant value in a constant [E0435] //~^^^ ERROR cannot find value `b` in this scope [E0425] </del> // notice the space at the start, // we can't attach any attributes to this file because it needs to be at the start

LL |  #![l=|x|[b;x ]] |     ^ <del> error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-90878-2.rs:1:13 | LL |  #![l=|x|[b;x ]] |        -    ^ |        | |        this would need to be a `const` error[E0425]: cannot find value `b` in this scope --> $DIR/issue-90878-2.rs:1:11 | LL |  #![l=|x|[b;x ]] |           ^ help: a local variable with a similar name exists: `x` error: aborting due to 4 previous errors </del> <ins> error: aborting due to 2 previous errors </ins> <del> Some errors have detailed explanations: E0425, E0435. For more information about an error, try `rustc --explain E0425`. </del>