Skip to content

Type parameter Self/#0 out of range when substituting #9781

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

Closed
nickgerace opened this issue Nov 3, 2022 · 6 comments
Closed

Type parameter Self/#0 out of range when substituting #9781

nickgerace opened this issue Nov 3, 2022 · 6 comments

Comments

@nickgerace
Copy link

nickgerace commented Nov 3, 2022

Using rustup on stable-aarch64-apple-darwin, I upgraded to Rust 1.65. Upon running cargo clean and fixing new clippy warnings (there were many, so it would be may to pin down a trigger, if applicable), I ran the following commands:

cargo clean # success
cargo build --all-targets # success
cargo clippy --no-deps --all-targets # fails with error below

The last command produces the following error:

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

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/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 (897e3755 2022-11-02)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `redacted-crate-name`
warning: build failed, waiting for other jobs to finish...

Since the message recommended that I file a bug... here I am!

EDIT 1: the --all-targets flag appears to be the trigger.

EDIT 2: the issue appears to happen on both Linux (unknown-gnu) amd64 and macOS aarch64 systems using the corresponding their corresponding stable toolchains.

nickgerace added a commit to systeminit/si that referenced this issue Nov 3, 2022
The post fix intelligence test for resource is currently failing due to
a known bug. This test is being added with the "ignore" macro so that
others can use it.

The three regression tests should currently pass and provide a baseline
for testing in the future. They can (and likely should) be expanded to
account for multiple scenarios.

Finally, fix clippy lints due to Rust 1.65's release. Disable the
"all-targets" flag temporarily until the following issue is resolved:
rust-lang/rust-clippy#9781

Signed-off-by: Nick Gerace <[email protected]>
Co-authored-by: Fletcher Nichol <[email protected]>
nickgerace added a commit to systeminit/si that referenced this issue Nov 3, 2022
The post fix intelligence test for resource is currently failing due to
a known bug. This test is being added with the "ignore" macro so that
others can use it.

The three regression tests should currently pass and provide a baseline
for testing in the future. They can (and likely should) be expanded to
account for multiple scenarios.

Finally, fix clippy lints due to Rust 1.65's release. Disable the
"all-targets" flag temporarily until the following issue is resolved:
rust-lang/rust-clippy#9781

Signed-off-by: Nick Gerace <[email protected]>
Co-authored-by: Fletcher Nichol <[email protected]>
@zacharyhamm
Copy link

zacharyhamm commented Nov 3, 2022

