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

Self/#0` (Self/0) out of range when substituting, substs=[] #9852

Closed
yaleman opened this issue Nov 15, 2022 · 4 comments
Closed

Self/#0` (Self/0) out of range when substituting, substs=[] #9852

yaleman opened this issue Nov 15, 2022 · 4 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@yaleman
Copy link

yaleman commented Nov 15, 2022

Summary

Found the offending code, which I have posted here: https://github.com/yaleman/clippy-2022-11-15/blob/main/src/lib.rs

If you change either of the clone calls to to_owned the bug appears.

good:

use std::path::PathBuf;
use std::str::FromStr;

use axum_server::tls_rustls::RustlsConfig;

pub async fn get_tls_config() -> Result<RustlsConfig, std::io::Error> {
    let testval1 = PathBuf::from_str("/test").unwrap();
    let testval2 = PathBuf::from_str("/test").unwrap();

    RustlsConfig::from_pem_file(testval1.clone(), testval2.clone()).await
}

bad:

use std::path::PathBuf;
use std::str::FromStr;

use axum_server::tls_rustls::RustlsConfig;

pub async fn get_tls_config() -> Result<RustlsConfig, std::io::Error> {
    let testval1 = PathBuf::from_str("/test").unwrap();
    let testval2 = PathBuf::from_str("/test").unwrap();

    RustlsConfig::from_pem_file(testval1.to_owned(), testval2.clone()).await
}

Version

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: aarch64-apple-darwin
release: 1.65.0
LLVM version: 15.0.0

Error output

Backtrace

