Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: compiler/rustc_middle/src/hir/map/mod.rs:810:21: no name for param # [ doc ( alias = "false" ) ] DiagnosticBuilder (hir_id=HirId { owner: DefId(0:4 ~ mutant[8787]::StructuredDiagnostic::extended), local_id: 1 }) #86239

Closed
Cancelll opened this issue Jun 12, 2021 · 8 comments · Fixed by #86332
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Cancelll
Copy link

Code

trait StructuredDiagnostic {
fn extended (# [ doc ( alias = "false" ) ] DiagnosticBuilder){
}
}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (0a8629bff 2021-06-11)
binary: rustc
commit-hash: 0a8629bff642c3c3b84bb644c0099194f063b627
commit-date: 2021-06-11
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters
 --> mutant.rs:2:14
  |
2 | fn extended (# [ doc ( alias = "false" ) ] DiagnosticBuilder){
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0412]: cannot find type `DiagnosticBuilder` in this scope
 --> mutant.rs:2:44
  |
2 | fn extended (# [ doc ( alias = "false" ) ] DiagnosticBuilder){
  |                                            ^^^^^^^^^^^^^^^^^ not found in this scope

warning: anonymous parameters are deprecated and will be removed in the next edition.
 --> mutant.rs:2:44
  |
2 | fn extended (# [ doc ( alias = "false" ) ] DiagnosticBuilder){
  |                                            ^^^^^^^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: DiagnosticBuilder`
  |
  = note: `#[warn(anonymous_parameters)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:810:21: no name for param # [ doc ( alias = "false" ) ] DiagnosticBuilder (hir_id=HirId { owner: DefId(0:4 ~ mutant[8787]::StructuredDiagnostic::extended), local_id: 1 })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1007:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (0a8629bff 2021-06-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -Z new-llvm-pass-manager=yes -Z unsound-mir-opts=yes -Z polonius=yes -Z polymorphize=yes -C debuginfo=2 -C opt-level=3 --crate-type staticlib

query stack during panic:
#0 [check_mod_attrs] checking attributes in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0412`.
Backtrace

error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters
 --> mutant.rs:2:14
  |
2 | fn extended (# [ doc ( alias = "false" ) ] DiagnosticBuilder){
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0412]: cannot find type `DiagnosticBuilder` in this scope
 --> mutant.rs:2:44
  |
2 | fn extended (# [ doc ( alias = "false" ) ] DiagnosticBuilder){
  |                                            ^^^^^^^^^^^^^^^^^ not found in this scope

warning: anonymous parameters are deprecated and will be removed in the next edition.
 --> mutant.rs:2:44
  |
2 | fn extended (# [ doc ( alias = "false" ) ] DiagnosticBuilder){
  |                                            ^^^^^^^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: DiagnosticBuilder`
  |
  = note: `#[warn(anonymous_parameters)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:810:21: no name for param # [ doc ( alias = "false" ) ] DiagnosticBuilder (hir_id=HirId { owner: DefId(0:4 ~ mutant[8787]::StructuredDiagnostic::extended), local_id: 1 })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1007:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::hir::map::Map::name
   8: rustc_passes::check_attr::CheckAttrVisitor::check_doc_alias_value
   9: rustc_passes::check_attr::CheckAttrVisitor::check_attributes
  10: rustc_hir::intravisit::walk_body
  11: rustc_hir::intravisit::walk_fn
  12: rustc_hir::intravisit::walk_trait_item
  13: rustc_middle::hir::map::Map::visit_item_likes_in_module
  14: rustc_passes::check_attr::check_mod_attrs
  15: rustc_query_system::query::plumbing::get_query_impl
  16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_attrs
  17: std::panic::catch_unwind
  18: rustc_session::utils::<impl rustc_session::session::Session>::time
  19: rustc_interface::passes::analysis
  20: rustc_query_system::query::plumbing::get_query_impl
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  22: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  23: rustc_span::with_source_map
  24: rustc_interface::interface::create_compiler_and_run
  25: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (0a8629bff 2021-06-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -Z new-llvm-pass-manager=yes -Z unsound-mir-opts=yes -Z polonius=yes -Z polymorphize=yes -C debuginfo=2 -C opt-level=3 --crate-type staticlib

query stack during panic:
#0 [check_mod_attrs] checking attributes in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0412`.

@Cancelll Cancelll added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2021
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 12, 2021
@steffahn
Copy link
Member

ICE only appears since 1.52. @rustbot label regression-from-stable-to-stable

@rustbot rustbot added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jun 12, 2021
@steffahn
Copy link
Member

steffahn commented Jun 12, 2021

Better-looking code example

trait Trait {
    fn method(#[doc(alias = "m")] _n: i32) {}
}

Bisection points to 9503ea1

Rollup of 11 pull requests

Successful merges:

 - #80523 (#[doc(inline)] sym_generated)
 - #80920 (Visit more targets when validating attributes)
 - #81720 (Updated smallvec version due to RUSTSEC-2021-0003)
 - #81891 ([rustdoc-json] Make `header` a vec of modifiers, and FunctionPointer consistent)
 - #81912 (Implement the precise analysis pass for lint `disjoint_capture_drop_reorder`)
 - #81914 (Fixing bad suggestion for `_` in `const` type when a function #81885)
 - #81919 (BTreeMap: fix internal comments)
 - #81927 (Add a regression test for #32498)
 - #81965 (Fix MIR pretty printer for non-local DefIds)
 - #82029 (Use debug log level for developer oriented logs)
 - #82056 (fix ice (#82032))

@steffahn
Copy link
Member

Reading the descriptions, I’d guess most likely #80920, cc @rylev.

@rylev
Copy link
Member

rylev commented Jun 15, 2021

This is indeed caused by #80920 since we're now checking parameters unlike before. The issue is in when checking that a doc alias is not the same name as the thing it is aliasing. The call to self.tcx.hir().name(hir_id); panics because there is no name for a param.

The question I have is whether we should support params for doc aliases. I didn't find anything in the tracking issue to indicate that it was supposed to be supported, and I personally don't think it makes sense. If we decide to not support doc aliases for params, then it should be an easy change to check_doc_alias_value to error when target is a rustc_hir::Target::Param.

cc @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

Doc aliases are only supported for items showing up in doc search, function parameters don't, so in this case, it should error on the doc alias attribute.

@GuillaumeGomez
Copy link
Member

Do you want to send a fix or should I?

@rylev
Copy link
Member

rylev commented Jun 15, 2021

@GuillaumeGomez I'll submit a fix.

@GuillaumeGomez
Copy link
Member

Thanks! Please ping me on it (and don't forget to add a test for it too ;) ).

@bors bors closed this as completed in 8daad74 Jun 16, 2021
@JohnTitor JohnTitor removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants