Closed
Description
Code
kinda garbish-y but it reproduces the ICE 🤷
use std::path::Path;
pub use self::imp::Lock;
#[cfg(unix)]
mod imp {
use std::ffi::{CString, OsStr};
use std::os::unix::prelude::*;
use std::path::Path;
use std::io;
use libc;
#[derive(Debug)]
pub struct Lock {
fd: libc::c_int,
}
impl Lock {
pub fn new(p: &Path,
wait: bool,
create: bool,
exclusive: bool)
-> io::Result<Lock> {
let os: &OsStr = p.as_ref();
let buf = CString::new(os.as_bytes()).unwrap();
let open_flags = if create {
libc::O_RDWR | libc::O_CREAT
} else {
libc::O_RDWR
};
let fd = unsafe {
libc::open(buf.as_ptr(), open_flags,
libc::S_IRWXU as libc::c_int)
};
let cmd = if wait { os::F_SETLKW } else { os::F_SETLK };
let ret = unsafe {
};
if ret == -1 {
let err = io::Error::last_os_error();
unsafe { libc::close(fd); }
Err(err)
} else {
Ok(Lock { fd: fd })
}
}
}
}
Meta
rustc --version --verbose
:
IMPORTANT: this reproduces with MASTER but not yet with NIGHTLY rustc 1.63.0-nightly (e71440575 2022-06-02)
rustc 1.63.0-nightly (e40d5e83d 2022-06-03)
binary: rustc
commit-hash: e40d5e83dc133d093c22c7ff016b10daa4f40dcf
commit-date: 2022-06-03
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.4
Error output
error[E0432]: unresolved import `libc`
--> ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:11:9
|
11 | use libc;
| ^^^^ no `libc` in the root
error[E0433]: failed to resolve: use of undeclared crate or module `os`
--> ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:39:33
|
39 | let cmd = if wait { os::F_SETLKW } else { os::F_SETLK };
| ^^ use of undeclared crate or module `os`
error[E0433]: failed to resolve: use of undeclared crate or module `os`
--> ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:39:55
|
39 | let cmd = if wait { os::F_SETLKW } else { os::F_SETLK };
| ^^ use of undeclared crate or module `os`
warning: unused import: `std::path::Path`
--> ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:1:5
|
1 | use std::path::Path;
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0601]: `main` function not found in crate `510c9ceef0960a8c8b6a20e3625ee6c2e10b4052`
--> ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:54:2
|
54 | }
| ^ consider adding a `main` function to `./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs`
error[E0308]: mismatched types
--> ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:43:23
|
43 | if ret == -1 {
| ^^ expected `()`, found integer
error: internal compiler error: compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:856:33: unexpected path: def=alloc::ffi::c_str::CString substs=[] path=Path { span: ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:27:23: 27:30 (#0), res: Def(TyAlias, DefId(1:2774 ~ std[4f4f]::ffi::CString)), segments: [PathSegment { ident: CString#0, hir_id: Some(HirId { owner: DefId(0:28 ~ 510c9ceef0960a8c8b6a20e3625ee6c2e10b4052[d1fc]::imp::{impl#0}::new), local_id: 22 }), res: Some(Err), args: None, infer_args: true }] }
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/compiler/rustc_errors/src/lib.rs:1335:9
Backtrace
error: internal compiler error: compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:856:33: unexpected path: def=alloc::ffi::c_str::CString substs=[] path=Path { span: ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:27:23: 27:30 (#0), res: Def(TyAlias, DefId(1:2774 ~ std[4f4f]::ffi::CString)), segments: [PathSegment { ident: CString#0, hir_id: Some(HirId { owner: DefId(0:28 ~ 510c9ceef0960a8c8b6a20e3625ee6c2e10b4052[d1fc]::imp::{impl#0}::new), local_id: 22 }), res: Some(Err), args: None, infer_args: true }] }
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/compiler/rustc_errors/src/lib.rs:1335:9
stack backtrace:
0: 0x7f6b6ec9decd - std::backtrace_rs::backtrace::libunwind::trace::hfcd45b45ae488cd5
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f6b6ec9decd - std::backtrace_rs::backtrace::trace_unsynchronized::h405dac851f6cc6a8
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f6b6ec9decd - std::sys_common::backtrace::_print_fmt::h5f6c74a63449dd3f
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/sys_common/backtrace.rs:66:5
3: 0x7f6b6ec9decd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7d487462c277bf24
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/sys_common/backtrace.rs:45:22
4: 0x7f6b6ecf9bac - core::fmt::write::h832d0c8909aada18
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/core/src/fmt/mod.rs:1196:17
5: 0x7f6b6ec8f5c1 - std::io::Write::write_fmt::h65c8c1822edc4894
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/io/mod.rs:1654:15
6: 0x7f6b6eca0bb5 - std::sys_common::backtrace::_print::h560a0f4f262236c1
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/sys_common/backtrace.rs:48:5
7: 0x7f6b6eca0bb5 - std::sys_common::backtrace::print::h0080326ddadae76c
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/sys_common/backtrace.rs:35:9
8: 0x7f6b6eca0bb5 - std::panicking::default_hook::{{closure}}::hc726d21ea0224885
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/panicking.rs:295:22
9: 0x7f6b6eca08d6 - std::panicking::default_hook::hdcc52b852804bb0b
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/panicking.rs:314:9
10: 0x7f6b6f4f9f11 - rustc_driver[c7c8f2fedff45b54]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7f6b6eca128a - std::panicking::rust_panic_with_hook::h48930cf2efbb5ae2
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/panicking.rs:702:17
12: 0x7f6b705e7ae1 - std[4f4f1627d3880017]::panicking::begin_panic::<rustc_errors[65331a6f7e432222]::ExplicitBug>::{closure#0}
13: 0x7f6b705e7556 - std[4f4f1627d3880017]::sys_common::backtrace::__rust_end_short_backtrace::<std[4f4f1627d3880017]::panicking::begin_panic<rustc_errors[65331a6f7e432222]::ExplicitBug>::{closure#0}, !>
14: 0x7f6b7054ecf6 - std[4f4f1627d3880017]::panicking::begin_panic::<rustc_errors[65331a6f7e432222]::ExplicitBug>
15: 0x7f6b70572b26 - std[4f4f1627d3880017]::panic::panic_any::<rustc_errors[65331a6f7e432222]::ExplicitBug>
16: 0x7f6b705722e5 - <rustc_errors[65331a6f7e432222]::HandlerInner>::bug::<&alloc[31c74b9f3315cbc6]::string::String>
17: 0x7f6b70571dc0 - <rustc_errors[65331a6f7e432222]::Handler>::bug::<&alloc[31c74b9f3315cbc6]::string::String>
18: 0x7f6b705e4acd - rustc_middle[83233ac63f698a09]::ty::context::tls::with_opt::<rustc_middle[83233ac63f698a09]::util::bug::opt_span_bug_fmt<rustc_span[b73b5b7a1d5e4b08]::span_encoding::Span>::{closure#0}, ()>
19: 0x7f6b705e4bc6 - rustc_middle[83233ac63f698a09]::util::bug::opt_span_bug_fmt::<rustc_span[b73b5b7a1d5e4b08]::span_encoding::Span>
20: 0x7f6b705e4b43 - rustc_middle[83233ac63f698a09]::util::bug::bug_fmt
21: 0x7f6b704a82ba - <rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor>::path_inferred_subst_iter
22: 0x7f6b704a8833 - <rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[a9ca4d4e6c54b339]::intravisit::Visitor>::visit_expr
23: 0x7f6b704a86cc - <rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[a9ca4d4e6c54b339]::intravisit::Visitor>::visit_expr
24: 0x7f6b704beb92 - rustc_hir[a9ca4d4e6c54b339]::intravisit::walk_expr::<rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor>
25: 0x7f6b704a86de - <rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[a9ca4d4e6c54b339]::intravisit::Visitor>::visit_expr
26: 0x7f6b704bb80c - rustc_hir[a9ca4d4e6c54b339]::intravisit::walk_local::<rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor>
27: 0x7f6b704a8348 - <rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[a9ca4d4e6c54b339]::intravisit::Visitor>::visit_local
28: 0x7f6b704bb657 - rustc_hir[a9ca4d4e6c54b339]::intravisit::walk_block::<rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor>
29: 0x7f6b704a86de - <rustc_infer[78bfaa2976d36a75]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[a9ca4d4e6c54b339]::intravisit::Visitor>::visit_expr
30: 0x7f6b70460f84 - <rustc_infer[78bfaa2976d36a75]::infer::InferCtxt>::emit_inference_failure_err
31: 0x7f6b703b30c2 - <rustc_infer[78bfaa2976d36a75]::infer::InferCtxt as rustc_trait_selection[ae7a9636b275321f]::traits::error_reporting::InferCtxtPrivExt>::maybe_report_ambiguity
32: 0x7f6b703a6c87 - <rustc_infer[78bfaa2976d36a75]::infer::InferCtxt as rustc_trait_selection[ae7a9636b275321f]::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
33: 0x7f6b70af7af3 - <rustc_infer[78bfaa2976d36a75]::infer::InferCtxtBuilder>::enter::<&rustc_middle[83233ac63f698a09]::ty::context::TypeckResults, <rustc_typeck[412d93c49a5cfb7d]::check::inherited::InheritedBuilder>::enter<rustc_typeck[412d93c49a5cfb7d]::check::typeck_with_fallback<rustc_typeck[412d93c49a5cfb7d]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[83233ac63f698a09]::ty::context::TypeckResults>::{closure#0}>
34: 0x7f6b70aa6efa - rustc_typeck[412d93c49a5cfb7d]::check::typeck
35: 0x7f6b7109bbb4 - rustc_query_system[cd54684135f7aede]::query::plumbing::try_execute_query::<rustc_query_impl[5d43592eeec5f58a]::plumbing::QueryCtxt, rustc_query_system[cd54684135f7aede]::query::caches::DefaultCache<rustc_span[b73b5b7a1d5e4b08]::def_id::LocalDefId, &rustc_middle[83233ac63f698a09]::ty::context::TypeckResults>>
36: 0x7f6b7107623e - <rustc_query_impl[5d43592eeec5f58a]::Queries as rustc_middle[83233ac63f698a09]::ty::query::QueryEngine>::typeck
37: 0x7f6b70b55ee8 - <rustc_middle[83233ac63f698a09]::hir::map::Map>::par_body_owners::<rustc_typeck[412d93c49a5cfb7d]::check::typeck_item_bodies::{closure#0}>
38: 0x7f6b71936a7c - rustc_typeck[412d93c49a5cfb7d]::check::typeck_item_bodies
39: 0x7f6b71c303ac - rustc_query_system[cd54684135f7aede]::query::plumbing::try_execute_query::<rustc_query_impl[5d43592eeec5f58a]::plumbing::QueryCtxt, rustc_query_system[cd54684135f7aede]::query::caches::DefaultCache<(), ()>>
40: 0x7f6b71c5a8b1 - rustc_query_system[cd54684135f7aede]::query::plumbing::get_query::<rustc_query_impl[5d43592eeec5f58a]::queries::typeck_item_bodies, rustc_query_impl[5d43592eeec5f58a]::plumbing::QueryCtxt>
41: 0x7f6b7196d3f3 - <rustc_session[3dcad23083b71834]::session::Session>::time::<(), rustc_typeck[412d93c49a5cfb7d]::check_crate::{closure#7}>
42: 0x7f6b7194a77b - rustc_typeck[412d93c49a5cfb7d]::check_crate
43: 0x7f6b716e3a57 - rustc_interface[d21641337a9fbe3]::passes::analysis
44: 0x7f6b71c2649f - rustc_query_system[cd54684135f7aede]::query::plumbing::try_execute_query::<rustc_query_impl[5d43592eeec5f58a]::plumbing::QueryCtxt, rustc_query_system[cd54684135f7aede]::query::caches::DefaultCache<(), core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>>
45: 0x7f6b71c6ce2e - rustc_query_system[cd54684135f7aede]::query::plumbing::get_query::<rustc_query_impl[5d43592eeec5f58a]::queries::analysis, rustc_query_impl[5d43592eeec5f58a]::plumbing::QueryCtxt>
46: 0x7f6b716c6a07 - <rustc_interface[d21641337a9fbe3]::passes::QueryContext>::enter::<rustc_driver[c7c8f2fedff45b54]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>
47: 0x7f6b716b0cc8 - <rustc_interface[d21641337a9fbe3]::interface::Compiler>::enter::<rustc_driver[c7c8f2fedff45b54]::run_compiler::{closure#1}::{closure#2}, core[e20aa153a98323b0]::result::Result<core[e20aa153a98323b0]::option::Option<rustc_interface[d21641337a9fbe3]::queries::Linker>, rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>
48: 0x7f6b716d44df - rustc_span[b73b5b7a1d5e4b08]::with_source_map::<core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>, rustc_interface[d21641337a9fbe3]::interface::create_compiler_and_run<core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>, rustc_driver[c7c8f2fedff45b54]::run_compiler::{closure#1}>::{closure#1}>
49: 0x7f6b716b18f2 - <scoped_tls[f8b3eb90e665007e]::ScopedKey<rustc_span[b73b5b7a1d5e4b08]::SessionGlobals>>::set::<rustc_interface[d21641337a9fbe3]::interface::run_compiler<core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>, rustc_driver[c7c8f2fedff45b54]::run_compiler::{closure#1}>::{closure#0}, core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>
50: 0x7f6b716c708f - std[4f4f1627d3880017]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d21641337a9fbe3]::util::run_in_thread_pool_with_globals<rustc_interface[d21641337a9fbe3]::interface::run_compiler<core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>, rustc_driver[c7c8f2fedff45b54]::run_compiler::{closure#1}>::{closure#0}, core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>::{closure#0}, core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>
51: 0x7f6b716c71c9 - <<std[4f4f1627d3880017]::thread::Builder>::spawn_unchecked_<rustc_interface[d21641337a9fbe3]::util::run_in_thread_pool_with_globals<rustc_interface[d21641337a9fbe3]::interface::run_compiler<core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>, rustc_driver[c7c8f2fedff45b54]::run_compiler::{closure#1}>::{closure#0}, core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>::{closure#0}, core[e20aa153a98323b0]::result::Result<(), rustc_errors[65331a6f7e432222]::ErrorGuaranteed>>::{closure#1} as core[e20aa153a98323b0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
52: 0x7f6b6ecab1b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3752e20e7af2922b
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/alloc/src/boxed.rs:1951:9
53: 0x7f6b6ecab1b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hea44272e5391750e
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/alloc/src/boxed.rs:1951:9
54: 0x7f6b6ecab1b3 - std::sys::unix::thread::Thread::new::thread_start::h6d31b3f92a2b25ea
at /rustc/e40d5e83dc133d093c22c7ff016b10daa4f40dcf/library/std/src/sys/unix/thread.rs:108:17
55: 0x7f6b6ea835c2 - start_thread
56: 0x7f6b6eb08584 - __clone
57: 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.63.0-nightly (e40d5e83d 2022-06-03) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `imp::<impl at ./510c9ceef0960a8c8b6a20e3625ee6c2e10b4052.rs:20:5: 52:6>::new`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted
Some errors have detailed explanations: E0308, E0432, E0433, E0601.
For more information about an error, try `rustc --explain E0308`.