➜ RUST_BACKTRACE=full cargo clippy
  Checking clippy-2022-11-15 v0.1.0 (/Users/yaleman/Projects/clippy-2022-11-15)
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:        0x1054db670 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2990a6f24ccff6db
 1:        0x105525c34 - core::fmt::write::h91497fd291c8b104
 2:        0x1054ce604 - std::io::Write::write_fmt::h23fa41342cffacf4
 3:        0x1054ddeec - std::panicking::default_hook::{{closure}}::hb41cdb784f4c17ac
 4:        0x1054ddc10 - std::panicking::default_hook::hdfe992d5fb29a991
 5:        0x10424dc3c - clippy_driver[3d26af9ed3b5abdc]::ICE_HOOK::{closure#0}::{closure#0}
 6:        0x1054de5b0 - std::panicking::rust_panic_with_hook::h2eb0e4b718773521
 7:        0x110eac1f4 - std[a5ccfe66677bd8c7]::panicking::begin_panic::<rustc_errors[c8454b970e154417]::ExplicitBug>::{closure#0}
 8:        0x110eaa77c - std[a5ccfe66677bd8c7]::sys_common::backtrace::__rust_end_short_backtrace::<std[a5ccfe66677bd8c7]::panicking::begin_panic<rustc_errors[c8454b970e154417]::ExplicitBug>::{closure#0}, !>
 9:        0x1113b6f48 - std[a5ccfe66677bd8c7]::panicking::begin_panic::<rustc_errors[c8454b970e154417]::ExplicitBug>
10:        0x110e0f904 - std[a5ccfe66677bd8c7]::panic::panic_any::<rustc_errors[c8454b970e154417]::ExplicitBug>
11:        0x110e0c34c - <rustc_errors[c8454b970e154417]::HandlerInner>::bug::<&alloc[3ba61535766dd904]::string::String>
12:        0x110e0bc50 - <rustc_errors[c8454b970e154417]::Handler>::bug::<&alloc[3ba61535766dd904]::string::String>
13:        0x110f38640 - rustc_middle[a5107c7538e61c53]::ty::context::tls::with_context_opt::<rustc_middle[a5107c7538e61c53]::ty::context::tls::with_opt<rustc_middle[a5107c7538e61c53]::util::bug::opt_span_bug_fmt<rustc_span[b9fdb1d50c47c7fe]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
14:        0x110f3c994 - rustc_middle[a5107c7538e61c53]::util::bug::opt_span_bug_fmt::<rustc_span[b9fdb1d50c47c7fe]::span_encoding::Span>
15:        0x1113b7e40 - rustc_middle[a5107c7538e61c53]::util::bug::bug_fmt
16:        0x1113b8088 - <rustc_middle[a5107c7538e61c53]::ty::subst::SubstFolder>::type_param_out_of_range
17:        0x110f5ba70 - <rustc_middle[a5107c7538e61c53]::ty::subst::SubstFolder as rustc_middle[a5107c7538e61c53]::ty::fold::TypeFolder>::fold_ty
18:        0x104417f70 - <&rustc_middle[a5107c7538e61c53]::ty::list::List<rustc_middle[a5107c7538e61c53]::ty::subst::GenericArg> as rustc_middle[a5107c7538e61c53]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[a5107c7538e61c53]::ty::subst::SubstFolder>
19:        0x104395034 - <rustc_middle[a5107c7538e61c53]::ty::PredicateKind as rustc_middle[a5107c7538e61c53]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[a5107c7538e61c53]::ty::subst::SubstFolder>
20:        0x1044154e4 - <rustc_middle[a5107c7538e61c53]::ty::subst::SubstFolder as rustc_middle[a5107c7538e61c53]::ty::fold::FallibleTypeFolder>::try_fold_binder::<rustc_middle[a5107c7538e61c53]::ty::PredicateKind>
21:        0x1042dd72c - <core[75a5a00debbb3d3d]::iter::adapters::copied::Copied<core[75a5a00debbb3d3d]::slice::iter::Iter<rustc_middle[a5107c7538e61c53]::ty::Predicate>> as core[75a5a00debbb3d3d]::iter::traits::iterator::Iterator>::try_fold::<(), core[75a5a00debbb3d3d]::iter::adapters::filter::filter_try_fold<rustc_middle[a5107c7538e61c53]::ty::Predicate, (), core[75a5a00debbb3d3d]::ops::control_flow::ControlFlow<()>, clippy_lints[42ea88bd058be92]::methods::unnecessary_to_owned::can_change_type::{closure#5}, core[75a5a00debbb3d3d]::iter::traits::iterator::Iterator::any::check<rustc_middle[a5107c7538e61c53]::ty::Predicate, clippy_lints[42ea88bd058be92]::methods::unnecessary_to_owned::can_change_type::{closure#7}>::{closure#0}>::{closure#0}, core[75a5a00debbb3d3d]::ops::control_flow::ControlFlow<()>>
22:        0x1044b43bc - clippy_lints[42ea88bd058be92]::methods::unnecessary_to_owned::can_change_type
23:        0x1044b3864 - clippy_lints[42ea88bd058be92]::methods::unnecessary_to_owned::check
24:        0x1043ca904 - <clippy_lints[42ea88bd058be92]::methods::Methods as rustc_lint[aa6378de71b85db]::passes::LateLintPass>::check_expr
25:        0x110b85220 - <rustc_lint[aa6378de71b85db]::late::LateLintPassObjects as rustc_lint[aa6378de71b85db]::passes::LateLintPass>::check_expr
26:        0x10d327794 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
27:        0x10d3277a0 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
28:        0x10d327b68 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
29:        0x10d322dcc - rustc_hir[db6588c2747fedc8]::intravisit::walk_block::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
30:        0x10d3274b8 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
31:        0x10d327318 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
32:        0x10d322dcc - rustc_hir[db6588c2747fedc8]::intravisit::walk_block::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
33:        0x10d3274b8 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
34:        0x10d3270ac - rustc_hir[db6588c2747fedc8]::intravisit::walk_body::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
35:        0x10d38332c - <rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects> as rustc_hir[db6588c2747fedc8]::intravisit::Visitor>::visit_nested_body
36:        0x10d327ce8 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
37:        0x10d3277a0 - rustc_hir[db6588c2747fedc8]::intravisit::walk_expr::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
38:        0x10d3270ac - rustc_hir[db6588c2747fedc8]::intravisit::walk_body::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
39:        0x10d38332c - <rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects> as rustc_hir[db6588c2747fedc8]::intravisit::Visitor>::visit_nested_body
40:        0x10d328f68 - rustc_hir[db6588c2747fedc8]::intravisit::walk_item::<rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>>
41:        0x10d3838f8 - <rustc_lint[aa6378de71b85db]::late::LateContextAndPass<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects> as rustc_hir[db6588c2747fedc8]::intravisit::Visitor>::visit_nested_item
42:        0x10d382a48 - rustc_lint[aa6378de71b85db]::late::late_lint_pass_crate::<rustc_lint[aa6378de71b85db]::late::LateLintPassObjects>
43:        0x10d3822e4 - rustc_lint[aa6378de71b85db]::late::late_lint_crate::<rustc_lint[aa6378de71b85db]::BuiltinCombinedLateLintPass>
44:        0x10d353538 - <rustc_session[d9f8ead3a6f8da8f]::session::Session>::time::<(), rustc_lint[aa6378de71b85db]::late::check_crate<rustc_lint[aa6378de71b85db]::BuiltinCombinedLateLintPass, rustc_interface[64ac8d545596c047]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
45:        0x10d35394c - <rustc_session[d9f8ead3a6f8da8f]::session::Session>::time::<(), rustc_interface[64ac8d545596c047]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
46:        0x10d39b528 - <core[75a5a00debbb3d3d]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[64ac8d545596c047]::passes::analysis::{closure#5}::{closure#1}> as core[75a5a00debbb3d3d]::ops::function::FnOnce<()>>::call_once
47:        0x10d355de0 - <rustc_session[d9f8ead3a6f8da8f]::session::Session>::time::<(), rustc_interface[64ac8d545596c047]::passes::analysis::{closure#5}>
48:        0x10d351188 - rustc_interface[64ac8d545596c047]::passes::analysis
49:        0x11040e0ec - <rustc_query_system[376554ccb6bbe62f]::dep_graph::graph::DepGraph<rustc_middle[a5107c7538e61c53]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a5107c7538e61c53]::ty::context::TyCtxt, (), core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
50:        0x11021c000 - rustc_query_system[376554ccb6bbe62f]::query::plumbing::try_execute_query::<rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt, rustc_query_system[376554ccb6bbe62f]::query::caches::DefaultCache<(), core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>>
51:        0x11028302c - rustc_query_system[376554ccb6bbe62f]::query::plumbing::get_query::<rustc_query_impl[ebd438b5e01d582b]::queries::analysis, rustc_query_impl[ebd438b5e01d582b]::plumbing::QueryCtxt>
52:        0x10d273054 - <rustc_interface[64ac8d545596c047]::passes::QueryContext>::enter::<rustc_driver[250dcea03822790c]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
53:        0x10d2481b4 - rustc_interface[64ac8d545596c047]::interface::create_compiler_and_run::<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>
54:        0x10d2ab5e0 - <scoped_tls[1c31aea71029b747]::ScopedKey<rustc_span[b9fdb1d50c47c7fe]::SessionGlobals>>::set::<rustc_interface[64ac8d545596c047]::interface::run_compiler<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
55:        0x10d276dc8 - std[a5ccfe66677bd8c7]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[64ac8d545596c047]::util::run_in_thread_pool_with_globals<rustc_interface[64ac8d545596c047]::interface::run_compiler<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>
56:        0x10d279c4c - <<std[a5ccfe66677bd8c7]::thread::Builder>::spawn_unchecked_<rustc_interface[64ac8d545596c047]::util::run_in_thread_pool_with_globals<rustc_interface[64ac8d545596c047]::interface::run_compiler<core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>, rustc_driver[250dcea03822790c]::run_compiler::{closure#1}>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>::{closure#0}, core[75a5a00debbb3d3d]::result::Result<(), rustc_errors[c8454b970e154417]::ErrorGuaranteed>>::{closure#1} as core[75a5a00debbb3d3d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
57:        0x1054e6428 - std::sys::unix::thread::Thread::new::thread_start::hf682c03d0f237892
58:        0x1805e826c - __pthread_deallocate

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 `clippy-2022-11-15`

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

yaleman commented Nov 15, 2022

Updated this from the original report because I found a minimal example..

@smoelius
Copy link
Contributor

I can reproduce the ICE with cargo clippy, but not with cargo +nightly clippy.

I suspect this was fixed by #9505.

@yaleman
Copy link
Author

yaleman commented Nov 16, 2022

That does look like it's sorted in nightly, thanks!

@giraffate
Copy link
Contributor

Thanks for the report!

I'm closing this because of #9852 (comment).

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

No branches or pull requests

3 participants