Skip to content

crash when creating path from formated string #104149

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

Closed
can2049 opened this issue Nov 8, 2022 · 2 comments
Closed

crash when creating path from formated string #104149

can2049 opened this issue Nov 8, 2022 · 2 comments
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@can2049
Copy link

can2049 commented Nov 8, 2022

Code

fn main() {
    let a = std::path::Path::from(format!("a/b"));
}

Meta

rustc --version --verbose:

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/context.rs:703:13: node_type: no type for node `expr {
                                        let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));
                                        res
                                    } (hir_id=HirId { owner: DefId(0:376 ~ git_repos[163e]::repo::init_repos), local_id: 118 })`

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/compiler/rustc_errors/src/lib.rs:1462:9
Backtrace


stack backtrace:
   0:     0x7fec4b7b5d40 - std::backtrace_rs::backtrace::libunwind::trace::h32eb3e08e874dd27
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fec4b7b5d40 - std::backtrace_rs::backtrace::trace_unsynchronized::haa3f451d27bc11a5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fec4b7b5d40 - std::sys_common::backtrace::_print_fmt::h5b94a01bb4289bb5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fec4b7b5d40 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb070b7fa7e3175df
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fec4b810bfe - core::fmt::write::hd5207aebbb9a86e9
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/fmt/mod.rs:1202:17
   5:     0x7fec4b7a6935 - std::io::Write::write_fmt::h3bd699bbd129ab8a
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/io/mod.rs:1679:15
   6:     0x7fec4b7b89f3 - std::sys_common::backtrace::_print::h7a21be552fdf58da
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fec4b7b89f3 - std::sys_common::backtrace::print::ha85c41fe4dd80b13
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fec4b7b89f3 - std::panicking::default_hook::{{closure}}::h04cca40023d0eeca
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:295:22
   9:     0x7fec4b7b86df - std::panicking::default_hook::haa3ca8c310ed5402
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:314:9
  10:     0x7fec4a1ab2e1 - rustc_driver[cfb34b1539811fe8]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fec4b7b922d - std::panicking::rust_panic_with_hook::h7b190ce1a948faac
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:702:17
  12:     0x7fec4b131e51 - std[71cb4861428b0c25]::panicking::begin_panic::<rustc_errors[f77a66b68db622d5]::ExplicitBug>::{closure#0}
  13:     0x7fec4b12f966 - std[71cb4861428b0c25]::sys_common::backtrace::__rust_end_short_backtrace::<std[71cb4861428b0c25]::panicking::begin_panic<rustc_errors[f77a66b68db622d5]::ExplicitBug>::{closure#0}, !>
  14:     0x7fec4b189316 - std[71cb4861428b0c25]::panicking::begin_panic::<rustc_errors[f77a66b68db622d5]::ExplicitBug>
  15:     0x7fec4b12c5f6 - std[71cb4861428b0c25]::panic::panic_any::<rustc_errors[f77a66b68db622d5]::ExplicitBug>
  16:     0x7fec4b12b1dd - <rustc_errors[f77a66b68db622d5]::HandlerInner>::bug::<&alloc[188ed69dc0d14b4b]::string::String>
  17:     0x7fec4b12ac10 - <rustc_errors[f77a66b68db622d5]::Handler>::bug::<&alloc[188ed69dc0d14b4b]::string::String>
  18:     0x7fec4b1e77ed - rustc_middle[a9ca1c3f9fd197cd]::ty::context::tls::with_context_opt::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::tls::with_opt<rustc_middle[a9ca1c3f9fd197cd]::util::bug::opt_span_bug_fmt<rustc_span[8f00505efff112e2]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7fec4b1eac86 - rustc_middle[a9ca1c3f9fd197cd]::util::bug::opt_span_bug_fmt::<rustc_span[8f00505efff112e2]::span_encoding::Span>
  20:     0x7fec48b88a83 - rustc_middle[a9ca1c3f9fd197cd]::util::bug::bug_fmt
  21:     0x7fec491a959d - <rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults>::expr_ty_adjusted
  22:     0x7fec4afac2b5 - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxt as rustc_trait_selection[f6cb7b5468c1337d]::traits::error_reporting::suggestions::InferCtxtExt>::note_obligation_cause_code::<rustc_middle[a9ca1c3f9fd197cd]::ty::Predicate>
  23:     0x7fec4afbbc5f - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxt as rustc_trait_selection[f6cb7b5468c1337d]::traits::error_reporting::InferCtxtPrivExt>::note_obligation_cause
  24:     0x7fec4afb3068 - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxt as rustc_trait_selection[f6cb7b5468c1337d]::traits::error_reporting::InferCtxtExt>::report_selection_error
  25:     0x7fec4afbf58a - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxt as rustc_trait_selection[f6cb7b5468c1337d]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  26:     0x7fec4afb1b50 - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxt as rustc_trait_selection[f6cb7b5468c1337d]::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  27:     0x7fec48e3b5f7 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_call
  28:     0x7fec48deaf27 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:     0x7fec48deb7e4 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7fec48e8367f - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_argument_types
  31:     0x7fec48e37f98 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_call
  32:     0x7fec48deaf27 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7fec48e8367f - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_argument_types
  34:     0x7fec48e37f98 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_call
  35:     0x7fec48deaf27 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36:     0x7fec48e6bd3b - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_match::{closure#0}
  37:     0x7fec48dec443 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  38:     0x7fec48e3602f - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_decl
  39:     0x7fec48e32853 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  40:     0x7fec48deb050 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  41:     0x7fec497e54d6 - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::check_return_expr
  42:     0x7fec497dd86a - rustc_typeck[4a3b2f91c49b3c3e]::check::check::check_fn
  43:     0x7fec497d0a75 - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxtBuilder>::enter::<&rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults, <rustc_typeck[4a3b2f91c49b3c3e]::check::inherited::InheritedBuilder>::enter<rustc_typeck[4a3b2f91c49b3c3e]::check::typeck_with_fallback<rustc_typeck[4a3b2f91c49b3c3e]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults>::{closure#0}>
  44:     0x7fec497cec29 - rustc_typeck[4a3b2f91c49b3c3e]::check::typeck
  45:     0x7fec49a7a8ad - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, rustc_span[8f00505efff112e2]::def_id::LocalDefId, &rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults>
  46:     0x7fec49a6d664 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<rustc_span[8f00505efff112e2]::def_id::LocalDefId, &rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults>>
  47:     0x7fec4a0e7cae - <rustc_query_impl[d6191eea714bd250]::Queries as rustc_middle[a9ca1c3f9fd197cd]::ty::query::QueryEngine>::typeck
  48:     0x7fec49f28057 - rustc_data_structures[62ce3989ce8140ee]::sync::par_for_each_in::<&[rustc_span[8f00505efff112e2]::def_id::LocalDefId], <rustc_middle[a9ca1c3f9fd197cd]::hir::map::Map>::par_body_owners<rustc_typeck[4a3b2f91c49b3c3e]::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  49:     0x7fec49f27e13 - rustc_typeck[4a3b2f91c49b3c3e]::check::typeck_item_bodies
  50:     0x7fec49e322e5 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, (), ()>
  51:     0x7fec49e312be - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<(), ()>>
  52:     0x7fec49e30cc7 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::typeck_item_bodies, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  53:     0x7fec4951ea9f - <rustc_session[c5946fac61f8bc34]::session::Session>::time::<(), rustc_typeck[4a3b2f91c49b3c3e]::check_crate::{closure#7}>
  54:     0x7fec4951e65f - rustc_typeck[4a3b2f91c49b3c3e]::check_crate
  55:     0x7fec4951dc27 - rustc_interface[3182dd864eff9d7d]::passes::analysis
  56:     0x7fec49f7c382 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, (), core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  57:     0x7fec49f7ba4a - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<(), core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>>
  58:     0x7fec49f7b517 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::analysis, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  59:     0x7fec49067897 - <rustc_interface[3182dd864eff9d7d]::passes::QueryContext>::enter::<rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  60:     0x7fec4905b28c - rustc_interface[3182dd864eff9d7d]::interface::create_compiler_and_run::<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>
  61:     0x7fec49059ac1 - <scoped_tls[e395fa6e23b19669]::ScopedKey<rustc_span[8f00505efff112e2]::SessionGlobals>>::set::<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  62:     0x7fec490597af - std[71cb4861428b0c25]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  63:     0x7fec4a00ed70 - <<std[71cb4861428b0c25]::thread::Builder>::spawn_unchecked_<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#1} as core[8c92e53db3fc2eaa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  64:     0x7fec4b7c3003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49f797984e2121bf
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  65:     0x7fec4b7c3003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfa4f3d0ee6440e0b
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  66:     0x7fec4b7c3003 - std::sys::unix::thread::Thread::new::thread_start::h62ca48b42d48a8fc
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys/unix/thread.rs:108:17
  67:     0x7fec473e96db - start_thread
                               at /build/glibc-uZu3wS/glibc-2.27/nptl/pthread_create.c:463
  68:     0x7fec4711261f - clone
                               at /build/glibc-uZu3wS/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  69:                0x0 - <unknown>

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.65.0 (897e37553 2022-11-02) running on x86_64-unknown-linux-gnu

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 `repo::init_repos`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

@can2049 can2049 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 8, 2022
@fmease
Copy link
Member

fmease commented Nov 8, 2022

no longer reproduces on nightly:

stderr
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
   --> r.rs:2:35
    |
2   |     let a = std::path::Path::from(format!("a/b"));
    |             --------------------- ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |             |
    |             required by a bound introduced by this call
    |
    = help: within `Path`, the trait `Sized` is not implemented for `[u8]`
    = note: required because it appears within the type `Path`
note: required by a bound in `from`
   --> /home/fmease/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:543:16
    |
543 | pub trait From<T>: Sized {
    |                ^ required by this bound in `from`

error[E0308]: mismatched types
   --> r.rs:2:35
    |
2   |     let a = std::path::Path::from(format!("a/b"));
    |             --------------------- ^^^^^^^^^^^^^^ expected struct `Path`, found struct `String`
    |             |
    |             arguments to this function are incorrect
    |
note: associated function defined here
   --> /home/fmease/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:548:8
    |
548 |     fn from(value: T) -> Self;
    |        ^^^^

error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
 --> r.rs:2:9
  |
2 |     let a = std::path::Path::from(format!("a/b"));
  |         ^ doesn't have a size known at compile-time
  |
  = help: within `Path`, the trait `Sized` is not implemented for `[u8]`
  = note: required because it appears within the type `Path`
  = note: all local variables must have a statically known size
  = help: unsized locals are gated as an unstable feature

error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
 --> r.rs:2:35
  |
2 |     let a = std::path::Path::from(format!("a/b"));
  |                                   ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: within `Path`, the trait `Sized` is not implemented for `[u8]`
  = note: required because it appears within the type `Path`
  = note: all function arguments must have a statically known size
  = help: unsized fn params are gated as an unstable feature
  = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

@Rageking8
Copy link
Contributor

Should be a dupe of #103906. Fixed by @compiler-errors in #101629. I think this issue can be closed as dupe and completed. (UI test not needed as previously confirmed with compiler-errors)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants