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

Generic parameter to async function causes ICE #9504

Closed
djkoloski opened this issue Sep 21, 2022 · 1 comment · Fixed by #9505
Closed

Generic parameter to async function causes ICE #9504

djkoloski opened this issue Sep 21, 2022 · 1 comment · Fixed by #9505
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@djkoloski
Copy link

Summary

Minimal repro:

// lib.rs
async fn foo<S: AsRef<str>>(_: S) {}
async fn bar() {
    foo(std::path::PathBuf::new().to_string_lossy().to_string()).await;
}

Output:

$ cargo +nightly clippy
error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:687:9: type parameter `Self/#0` (Self/0) out of range when substituting, substs=[]

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/432abd86f231c908f6df3cdd779e83f35084be90/compiler/rustc_errors/src/lib.rs:1462: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-clippy/issues/new

note: Clippy version: clippy 0.1.65 (432abd8 2022-09-20)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack

cargo +nightly build succeeds with the same input, as does cargo clippy (on stable).

Version

rustc 1.66.0-nightly (432abd86f 2022-09-20)
binary: rustc
commit-hash: 432abd86f231c908f6df3cdd779e83f35084be90
commit-date: 2022-09-20
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Error output

Backtrace

warning: function `foo` is never used
--> src/lib.rs:1:10
|
1 | async fn foo<S: AsRef<str>>(_: S) {}
|          ^^^
|
= note: `#[warn(dead_code)]` on by default

warning: function `bar` is never used
--> src/lib.rs:3:10
|
3 | async fn bar() {
|          ^^^

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:687:9: type parameter `Self/#0` (Self/0) out of range when substituting, substs=[]

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/432abd86f231c908f6df3cdd779e83f35084be90/compiler/rustc_errors/src/lib.rs:1462: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-clippy/issues/new

note: Clippy version: clippy 0.1.65 (432abd8 2022-09-20)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
warning: `clippy-repro` (lib) generated 2 warnings
error: could not compile `clippy-repro`; 2 warnings emitted

@djkoloski djkoloski added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Sep 21, 2022
@ghost
Copy link

ghost commented Sep 21, 2022

This is caused by #9424. It looks like the compiler generated call to into_future doesn't have substs we need to check predicates. I'm working on fix that will just exit when it encounters these.

Thanks for the minimal repro.

bors added a commit that referenced this issue Sep 21, 2022
Fix ICE in `unnecessary_to_owned`

Fixes #9504

Compiler generated call `into_future` nodes return empty substs which we need when checking it's predicates. Handle this by simply exitting when we encounter one. This change introduces false negatives in place of the ICEs.

changelog: [`unnecessary_to_owned`]: fix ICE
@bors bors closed this as completed in a783d54 Sep 21, 2022
bors added a commit that referenced this issue Dec 29, 2023
Remove mitigations for incorrect node args

This change https://github.com/rust-lang/rust/pull/118420/files#r1419874371 adds a missing `write_args` to properly record node args for lang-item calls.

Thus, in the `unnecessary_to_owned` lint, this ensures that the `call_generic_args` extracted by `get_callee_generic_args_and_args` are always correct, and we can remove the mitigation for #9504 and #10021 since the root cause has been fixed.

I'm not sure if there is other now-unnecessary code that can be removed, but this is the one I found when investigating #11965 (comment).

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant