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: 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs #78651

Closed
chengniansun opened this issue Nov 2, 2020 · 12 comments · Fixed by #82087
Closed
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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

@chengniansun
Copy link

Code

use std::result;
impl result {
    fn into_future() -> Err {}
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (4f7612ac1 2020-10-31)
binary: rustc
commit-hash: 4f7612ac1499258025077f1fd05d2f429f9accfb
commit-date: 2020-10-31
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

error[E0573]: expected type, found module `result`
   --> reduced-mutant.rs:2:6
    |
2   |   impl result {
    |        ^^^^^^ help: an enum with a similar name exists: `Result`

error[E0573]: expected type, found variant `Err`
 --> reduced-mutant.rs:3:25
  |
3 |     fn into_future() -> Err {}
  |                         ^^^ not a type
  |
thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:173:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.49.0-nightly (4f7612ac1 2020-10-31) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error

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

error[E0573]: expected type, found module `result`
   --> reduced-mutant.rs:2:6
    |
2   |   impl result {
    |        ^^^^^^ help: an enum with a similar name exists: `Result`

error[E0573]: expected type, found variant `Err`
 --> reduced-mutant.rs:3:25
  |
3 |     fn into_future() -> Err {}
  |                         ^^^ not a type
  |
thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:173:9
stack backtrace:
   0: std::panicking::begin_panic
   1: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   2: rustc_errors::HandlerInner::emit_diagnostic
   3: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
   4: rustc_resolve::Resolver::resolve_crate
   5: rustc_interface::passes::configure_and_expand_inner
   6: rustc_interface::passes::configure_and_expand::{{closure}}
   7: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
   8: rustc_interface::passes::configure_and_expand
   9: rustc_interface::queries::Queries::expansion
  10: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  11: rustc_span::with_source_map
  12: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.49.0-nightly (4f7612ac1 2020-10-31) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error

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

NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses

@chengniansun chengniansun 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 Nov 2, 2020
@fanninpm
Copy link

Playground link of example

Can you confirm if this still ICEs with the latest nightly?

@chengniansun
Copy link
Author

$ rustc --verbose --version
rustc 1.50.0-nightly (f76ecd066 2020-12-15)
binary: rustc
commit-hash: f76ecd0668fcdb289456cdc72a39ad15467cc454
commit-date: 2020-12-15
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

$ rustc reduced-mutant.rs
error[E0573]: expected type, found module `result`
   --> reduced-mutant.rs:2:6
    |
2   |   impl result {
    |        ^^^^^^ help: an enum with a similar name exists: `Result`

error[E0573]: expected type, found variant `Err`
 --> reduced-mutant.rs:3:25
  |
3 |     fn into_future() -> Err {}
  |                         ^^^ not a type
  |
thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:151:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.50.0-nightly (f76ecd066 2020-12-15) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error

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

$ cat reduced-mutant.rs
use std::result;
impl result {
    fn into_future() -> Err {}
}
$

@fanninpm
Copy link

After further review, I can confirm that this does cause an ICE with rustc 1.50.0-nightly (f76ecd066 2020-12-15) on macOS 10.15. However, both the playground, running 1.50.0-nightly (2020-12-03 5be3f9f) as of this comment, and (for some weird reason) running glacier locally do not cause an ICE. I will note this in an upcoming PR to glacier.

fanninpm added a commit to fanninpm/glacier that referenced this issue Dec 17, 2020
Locally running `cargo run` and running `rustc` directly produced different
results.

Call rustc on 78651 directly instead of indirectly (through cargo).

Issue: rust-lang/rust#78651
fanninpm added a commit to fanninpm/glacier that referenced this issue Dec 19, 2020
Locally running `cargo run` and running `rustc` directly produced different
results.

Call rustc on 78651 directly instead of indirectly (through cargo).

Issue: rust-lang/rust#78651
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 20, 2020
@estebank
Copy link
Contributor

estebank commented Feb 12, 2021

I think this regression was introduced in https://github.com/rust-lang/rust/pull/72603/files#diff-7e4444c107c648eec7167c8fd88b2665cf1f6e68e2a77d7992001677c09dca81R534

tool_only_suggestion_with_metadata needs to be reworked to either have actual substitutions or remove the assertion and likely early return higher up to make sure that substitutions are present when emitting the diagnostic.

Edit: it was not introduced there, but I've found where it is coming from. It is because of an invalid suggestion with empty substitutions because we were filtering them away. PR incoming.

@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Feb 12, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 12, 2021
@osa1
Copy link
Contributor

osa1 commented Feb 15, 2021

I think there's another issue as I describe here: #82092 (comment)

Namely import_candidate_to_enum_paths doesn't work as advertised on paths like std::prelude::v1::Err, but it's still called on such paths.

Fixing that function (or the call site) would also fix this issue.

@apiraino
Copy link
Contributor

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@apiraino
Copy link
Contributor

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 17, 2021
@hameerabbasi
Copy link
Contributor

hameerabbasi commented Feb 17, 2021

The current nightly doesn't reproduce this:

$ cargo bisect-rustc --test-dir=. --start=2020-01-01 --regress=ice
...
ERROR: the end of the range (nightly-2021-02-17) does not reproduce the regression

I think just a testcase needs adding.

It happens only on Rust 2015.

@osa1
Copy link
Contributor

osa1 commented Feb 17, 2021

This still panics with current nightly ee88f46:

$ cat test.rs
use std::result;

impl result {
    fn into_future() -> Err {}
}

$ RUST_BACKTRACE=0 rustc +stage1 test.rs
error[E0573]: expected type, found module `result`
   --> test.rs:3:6
    |
3   | impl result {
    |      ^^^^^^ help: an enum with a similar name exists: `Result`
    |
   ::: /home/omer/rust/rust/library/core/src/result.rs:241:1
    |
241 | pub enum Result<T, E> {
    | --------------------- similarly named enum `Result` defined here

error[E0573]: expected type, found variant `Err`
 --> test.rs:4:25
  |
4 |     fn into_future() -> Err {}
  |                         ^^^ not a type
  |
thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:189:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.52.0-dev running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error

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

@hameerabbasi
Copy link
Contributor

hameerabbasi commented Feb 17, 2021

This is rather strange.

$ cargo bisect-rustc --test-dir=. --end=ee88f46bb5e27c4d9f30326e69ff2298dcbeecb1 --regress=ice
...
ERROR: the commit at the end of the range (ee88f46bb5e27c4d9f30326e69ff2298dcbeecb1) does not reproduce the regression
$ cargo build
   Compiling bisect v0.1.0 (/home/habbasi/bisect)
error[E0573]: expected type, found module `result`
   --> src/main.rs:2:6
    |
2   |   impl result {
    |        ^^^^^^ help: an enum with a similar name exists: `Result`

error[E0573]: expected type, found variant `Err`
 --> src/main.rs:3:25
  |
3 |     fn into_future() -> Err {}
  |                         ^^^ not a type
  |
help: try using the variant's enum
  |
3 |     fn into_future() -> core::result::Result {}
  |                         ^^^^^^^^^^^^^^^^^^^^
3 |     fn into_future() -> crate::result::Result {}
  |                         ^^^^^^^^^^^^^^^^^^^^^
3 |     fn into_future() -> std::result::Result {}
  |                         ^^^^^^^^^^^^^^^^^^^

error[E0601]: `main` function not found in crate `bisect`
 --> src/main.rs:1:1
  |
1 | / use std::result;
2 | | impl result {
3 | |     fn into_future() -> Err {}
4 | | }
  | |_^ consider adding a `main` function to `src/main.rs`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0573, E0601.
For more information about an error, try `rustc --explain E0573`.
error: could not compile `bisect`

To learn more, run the command again with --verbose.

Edit: It happens only when compiling with Rust 2015 edition.

@hameerabbasi
Copy link
Contributor

As stated in the edited message above, this ICE only happens on Rust 2015 edition.

********************************************************************************
Regression in nightly-2020-06-25
********************************************************************************

fetching https://static.rust-lang.org/dist/2020-06-24/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-06-24: 40 B / 40 B [================] 100.00 % 674.64 KB/s converted 2020-06-24 to ff5b446d2fdbd898bc97a751f2f72858de185cf1
fetching https://static.rust-lang.org/dist/2020-06-25/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-06-25: 40 B / 40 B [================] 100.00 % 689.42 KB/s converted 2020-06-25 to 67100f61e62a86f2bf9e38552ee138e231eddc74
looking for regression commit between 2020-06-24 and 2020-06-25
opening existing repository at "rust.git"
refreshing repository
fetching (via local git) commits from ff5b446d2fdbd898bc97a751f2f72858de185cf1 to 67100f61e62a86f2bf9e38552ee138e231eddc74
opening existing repository at "rust.git"
refreshing repository
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 6 bors merge commits in the specified range
  commit[0] 2020-06-23UTC: Auto merge of #73644 - ollie27:rustdoc_alias_filter, r=GuillaumeGomez
  commit[1] 2020-06-23UTC: Auto merge of #73669 - Manishearth:rollup-0n4u7vq, r=Manishearth
  commit[2] 2020-06-24UTC: Auto merge of #73293 - Aaron1011:feature/macro-rules-arg-capture, r=petrochenkov
  commit[3] 2020-06-24UTC: Auto merge of #73679 - ehuss:update-cargo, r=ehuss
  commit[4] 2020-06-24UTC: Auto merge of #73692 - Dylan-DPC:rollup-ehzsbfw, r=Dylan-DPC
  commit[5] 2020-06-24UTC: Auto merge of #73660 - flip1995:clippyup, r=nikomatsakis
ERROR: no commits between ff5b446d2fdbd898bc97a751f2f72858de185cf1 and 67100f61e62a86f2bf9e38552ee138e231eddc74 within last 167 days

@estebank
Copy link
Contributor

The problem is an empty suggestion, #82087 fixes this.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 25, 2021
Fix ICE caused by suggestion with no code substitutions

Change suggestion logic to filter and checking _before_ creating
specific resolution suggestion.

Assert earlier that suggestions contain code substitions to make it
easier in the future to debug invalid uses. If we find this becomes too
noisy in the wild, we can always make the emitter resilient to these
cases and remove the assertions.

Fix rust-lang#78651.
@bors bors closed this as completed in 04c2454 Feb 25, 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. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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.

8 participants