rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.77k stars 12.5k forks source link

ICE no errors encountered even though `delay_span_bug` issued - Bevy - Unused trait method name same as struct method name #120918

Open MJE10 opened 7 months ago

MJE10 commented 7 months ago

Code

use bevy::prelude::{Mut, Resource, World};

pub trait UselessTrait {
    fn update(&mut self) {}
}

#[derive(Resource, Default)]
struct App {}

impl App {
    fn update(&mut self, _: &mut i32) {}
}

fn main() {
    let mut world = World::new();
    let mut app: Mut<App> = world.resource_mut();
    app.update(0u32);
}

Cargo.toml

[package]
name = "compiler-error-crate"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { version = "0.12.1", default-features = false }

Meta

I could not build this example on nightly due to a broken feature in a dependency.

rustc --version --verbose:

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-pc-windows-msvc
release: 1.75.0
LLVM version: 17.0.6

Error output

error: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.75.0 (82e1608df 2023-12-21) running on x86_64-pc-windows-msvc

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 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: no errors encountered even though `delay_span_bug` issued                                                                                                                                            

error: internal compiler error: no errors reported for args
  --> src\main.rs:17:9
   |
17 |     app.update(0u32);
   |         ^^^^^^
   |
Backtrace

``` note: delayed at compiler\rustc_hir_typeck\src\fn_ctxt\checks.rs:525:22 0: std::backtrace::Backtrace::force_capture 1: std::backtrace::Backtrace::capture 2: ::emit_diagnostic 3: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty 4: ::blame_specific_expr_if_possible 5: ::probe_instantiate_query_response 6: ::demand_coerce 7: ::check_struct_path 8: ::demand_coerce 9: ::demand_coerce 10: ::borrow 11: rustc_hir_typeck::typeck 12: ::load_side_effects 13: rustc_query_impl::query_callbacks 14: ::load_side_effects 15: ::load_side_effects 16: ::visit_ty 17: rustc_hir_analysis::check_crate 18: rustc_interface::passes::analysis 19: rustc_query_impl::profiling_support::alloc_self_profile_query_strings 20: rustc_query_impl::dynamic_queries 21: rustc_query_impl::profiling_support::alloc_self_profile_query_strings 22: rustc_query_impl::profiling_support::alloc_self_profile_query_strings 23: rustc_query_impl::profiling_support::alloc_self_profile_query_strings 24: rustc_driver_impl::args::arg_expand_all 25: rustc_driver_impl::args::arg_expand_all 26: rustc_driver_impl::args::arg_expand_all 27: rustc_driver_impl::args::arg_expand_all 28: rustc_driver_impl::args::arg_expand_all 29: rustc_driver_impl::args::arg_expand_all 30: std::sys::windows::thread::Thread::new 31: BaseThreadInitThunk 32: RtlUserThreadStart ```

clubby789 commented 7 months ago

I get a slightly different error on nightly:

error[E0282]: type annotations needed
  --> src/main.rs:17:5
   |
17 |     app.update(0u32);
   |     ^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/demand.rs:403:52:
index out of bounds: the len is 1 but the index is 1