rust-lang / rust

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

I'm not sure what does this error mean #99737

Closed hoangph271 closed 2 years ago

hoangph271 commented 2 years ago

Code

I'm not sure which part went wrong

use iced::button::{self, Button};
use iced::{Alignment, Column, Element, Row, Sandbox, Text};

#[derive(Default)]
struct Counter {
    value: i32,
    exit_button: button::State,
    increment_pressed: button::State,
}

#[derive(Debug, Clone, Copy)]
enum Message {
    ExitPressed,
    IncrementPressed,
}

impl Sandbox for Counter {
    type Message = Message;

    fn new() -> Self {
        Self::default()
    }

    fn title(&self) -> String {
        String::from("Counter - Iced")
    }

    fn update(&mut self, message: Message) {
        match message {
            Message::ExitPressed => {
                self.value += 1;
            }
            Message::IncrementPressed => {
                todo!("Handle exit app...!")
            }
        }
    }

    fn view(&mut self) -> Element<Message> {
        Row::new()
            .push(
                Column::new()
                    .padding(20)
                    .align_items(Alignment::Center)
                    .push(
                        Button::new(&mut self.exit_button, Text::new("Increment"))
                            .on_press(Message::ExitPressed),
                    )
                    .push(Text::new(self.value.to_string()).size(50))
                    .push(
                        Button::new(&mut self.increment_pressed, Text::new("Exit app"))
                            .on_press(Message::IncrementPressed),
                    )
                    .into(),
            )
            .into()
    }
}

fn main() -> Result<(), iced::Error> {
    Counter::run(iced::Settings::default())
}

Meta

I'm using rustc@1.63.0-nightly

Backtrace

``` garand@garand rusted-content % RUST_BACKTRACE=1 cargo run . Compiling rusted-content v0.1.0 (/Users/garand/useCode/rusted-content) error: internal compiler error: compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:856:33: unexpected path: def=iced_native::widget::row::Row substs=['_#1r, _, _] path=Path { span: src/main.rs:40:9: 40:12 (#0), res: Def(TyAlias, DefId(20:185 ~ iced[6c0f]::widget::Row)), segments: [PathSegment { ident: Row#0, hir_id: Some(HirId { owner: DefId(0:34 ~ rusted_content[7db5]::{impl#0}::view), local_id: 6 }), res: Some(Err), args: Some(GenericArgs { args: [Lifetime(Lifetime { hir_id: HirId { owner: DefId(0:34 ~ rusted_content[7db5]::{impl#0}::view), local_id: 5 }, span: src/main.rs:40:9: 40:12 (#0), name: Implicit })], bindings: [], parenthesized: false, span_ext: src/main.rs:40:17: 40:17 (#0) }), infer_args: true }] } thread 'rustc' panicked at 'Box', /rustc/a6b8c6954829669a5c4fa320c3e6132edf04fcfc/compiler/rustc_errors/src/lib.rs:1335:9 stack backtrace: 0: std::panicking::begin_panic:: 1: std::panic::panic_any:: 2: ::bug::<&alloc::string::String> 3: ::bug::<&alloc::string::String> 4: rustc_middle::ty::context::tls::with_opt::::{closure#0}, ()> 5: rustc_middle::util::bug::opt_span_bug_fmt:: 6: rustc_middle::util::bug::bug_fmt 7: ::path_inferred_subst_iter 8: ::visit_expr 9: ::visit_expr 10: rustc_hir::intravisit::walk_expr:: 11: ::visit_expr 12: rustc_hir::intravisit::walk_expr:: 13: ::visit_expr 14: ::visit_expr 15: ::emit_inference_failure_err 16: ::maybe_report_ambiguity 17: ::report_fulfillment_errors 18: ::select_all_obligations_or_error 19: ::enter::<&rustc_middle::ty::context::TypeckResults, ::enter::{closure#1}, &rustc_middle::ty::context::TypeckResults>::{closure#0}> 20: rustc_typeck::check::typeck 21: >::with_task:: 22: rustc_query_system::query::plumbing::try_execute_query::> 23: rustc_query_system::query::plumbing::get_query:: 24: ::par_body_owners:: 25: rustc_typeck::check::typeck_item_bodies 26: >::with_task:: 27: rustc_query_system::query::plumbing::try_execute_query::> 28: rustc_query_system::query::plumbing::get_query:: 29: ::time::<(), rustc_typeck::check_crate::{closure#7}> 30: rustc_typeck::check_crate 31: rustc_interface::passes::analysis 32: >::with_task::> 33: rustc_query_system::query::plumbing::try_execute_query::>> 34: rustc_query_system::query::plumbing::get_query:: 35: ::enter::> 36: ::enter::, rustc_errors::ErrorGuaranteed>> 37: rustc_span::with_source_map::, rustc_interface::interface::create_compiler_and_run, rustc_driver::run_compiler::{closure#1}>::{closure#1}> 38: >::set::, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>> note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. note: 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.63.0-nightly (a6b8c6954 2022-06-03) running on aarch64-apple-darwin note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [typeck] type-checking `::view` #1 [typeck_item_bodies] type-checking all item bodies #2 [analysis] running analysis passes on this crate end of query stack error: could not compile `rusted-content` ```

compiler-errors commented 2 years ago

@hoangph271 please update your compiler, this is an old nightly version.

hoangph271 commented 2 years ago

Thank you, I think the issue here is I failed to update rustc in M1 mac...!

> rustup update
nightly-aarch64-apple-darwin update failed - rustc 1.63.0-nightly (a6b8c6954 2022-06-03)