Closed
Description
Code
fn main() {
fn set_strength(&mut self, new_strength: T) {
}
trait Self {
}
}
Meta
rustc --version --verbose
:
rustc 1.79.0-nightly (79424056b 2024-04-12)
binary: rustc
commit-hash: 79424056b05eaa9563d16dfab9b9a0c8f033f220
commit-date: 2024-04-12
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3
Error output
error: expected identifier, found keyword `Self`
--> src/main.rs:9:11
|
9 | trait Self {
| ^^^^ expected identifier, found keyword
error: `self` parameter is only allowed in associated functions
--> src/main.rs:6:21
|
6 | fn set_strength(&mut self, new_strength: T) {
| ^^^^^^^^^ not semantically valid as function parameter
|
= note: associated functions are those in `impl` or `trait` definitions
error[E0412]: cannot find type `T` in this scope
--> src/main.rs:6:46
|
6 | fn set_strength(&mut self, new_strength: T) {
| ^ not found in this scope
|
help: you might be missing a type parameter
|
6 | fn set_strength<T>(&mut self, new_strength: T) {
| +++
error: internal compiler error: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1882:18: unexpected resolution: Def(Trait, DefId(0:5 ~ hello[3c53]::main::Self))
--> src/main.rs:6:26
|
6 | fn set_strength(&mut self, new_strength: T) {
| ^^^^
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1882:18:
Box<dyn Any>
stack backtrace:
0: 0x7f030e95ec05 - std::backtrace_rs::backtrace::libunwind::trace::h55fda353153fba83
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x7f030e95ec05 - std::backtrace_rs::backtrace::trace_unsynchronized::hd6863035e9fd170d
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f030e95ec05 - std::sys_common::backtrace::_print_fmt::hb008a4c9b6a56579
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7f030e95ec05 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hebe97ff020297e4b
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f030e9adf3b - core::fmt::rt::Argument::fmt::h080027bd1f8ad132
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/core/src/fmt/rt.rs:142:9
5: 0x7f030e9adf3b - core::fmt::write::hd145bb79142a862b
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/core/src/fmt/mod.rs:1153:17
6: 0x7f030e95378f - std::io::Write::write_fmt::hcf9a0a231c034c04
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/io/mod.rs:1832:15
7: 0x7f030e95e9de - std::sys_common::backtrace::_print::h103adc9b0aea227e
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f030e95e9de - std::sys_common::backtrace::print::h9e47c46d0ba15a0f
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f030e961359 - std::panicking::default_hook::{{closure}}::h02a180ea11cac171
10: 0x7f030e96109d - std::panicking::default_hook::hfc2680b73215b484
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/panicking.rs:291:9
11: 0x7f0311a75aec - std[c8275a09eb24d4c6]::panicking::update_hook::<alloc[421aab07a607723c]::boxed::Box<rustc_driver_impl[69898ae479fe711b]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7f030e961a5c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd3937552e00b1318
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/alloc/src/boxed.rs:2032:9
13: 0x7f030e961a5c - std::panicking::rust_panic_with_hook::hb8ccdf030b0c5d6d
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/panicking.rs:792:13
14: 0x7f0311aa5124 - std[c8275a09eb24d4c6]::panicking::begin_panic::<rustc_errors[faa9e1467089e630]::ExplicitBug>::{closure#0}
15: 0x7f0311aa2046 - std[c8275a09eb24d4c6]::sys_common::backtrace::__rust_end_short_backtrace::<std[c8275a09eb24d4c6]::panicking::begin_panic<rustc_errors[faa9e1467089e630]::ExplicitBug>::{closure#0}, !>
16: 0x7f0311aa1d26 - std[c8275a09eb24d4c6]::panicking::begin_panic::<rustc_errors[faa9e1467089e630]::ExplicitBug>
17: 0x7f0311aae311 - <rustc_errors[faa9e1467089e630]::diagnostic::BugAbort as rustc_errors[faa9e1467089e630]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x7f0311b23478 - <rustc_errors[faa9e1467089e630]::DiagCtxt>::span_bug::<rustc_span[24393b7d9aa35d24]::span_encoding::Span, alloc[421aab07a607723c]::string::String>
19: 0x7f0311b5e09d - rustc_middle[3536e66dcc7db89e]::util::bug::opt_span_bug_fmt::<rustc_span[24393b7d9aa35d24]::span_encoding::Span>::{closure#0}
20: 0x7f0311b5eb0a - rustc_middle[3536e66dcc7db89e]::ty::context::tls::with_opt::<rustc_middle[3536e66dcc7db89e]::util::bug::opt_span_bug_fmt<rustc_span[24393b7d9aa35d24]::span_encoding::Span>::{closure#0}, !>::{closure#0}
21: 0x7f0311b4355b - rustc_middle[3536e66dcc7db89e]::ty::context::tls::with_context_opt::<rustc_middle[3536e66dcc7db89e]::ty::context::tls::with_opt<rustc_middle[3536e66dcc7db89e]::util::bug::opt_span_bug_fmt<rustc_span[24393b7d9aa35d24]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
22: 0x7f0311b3fa67 - rustc_middle[3536e66dcc7db89e]::util::bug::span_bug_fmt::<rustc_span[24393b7d9aa35d24]::span_encoding::Span>
23: 0x7f031099ad71 - <dyn rustc_hir_analysis[93da00151db7016f]::hir_ty_lowering::HirTyLowerer>::lower_path
24: 0x7f0312fd0ed0 - <dyn rustc_hir_analysis[93da00151db7016f]::hir_ty_lowering::HirTyLowerer>::lower_ty_common
25: 0x7f0312fd0f5e - <dyn rustc_hir_analysis[93da00151db7016f]::hir_ty_lowering::HirTyLowerer>::lower_ty_common
26: 0x7f0312fcf94a - <dyn rustc_hir_analysis[93da00151db7016f]::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
27: 0x7f0312fcf1b8 - rustc_hir_analysis[93da00151db7016f]::collect::infer_return_ty_for_fn_sig
28: 0x7f0312fcc9ad - rustc_hir_analysis[93da00151db7016f]::collect::fn_sig
29: 0x7f0312fe4eff - rustc_query_impl[93ab4e638077d6a3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[93ab4e638077d6a3]::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 24usize]>>
30: 0x7f0312fe4ecf - <rustc_query_impl[93ab4e638077d6a3]::query_impl::fn_sig::dynamic_query::{closure#2} as core[88347914527c2294]::ops::function::FnOnce<(rustc_middle[3536e66dcc7db89e]::ty::context::TyCtxt, rustc_span[24393b7d9aa35d24]::def_id::DefId)>>::call_once
31: 0x7f0313284bd6 - rustc_query_system[421efb6b4256089a]::query::plumbing::try_execute_query::<rustc_query_impl[93ab4e638077d6a3]::DynamicConfig<rustc_query_system[421efb6b4256089a]::query::caches::DefIdCache<rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[93ab4e638077d6a3]::plumbing::QueryCtxt, true>
32: 0x7f0313283bc4 - rustc_query_impl[93ab4e638077d6a3]::query_impl::fn_sig::get_query_incr::__rust_end_short_backtrace
33: 0x7f03134517a4 - <rustc_hir_analysis[93da00151db7016f]::collect::CollectItemTypesVisitor as rustc_hir[43b93ab3ddc3858]::intravisit::Visitor>::visit_item
34: 0x7f0313459aff - rustc_hir_analysis[93da00151db7016f]::check::wfcheck::check_well_formed
35: 0x7f03134599f3 - rustc_query_impl[93ab4e638077d6a3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[93ab4e638077d6a3]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 1usize]>>
36: 0x7f031339a472 - rustc_query_system[421efb6b4256089a]::query::plumbing::try_execute_query::<rustc_query_impl[93ab4e638077d6a3]::DynamicConfig<rustc_query_system[421efb6b4256089a]::query::caches::VecCache<rustc_hir[43b93ab3ddc3858]::hir_id::OwnerId, rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[93ab4e638077d6a3]::plumbing::QueryCtxt, true>
37: 0x7f0313399f7f - rustc_query_impl[93ab4e638077d6a3]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
38: 0x7f0313456e53 - rustc_hir_analysis[93da00151db7016f]::check::wfcheck::check_mod_type_wf
39: 0x7f0313456c9b - rustc_query_impl[93ab4e638077d6a3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[93ab4e638077d6a3]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 1usize]>>
40: 0x7f0313c1afc2 - rustc_query_system[421efb6b4256089a]::query::plumbing::try_execute_query::<rustc_query_impl[93ab4e638077d6a3]::DynamicConfig<rustc_query_system[421efb6b4256089a]::query::caches::DefaultCache<rustc_span[24393b7d9aa35d24]::def_id::LocalModDefId, rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[93ab4e638077d6a3]::plumbing::QueryCtxt, true>
41: 0x7f0313c1bc88 - rustc_query_impl[93ab4e638077d6a3]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
42: 0x7f031301ab4b - rustc_hir_analysis[93da00151db7016f]::check_crate
43: 0x7f03136f3eba - rustc_interface[7e68e68fe8897519]::passes::analysis
44: 0x7f03136f3a15 - rustc_query_impl[93ab4e638077d6a3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[93ab4e638077d6a3]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 1usize]>>
45: 0x7f0313c2590a - rustc_query_system[421efb6b4256089a]::query::plumbing::try_execute_query::<rustc_query_impl[93ab4e638077d6a3]::DynamicConfig<rustc_query_system[421efb6b4256089a]::query::caches::SingleCache<rustc_middle[3536e66dcc7db89e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[93ab4e638077d6a3]::plumbing::QueryCtxt, true>
46: 0x7f0313c2551c - rustc_query_impl[93ab4e638077d6a3]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
47: 0x7f0313ad6ad3 - rustc_interface[7e68e68fe8897519]::interface::run_compiler::<core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>, rustc_driver_impl[69898ae479fe711b]::run_compiler::{closure#0}>::{closure#0}
48: 0x7f0313bb019d - std[c8275a09eb24d4c6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7e68e68fe8897519]::util::run_in_thread_with_globals<rustc_interface[7e68e68fe8897519]::util::run_in_thread_pool_with_globals<rustc_interface[7e68e68fe8897519]::interface::run_compiler<core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>, rustc_driver_impl[69898ae479fe711b]::run_compiler::{closure#0}>::{closure#0}, core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>>::{closure#0}, core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>>
49: 0x7f0313baffaa - <<std[c8275a09eb24d4c6]::thread::Builder>::spawn_unchecked_<rustc_interface[7e68e68fe8897519]::util::run_in_thread_with_globals<rustc_interface[7e68e68fe8897519]::util::run_in_thread_pool_with_globals<rustc_interface[7e68e68fe8897519]::interface::run_compiler<core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>, rustc_driver_impl[69898ae479fe711b]::run_compiler::{closure#0}>::{closure#0}, core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>>::{closure#0}, core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88347914527c2294]::result::Result<(), rustc_span[24393b7d9aa35d24]::ErrorGuaranteed>>::{closure#2} as core[88347914527c2294]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
50: 0x7f030e96b95b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc339186170421144
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/alloc/src/boxed.rs:2018:9
51: 0x7f030e96b95b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2d2004059e1e0429
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/alloc/src/boxed.rs:2018:9
52: 0x7f030e96b95b - std::sys::pal::unix::thread::Thread::new::thread_start::hd47ec9690dd18f37
at /rustc/79424056b05eaa9563d16dfab9b9a0c8f033f220/library/std/src/sys/pal/unix/thread.rs:108:17
53: 0x7f030e749333 - start_thread
54: 0x7f030e7cbefc - __clone3
55: 0x0 - <unknown>
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: please make sure that you have updated to the latest nightly
note: please attach the file at `/users/Kosumi/hello/rustc-ice-2024-04-15T20_22_37-2701956.txt` to your bug report
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [fn_sig] computing function signature of `main::set_strength`
#1 [check_well_formed] checking that `main::set_strength` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0412`.
error: could not compile `hello` (bin "hello") due to 3 previous errors
Backtrace
error: expected identifier, found keyword `Self`
--> src/main.rs:6:11
|
6 | trait Self {
| ^^^^ expected identifier, found keyword
error: `self` parameter is only allowed in associated functions
--> src/main.rs:3:21
|
3 | fn set_strength(&mut self, new_strength: T) {
| ^^^^^^^^^ not semantically valid as function parameter
|
= note: associated functions are those in `impl` or `trait` definitions
error[E0412]: cannot find type `T` in this scope
--> src/main.rs:3:46
|
3 | fn set_strength(&mut self, new_strength: T) {
| ^ not found in this scope
|
help: you might be missing a type parameter
|
3 | fn set_strength<T>(&mut self, new_strength: T) {
| +++
error: internal compiler error: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1882:18: unexpected resolution: Def(Trait, DefId(0:5 ~ hello[3c53]::main::Self))
--> src/main.rs:3:26
|
3 | fn set_strength(&mut self, new_strength: T) {
| ^^^^
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1882:18:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: <rustc_errors::DiagCtxt>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
7: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_path
8: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty_common
9: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty_common
10: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
11: rustc_hir_analysis::collect::infer_return_ty_for_fn_sig
12: rustc_hir_analysis::collect::fn_sig
[... omitted 2 frames ...]
13: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
14: rustc_hir_analysis::check::wfcheck::check_well_formed
[... omitted 1 frame ...]
15: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
[... omitted 1 frame ...]
16: rustc_hir_analysis::check_crate
17: rustc_interface::passes::analysis
[... omitted 1 frame ...]
18: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: please make sure that you have updated to the latest nightly
note: please attach the file at `/users/Kosumi/hello/rustc-ice-2024-04-15T20_29_15-2960353.txt` to your bug report
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [fn_sig] computing function signature of `main::set_strength`
#1 [check_well_formed] checking that `main::set_strength` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0412`.
error: could not compile `hello` (bin "hello") due to 3 previous errors