Seeing this as well. Here's a full backtrace

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

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/compiler/rustc_errors/src/lib.rs:1462:9
stack backtrace:
   0:     0x7f77f7241d40 - std::backtrace_rs::backtrace::libunwind::trace::h32eb3e08e874dd27
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f77f7241d40 - std::backtrace_rs::backtrace::trace_unsynchronized::haa3f451d27bc11a5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f77f7241d40 - std::sys_common::backtrace::_print_fmt::h5b94a01bb4289bb5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f77f7241d40 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb070b7fa7e3175df
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f77f729cbfe - core::fmt::write::hd5207aebbb9a86e9
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f77f7232935 - std::io::Write::write_fmt::h3bd699bbd129ab8a
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/io/mod.rs:1679:15
   6:     0x7f77f72449f3 - std::sys_common::backtrace::_print::h7a21be552fdf58da
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f77f72449f3 - std::sys_common::backtrace::print::ha85c41fe4dd80b13
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f77f72449f3 - std::panicking::default_hook::{{closure}}::h04cca40023d0eeca
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:295:22
   9:     0x7f77f72446df - std::panicking::default_hook::haa3ca8c310ed5402
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:314:9
  10:     0x560f7228c8af - clippy_driver[8edfe2ebdb33510b]::ICE_HOOK::{closure#0}::{closure#0}
  11:     0x7f77f724522d - std::panicking::rust_panic_with_hook::h7b190ce1a948faac
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:702:17
  12:     0x7f77fa9f8e51 - std[71cb4861428b0c25]::panicking::begin_panic::<rustc_errors[f77a66b68db622d5]::ExplicitBug>::{closure#0}
  13:     0x7f77fa9f6966 - std[71cb4861428b0c25]::sys_common::backtrace::__rust_end_short_backtrace::<std[71cb4861428b0c25]::panicking::begin_panic<rustc_errors[f77a66b68db622d5]::ExplicitBug>::{closure#0}, !>
  14:     0x7f77faa50316 - std[71cb4861428b0c25]::panicking::begin_panic::<rustc_errors[f77a66b68db622d5]::ExplicitBug>
  15:     0x7f77fa9f35f6 - std[71cb4861428b0c25]::panic::panic_any::<rustc_errors[f77a66b68db622d5]::ExplicitBug>
  16:     0x7f77fa9f21dd - <rustc_errors[f77a66b68db622d5]::HandlerInner>::bug::<&alloc[188ed69dc0d14b4b]::string::String>
  17:     0x7f77fa9f1c10 - <rustc_errors[f77a66b68db622d5]::Handler>::bug::<&alloc[188ed69dc0d14b4b]::string::String>
  18:     0x7f77faaae7ed - rustc_middle[a9ca1c3f9fd197cd]::ty::context::tls::with_context_opt::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::tls::with_opt<rustc_middle[a9ca1c3f9fd197cd]::util::bug::opt_span_bug_fmt<rustc_span[8f00505efff112e2]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7f77faab1c86 - rustc_middle[a9ca1c3f9fd197cd]::util::bug::opt_span_bug_fmt::<rustc_span[8f00505efff112e2]::span_encoding::Span>
  20:     0x7f77f844fa83 - rustc_middle[a9ca1c3f9fd197cd]::util::bug::bug_fmt
  21:     0x7f77faac76b2 - <rustc_middle[a9ca1c3f9fd197cd]::ty::subst::SubstFolder>::type_param_out_of_range
  22:     0x7f77f838a687 - <rustc_middle[a9ca1c3f9fd197cd]::ty::subst::SubstFolder as rustc_middle[a9ca1c3f9fd197cd]::ty::fold::TypeFolder>::fold_ty
  23:     0x560f724a2be8 - <&rustc_middle[a9ca1c3f9fd197cd]::ty::list::List<rustc_middle[a9ca1c3f9fd197cd]::ty::subst::GenericArg> as rustc_middle[a9ca1c3f9fd197cd]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[a9ca1c3f9fd197cd]::ty::subst::SubstFolder>
  24:     0x560f7240a369 - <rustc_middle[a9ca1c3f9fd197cd]::ty::PredicateKind as rustc_middle[a9ca1c3f9fd197cd]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[a9ca1c3f9fd197cd]::ty::subst::SubstFolder>
  25:     0x560f7249fb36 - <rustc_middle[a9ca1c3f9fd197cd]::ty::subst::SubstFolder as rustc_middle[a9ca1c3f9fd197cd]::ty::fold::FallibleTypeFolder>::try_fold_binder::<rustc_middle[a9ca1c3f9fd197cd]::ty::PredicateKind>
  26:     0x560f722e3630 - <core[8c92e53db3fc2eaa]::iter::adapters::copied::Copied<core[8c92e53db3fc2eaa]::slice::iter::Iter<rustc_middle[a9ca1c3f9fd197cd]::ty::Predicate>> as core[8c92e53db3fc2eaa]::iter::traits::iterator::Iterator>::try_fold::<(), core[8c92e53db3fc2eaa]::iter::adapters::filter::filter_try_fold<rustc_middle[a9ca1c3f9fd197cd]::ty::Predicate, (), core[8c92e53db3fc2eaa]::ops::control_flow::ControlFlow<()>, clippy_lints[641d7bf63abf0cc3]::methods::unnecessary_to_owned::can_change_type::{closure#5}, core[8c92e53db3fc2eaa]::iter::traits::iterator::Iterator::any::check<rustc_middle[a9ca1c3f9fd197cd]::ty::Predicate, clippy_lints[641d7bf63abf0cc3]::methods::unnecessary_to_owned::can_change_type::{closure#7}>::{closure#0}>::{closure#0}, core[8c92e53db3fc2eaa]::ops::control_flow::ControlFlow<()>>
  27:     0x560f72559d04 - clippy_lints[641d7bf63abf0cc3]::methods::unnecessary_to_owned::can_change_type
  28:     0x560f72558b5f - clippy_lints[641d7bf63abf0cc3]::methods::unnecessary_to_owned::check
  29:     0x560f72448d4b - <clippy_lints[641d7bf63abf0cc3]::methods::Methods as rustc_lint[dab68e85e8b6d341]::passes::LateLintPass>::check_expr
  30:     0x7f77fa83c954 - <rustc_lint[dab68e85e8b6d341]::early::EarlyLintPassObjects as rustc_lint[dab68e85e8b6d341]::passes::EarlyLintPass>::check_generic_arg
  31:     0x7f77f9b36643 - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  32:     0x7f77f9b39305 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_expr::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  33:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  34:     0x7f77f9b39305 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_expr::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  35:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  36:     0x7f77f9b393e6 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_expr::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  37:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  38:     0x7f77f9b3933a - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_expr::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  39:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  40:     0x7f77f9b37fdb - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_local::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  41:     0x7f77f9b3681e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_local
  42:     0x7f77f9b37f8a - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_block::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  43:     0x7f77f9b36799 - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_block
  44:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  45:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  46:     0x7f77f9b36799 - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_block
  47:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  48:     0x7f77f9b36adc - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_nested_body
  49:     0x7f77f9b36cd9 - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_fn
  50:     0x7f77f9b39472 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_expr::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  51:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  52:     0x7f77f9b39305 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_expr::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  53:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  54:     0x7f77f9b36adc - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_nested_body
  55:     0x7f77f9b36cd9 - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_fn
  56:     0x7f77f9b3962d - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_item::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  57:     0x7f77f9b375de - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_nested_item
  58:     0x7f77f9b37f8a - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_block::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  59:     0x7f77f9b36799 - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_block
  60:     0x7f77f9b3664e - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  61:     0x7f77f9b36adc - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_nested_body
  62:     0x7f77f9b36cd9 - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_fn
  63:     0x7f77f9b3962d - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_item::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  64:     0x7f77f9b375de - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_nested_item
  65:     0x7f77f9b38f27 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_mod::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  66:     0x7f77f9b375de - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_nested_item
  67:     0x7f77f9b38f27 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_mod::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  68:     0x7f77f9b375de - <rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects> as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_nested_item
  69:     0x7f77f9b38f27 - rustc_hir[f29014e7b3f8eb6c]::intravisit::walk_mod::<rustc_lint[dab68e85e8b6d341]::late::LateContextAndPass<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>>
  70:     0x7f77f9b36563 - rustc_lint[dab68e85e8b6d341]::late::late_lint_pass_crate::<rustc_lint[dab68e85e8b6d341]::late::LateLintPassObjects>
  71:     0x7f77f8deb511 - rustc_lint[dab68e85e8b6d341]::late::late_lint_crate::<rustc_lint[dab68e85e8b6d341]::BuiltinCombinedLateLintPass>
  72:     0x7f77f8de9ad6 - <rustc_session[c5946fac61f8bc34]::session::Session>::time::<(), rustc_lint[dab68e85e8b6d341]::late::check_crate<rustc_lint[dab68e85e8b6d341]::BuiltinCombinedLateLintPass, rustc_interface[3182dd864eff9d7d]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
  73:     0x7f77f8de99d9 - <rustc_session[c5946fac61f8bc34]::session::Session>::time::<(), rustc_interface[3182dd864eff9d7d]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
  74:     0x7f77f8de97cf - <core[8c92e53db3fc2eaa]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[3182dd864eff9d7d]::passes::analysis::{closure#5}::{closure#1}> as core[8c92e53db3fc2eaa]::ops::function::FnOnce<()>>::call_once
  75:     0x7f77f8de8d9a - <rustc_session[c5946fac61f8bc34]::session::Session>::time::<(), rustc_interface[3182dd864eff9d7d]::passes::analysis::{closure#5}>
  76:     0x7f77f8de4cbc - rustc_interface[3182dd864eff9d7d]::passes::analysis
  77:     0x7f77f9843382 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, (), core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  78:     0x7f77f9842a4a - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<(), core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>>
  79:     0x7f77f9842517 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::analysis, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  80:     0x7f77f892e897 - <rustc_interface[3182dd864eff9d7d]::passes::QueryContext>::enter::<rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  81:     0x7f77f892228c - rustc_interface[3182dd864eff9d7d]::interface::create_compiler_and_run::<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>
  82:     0x7f77f8920ac1 - <scoped_tls[e395fa6e23b19669]::ScopedKey<rustc_span[8f00505efff112e2]::SessionGlobals>>::set::<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  83:     0x7f77f89207af - std[71cb4861428b0c25]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  84:     0x7f77f98d5d70 - <<std[71cb4861428b0c25]::thread::Builder>::spawn_unchecked_<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#1} as core[8c92e53db3fc2eaa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  85:     0x7f77f724f003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49f797984e2121bf
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  86:     0x7f77f724f003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfa4f3d0ee6440e0b
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  87:     0x7f77f724f003 - std::sys::unix::thread::Thread::new::thread_start::h62ca48b42d48a8fc
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys/unix/thread.rs:108:17
  88:     0x7f77f6ed0822 - start_thread
  89:     0x7f77f6e70450 - clone3
  90:                0x0 - <unknown>

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 (897e375 2022-11-02)

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

@nickgerace
Copy link
Author

nickgerace commented Nov 3, 2022

Potentially related issue: #9746
(thanks for finding this, @fnichol)

@zacharyhamm
Copy link

zacharyhamm commented Nov 3, 2022

Ok I got a minimal reproduction of this issue. With tokio version 1 (features = full):

async fn str_as_ref(a: impl AsRef<str>) {}

#[tokio::main]
async fn main() {
    str_as_ref("b".to_string()).await;
}

gives me:

$ cargo clippy
    Checking to_owned v0.1.0 (/Users/zacharyhamm/to_owned)
warning: unused variable: `a`
 --> src/main.rs:1:21
  |
1 | async fn str_as_ref(a: impl AsRef<str>) {}
  |                     ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

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

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/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 (897e3755 2022-11-02)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
warning: `to_owned` (bin "to_owned") generated 1 warning
error: could not compile `to_owned`; 1 warning emitted

Here's the Cargo.toml:

[package]
name = "to_owned"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1", features = ["full"] }

Edited to narrow down the issue further. Definitely only happens with the async fn.

Clippy version is:

clippy 0.1.65 (897e3755 2022-11-02)

What's interesting as well is that running the nightly clippy (clippy 0.1.66 (edf01822 2022-11-02)) does not show a lint at all for calling to_string on the argument passed to impl AsRef<str>:

warning: unused variable: `a`
 --> src/main.rs:1:21
  |
1 | async fn str_as_ref(a: impl AsRef<str>) {}
  |                     ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: `to_owned` (bin "to_owned") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

@Porges
Copy link

Porges commented Nov 4, 2022

Also hit this (see linked PR), I think invoking a fn(impl AsRef<Path>) from an async function (but I haven't looked deeply into it yet).

@Porges
Copy link

Porges commented Nov 9, 2022

I tried adding a test on latest master using @zacharyhamm’s repro but it doesn’t seem to fail there.

@flip1995
Copy link
Member

Duplicate of #9504

The fix for this hasn't made it to stable yet. From a quick check, it should be in beta and should get into 1.66 stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants