Open
Description
auto-reduced (treereduce-rust):
pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); }
original:
pub fn foo(x: &mut Vec<&'a T>, y: Ref<'b>) { x.push(y); } //~ ERROR lifetime may not live long enough
pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
fn main() {}
Version information
rustc 1.87.0-nightly (2a0602295 2025-03-28)
binary: rustc
commit-hash: 2a06022951893fe5b5384f8dbd75b4e6e3b5cee0
commit-date: 2025-03-28
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.1
Possibly related line of code:
rust/compiler/rustc_span/src/lib.rs
Lines 2241 to 2253 in 2a06022
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error: unknown start of token: \u{ff06}
--> /tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs:5:38
|
5 | pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); }
| ^^
|
help: Unicode character '&' (Fullwidth Ampersand) looks like '&' (Ampersand), but it is not
|
5 - pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); }
5 + pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); }
|
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs:5:72
|
5 | pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs`
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
--> /tmp/icemaker_global_tempdir.NM2ythOfXGaf/rustc_testrunner_tmpdir_reporting.uxIClsJjlvJ7/mvce.rs:5:60
|
5 | pub fn foo3<'a>(_other: &'a [u8], x: & Vec<&u8>, y: &u8) { x.push(y); }
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
thread 'rustc' panicked at compiler/rustc_span/src/lib.rs:2247:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
stack backtrace:
0: 0x7d4609077313 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hec1be6b515a4b985
1: 0x7d4609805d91 - core::fmt::write::h1a721e23ea933c95
2: 0x7d460ac8da51 - std::io::Write::write_fmt::h8aaeee0f3c8d3f0a
3: 0x7d4609077172 - std::sys::backtrace::BacktraceLock::print::h5669ce1c06d4f78b
4: 0x7d4609079a2a - std::panicking::default_hook::{{closure}}::h266748ebbae7c4be
5: 0x7d46090795af - std::panicking::default_hook::hc3bb6e6c093f4ea4
6: 0x7d46080e39b0 - std[4597d80d7047b022]::panicking::update_hook::<alloc[772d3812010e97a3]::boxed::Box<rustc_driver_impl[1d133c6972a1a6b9]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7d460907a2a3 - std::panicking::rust_panic_with_hook::h51ac92c4d270e86c
8: 0x7d4609079f66 - std::panicking::begin_panic_handler::{{closure}}::h8eaa2cc0543eec41
9: 0x7d46090777e9 - std::sys::backtrace::__rust_end_short_backtrace::h733c2f162ba57005
10: 0x7d4609079c5d - __rustc[5fbf492971bd0060]::rust_begin_unwind
11: 0x7d4605a92e70 - core::panicking::panic_fmt::h7438f3740b41962a
12: 0x7d460671a4dc - core::panicking::panic::h654f603cc4632f97
13: 0x7d460a0275c4 - <rustc_span[c4947a62e1591df3]::source_map::SourceMap>::lookup_char_pos
14: 0x7d460a65f891 - <rustc_span[c4947a62e1591df3]::source_map::SourceMap>::is_valid_span
15: 0x7d460a65fcfc - <core[d013d7c9d10039cf]::iter::adapters::filter_map::FilterMap<core[d013d7c9d10039cf]::iter::adapters::cloned::Cloned<core[d013d7c9d10039cf]::iter::adapters::filter::Filter<core[d013d7c9d10039cf]::slice::iter::Iter<rustc_errors[7964d5e4d9f7f11a]::Substitution>, <rustc_errors[7964d5e4d9f7f11a]::CodeSuggestion>::splice_lines::{closure#0}>>, <rustc_errors[7964d5e4d9f7f11a]::CodeSuggestion>::splice_lines::{closure#1}> as core[d013d7c9d10039cf]::iter::traits::iterator::Iterator>::next
16: 0x7d460a662392 - <rustc_errors[7964d5e4d9f7f11a]::emitter::HumanEmitter>::emit_suggestion_default
17: 0x7d460a01ed93 - <rustc_errors[7964d5e4d9f7f11a]::emitter::HumanEmitter as rustc_errors[7964d5e4d9f7f11a]::emitter::Emitter>::emit_diagnostic
18: 0x7d460a66ff75 - <rustc_errors[7964d5e4d9f7f11a]::DiagCtxtInner>::emit_diagnostic::{closure#3}
19: 0x7d460a672e4d - rustc_interface[838c222bb47cac2d]::callbacks::track_diagnostic::<core[d013d7c9d10039cf]::option::Option<rustc_span[c4947a62e1591df3]::ErrorGuaranteed>>
20: 0x7d460a6719a2 - <rustc_errors[7964d5e4d9f7f11a]::DiagCtxtInner>::emit_diagnostic
21: 0x7d460a67185f - <rustc_errors[7964d5e4d9f7f11a]::DiagCtxtHandle>::emit_diagnostic
22: 0x7d460ac3dfea - <rustc_span[c4947a62e1591df3]::ErrorGuaranteed as rustc_errors[7964d5e4d9f7f11a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
23: 0x7d460a9e8949 - rustc_borrowck[b30cfce8d6e8f762]::do_mir_borrowck
24: 0x7d460a99aeec - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 8usize]>>
25: 0x7d4609b3c96c - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_data_structures[44af7552550bcb5]::vec_cache::VecCache<rustc_span[c4947a62e1591df3]::def_id::LocalDefId, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[87ba3fee088a6fc4]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
26: 0x7d4609b3c3cb - rustc_query_impl[3289d2c66c00b6f8]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
27: 0x7d460a142353 - rustc_interface[838c222bb47cac2d]::passes::run_required_analyses
28: 0x7d460a21fc9e - rustc_interface[838c222bb47cac2d]::passes::analysis
29: 0x7d460a21fc6d - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 0usize]>>
30: 0x7d460a7bc3fd - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_query_system[87ba3fee088a6fc4]::query::caches::SingleCache<rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
31: 0x7d460a7bc0f8 - rustc_query_impl[3289d2c66c00b6f8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
32: 0x7d460aac874d - rustc_interface[838c222bb47cac2d]::passes::create_and_enter_global_ctxt::<core[d013d7c9d10039cf]::option::Option<rustc_interface[838c222bb47cac2d]::queries::Linker>, rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
33: 0x7d460a9651aa - rustc_interface[838c222bb47cac2d]::interface::run_compiler::<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}
34: 0x7d460a778148 - std[4597d80d7047b022]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[838c222bb47cac2d]::util::run_in_thread_with_globals<rustc_interface[838c222bb47cac2d]::util::run_in_thread_pool_with_globals<rustc_interface[838c222bb47cac2d]::interface::run_compiler<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
35: 0x7d460a778a34 - <<std[4597d80d7047b022]::thread::Builder>::spawn_unchecked_<rustc_interface[838c222bb47cac2d]::util::run_in_thread_with_globals<rustc_interface[838c222bb47cac2d]::util::run_in_thread_pool_with_globals<rustc_interface[838c222bb47cac2d]::interface::run_compiler<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d013d7c9d10039cf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
36: 0x7d460a779e37 - std::sys::pal::unix::thread::Thread::new::thread_start::h287c1faba384eaa8
37: 0x7d46046a370a - <unknown>
38: 0x7d4604727aac - <unknown>
39: 0x0 - <unknown>
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: please make sure that you have updated to the latest nightly
note: rustc 1.87.0-nightly (2a0602295 2025-03-28) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [mir_borrowck] borrow-checking `foo3`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0596, E0601.
For more information about an error, try `rustc --explain E0596`.
Metadata
Metadata
Assignees
Labels
Area: The borrow checkerArea: Error handlingArea: Compiler frontend (errors, parsing and HIR)Area: The lexing & parsing of Rust source code to an ASTCategory: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: a bisection has been found for this issueStatus: 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.