Closed
Description
auto-reduced (treereduce-rust):
//@compile-flags: -Zvalidate-mir -Zinline-mir -Zinline-mir-threshold=300
trait Foo: Sized {
fn foo(self) {}
}
trait Bar: Sized {
fn bar(self) {}
}
struct S;
impl<'l> Foo for &'l S {}
impl<T: Foo> Bar for T {
fn bar() {
let _ = "Hello".bytes().nth(3);
}
}
fn main() {
let s = S;
s.foo();
s.bar();
}
original:
//@ run-pass
trait Foo: Sized {
fn foo(self) {}
}
trait Bar: Sized {
fn bar(self) {}
}
struct S;
impl<'l> Foo for &'l S {}
impl<T: Foo> Bar for T {
//! See <https://rust-lang.github.io/rust-clippy/master/index.html>
#[expect(clippy::almost_swapped)]
fn foo() {
let mut a = 0;
let mut b = 9;
a = b;
b = a;
}
#[expect(clippy::bytes_nth)]
fn bar() {
let _ = "Hello".bytes().nth(3);
}
#[expect(clippy::if_same_then_else)]
fn baz() {
let _ = if true {
42
} else {
42
};
}
#[expect(clippy::logic_bug)]
fn burger() {
let a = false;
let b = true;
if a && b || a {}
}
}
fn main() {
let s = S;
s.foo();
(&s).bar();
s.bar();
}
Version information
rustc 1.84.0-nightly (251dc8ad8 2024-11-15)
binary: rustc
commit-hash: 251dc8ad84492c792a7600d8c5fef2ec868a36a7
commit-date: 2024-11-15
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3
Possibly related line of code:
rust/compiler/rustc_middle/src/mir/tcx.rs
Lines 288 to 300 in 251dc8a
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zvalidate-mir -Zinline-mir -Zinline-mir-threshold=300
Program output
error[E0186]: method `bar` has a `self` declaration in the trait, but not in the impl
--> /tmp/icemaker_global_tempdir.WRkiEaQifFT5/rustc_testrunner_tmpdir_reporting.09fRBzC5BHPB/mvce.rs:14:5
|
6 | fn bar(self) {}
| ------------ `self` used in trait
...
14 | fn bar() {
| ^^^^^^^^ expected `self` in impl
error: internal compiler error: compiler/rustc_middle/src/mir/tcx.rs:294:41: Type std::slice::Iter<'{erased}, u8> is not a pointer or reference type
thread 'rustc' panicked at compiler/rustc_middle/src/mir/tcx.rs:294:41:
Box<dyn Any>
stack backtrace:
0: 0x792f57a5a3ba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3e8890c320687803
1: 0x792f5820414a - core::fmt::write::h8e02e323e721d5d3
2: 0x792f5962cc51 - std::io::Write::write_fmt::hfa5fc2d5ad51eab4
3: 0x792f57a5a212 - std::sys::backtrace::BacktraceLock::print::hef9ddff43c45c466
4: 0x792f57a5c716 - std::panicking::default_hook::{{closure}}::he4ae1ef11715c038
5: 0x792f57a5c560 - std::panicking::default_hook::h4571154760051e3a
6: 0x792f56ae4281 - std[575dabc3fc23637d]::panicking::update_hook::<alloc[488fcebc54bee2fb]::boxed::Box<rustc_driver_impl[530468506af41d6d]::install_ice_hook::{closure#0}>>::{closure#0}
7: 0x792f57a5ce28 - std::panicking::rust_panic_with_hook::h99e29fee3fbc2974
8: 0x792f56b1e5d1 - std[575dabc3fc23637d]::panicking::begin_panic::<rustc_errors[6fe58dffe56bd7e6]::ExplicitBug>::{closure#0}
9: 0x792f56b115a6 - std[575dabc3fc23637d]::sys::backtrace::__rust_end_short_backtrace::<std[575dabc3fc23637d]::panicking::begin_panic<rustc_errors[6fe58dffe56bd7e6]::ExplicitBug>::{closure#0}, !>
10: 0x792f56b0ce1d - std[575dabc3fc23637d]::panicking::begin_panic::<rustc_errors[6fe58dffe56bd7e6]::ExplicitBug>
11: 0x792f56b282e1 - <rustc_errors[6fe58dffe56bd7e6]::diagnostic::BugAbort as rustc_errors[6fe58dffe56bd7e6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x792f571a86d3 - rustc_middle[c94631e3827a547d]::util::bug::opt_span_bug_fmt::<rustc_span[9778d555244491c7]::span_encoding::Span>::{closure#0}
13: 0x792f5718ef1a - rustc_middle[c94631e3827a547d]::ty::context::tls::with_opt::<rustc_middle[c94631e3827a547d]::util::bug::opt_span_bug_fmt<rustc_span[9778d555244491c7]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x792f5718edab - rustc_middle[c94631e3827a547d]::ty::context::tls::with_context_opt::<rustc_middle[c94631e3827a547d]::ty::context::tls::with_opt<rustc_middle[c94631e3827a547d]::util::bug::opt_span_bug_fmt<rustc_span[9778d555244491c7]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x792f5555b280 - rustc_middle[c94631e3827a547d]::util::bug::bug_fmt
16: 0x792f59c85e9a - <rustc_middle[c94631e3827a547d]::ty::Ty>::pointee_metadata_ty_or_projection.cold
17: 0x792f54f3ac6a - rustc_mir_transform[b6a0096f646ee25e]::validate::validate_types
18: 0x792f59238c1e - <rustc_mir_transform[b6a0096f646ee25e]::validate::Validator as rustc_mir_transform[b6a0096f646ee25e]::pass_manager::MirPass>::run_pass
19: 0x792f563d176f - rustc_mir_transform[b6a0096f646ee25e]::pass_manager::validate_body
20: 0x792f58206585 - rustc_mir_transform[b6a0096f646ee25e]::pass_manager::run_passes_inner
21: 0x792f5873b1c0 - rustc_mir_transform[b6a0096f646ee25e]::optimized_mir
22: 0x792f58739a9d - rustc_query_impl[bf1c9f3baad9eabf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bf1c9f3baad9eabf]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 8usize]>>
23: 0x792f585f936a - rustc_query_system[d5846f7a9cb2c23f]::query::plumbing::try_execute_query::<rustc_query_impl[bf1c9f3baad9eabf]::DynamicConfig<rustc_query_system[d5846f7a9cb2c23f]::query::caches::DefIdCache<rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[bf1c9f3baad9eabf]::plumbing::QueryCtxt, false>
24: 0x792f585f891f - rustc_query_impl[bf1c9f3baad9eabf]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
25: 0x792f553aa542 - <rustc_middle[c94631e3827a547d]::ty::context::TyCtxt>::instance_mir
26: 0x792f58746ce4 - rustc_interface[c18496298df4cf52]::passes::run_required_analyses
27: 0x792f5902961e - rustc_interface[c18496298df4cf52]::passes::analysis
28: 0x792f590295ef - rustc_query_impl[bf1c9f3baad9eabf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bf1c9f3baad9eabf]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 1usize]>>
29: 0x792f591dee6e - rustc_query_system[d5846f7a9cb2c23f]::query::plumbing::try_execute_query::<rustc_query_impl[bf1c9f3baad9eabf]::DynamicConfig<rustc_query_system[d5846f7a9cb2c23f]::query::caches::SingleCache<rustc_middle[c94631e3827a547d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[bf1c9f3baad9eabf]::plumbing::QueryCtxt, false>
30: 0x792f591deb4e - rustc_query_impl[bf1c9f3baad9eabf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
31: 0x792f590d963a - rustc_interface[c18496298df4cf52]::interface::run_compiler::<core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>, rustc_driver_impl[530468506af41d6d]::run_compiler::{closure#0}>::{closure#1}
32: 0x792f59132e50 - std[575dabc3fc23637d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c18496298df4cf52]::util::run_in_thread_with_globals<rustc_interface[c18496298df4cf52]::util::run_in_thread_pool_with_globals<rustc_interface[c18496298df4cf52]::interface::run_compiler<core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>, rustc_driver_impl[530468506af41d6d]::run_compiler::{closure#0}>::{closure#1}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>
33: 0x792f5913326b - <<std[575dabc3fc23637d]::thread::Builder>::spawn_unchecked_<rustc_interface[c18496298df4cf52]::util::run_in_thread_with_globals<rustc_interface[c18496298df4cf52]::util::run_in_thread_pool_with_globals<rustc_interface[c18496298df4cf52]::interface::run_compiler<core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>, rustc_driver_impl[530468506af41d6d]::run_compiler::{closure#0}>::{closure#1}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[678332cb0ee15b78]::result::Result<(), rustc_span[9778d555244491c7]::ErrorGuaranteed>>::{closure#1} as core[678332cb0ee15b78]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: 0x792f59133d39 - std::sys::pal::unix::thread::Thread::new::thread_start::h1176f996a4a1b888
35: 0x792f5a9e639d - <unknown>
36: 0x792f5aa6b49c - <unknown>
37: 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: rustc 1.84.0-nightly (251dc8ad8 2024-11-15) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z validate-mir -Z inline-mir -Z inline-mir-threshold=300 -Z dump-mir-dir=dir
query stack during panic:
#0 [optimized_mir] optimizing MIR for `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0186`.
Metadata
Metadata
Assignees
Labels
Unstable option: MIR validationArea: MIR optimizationsCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.