Skip to content

Generic parameter to async function causes ICE #9504

Closed
@djkoloski

Description

@djkoloski

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions