Open
Description
Code
#![allow(incomplete_features)]
#![feature(ergonomic_clones)]
use std::clone::UseCloned;
#[derive(Clone)]
struct Foo;
impl UseCloned for Foo {}
fn do_not_move_test(x: Foo) -> Foo { async {
let s = x.use;
x
} }
fn main() {}
A mutant of tests/ui/ergonomic-clones/dotuse/basic.rs
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (99e7c15e8 2025-06-01)
binary: rustc
commit-hash: 99e7c15e81385b38a8186b51edc4577d5d7b5bdd
commit-date: 2025-06-01
host: aarch64-apple-darwin
release: 1.89.0-nightly
LLVM version: 20.1.5
Error output
command: rustc --edition=2024
--edition=2021
also ICEs
error[E0308]: mismatched types
--> afidt_3.rs:11:38
|
11 | fn do_not_move_test(x: Foo) -> Foo { async {
| ________________________________---___^
| | |
| | expected `Foo` because of return type
12 | | let s = x.use;
13 | | x
14 | | } }
| |_^ expected `Foo`, found `async` block
|
= note: expected struct `Foo`
found `async` block `{async block@afidt_3.rs:11:38: 11:43}`
error: internal compiler error: compiler/rustc_hir_typeck/src/upvar.rs:2431:17: Same capture can't be ByUse and ByValue at the same time
thread 'rustc' panicked at compiler/rustc_hir_typeck/src/upvar.rs:2431:17:
Box<dyn Any>
Backtrace
thread 'rustc' panicked at compiler/rustc_hir_typeck/src/upvar.rs:2431:17:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
5: rustc_middle::util::bug::bug_fmt
6: rustc_hir_typeck::upvar::determine_capture_info
7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::compute_min_captures
8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::analyze_closure
9: <rustc_hir_typeck::upvar::InferBorrowKindVisitor as rustc_hir::intravisit::Visitor>::visit_expr
10: rustc_hir_typeck::typeck_with_inspect::{closure#0}
11: rustc_hir_typeck::typeck
[... omitted 1 frame ...]
12: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}
13: rustc_hir_analysis::check_crate
14: rustc_interface::passes::run_required_analyses
15: rustc_interface::passes::analysis
[... omitted 1 frame ...]
16: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: please attach the file at `/Users/jisukbyun/workspace/250203 scratch/rustc-ice-2025-06-02T14_11_03-89049.txt` to your bug report
query stack during panic:
#0 [typeck] type-checking `do_not_move_test`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.
Bisects to
searched nightlies: from nightly-2025-01-01 to nightly-2025-06-01
regressed nightly: nightly-2025-03-08
searched commit range: b74da96...f5a1ef7
regressed commit: f5a1ef7
bisected with cargo-bisect-rustc v0.6.9
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --end=2025-06-01 --regress ice --preserve --script rustc -- afidt_3.rs --edition=2024
********************************************************************************
Regression in f5a1ef7121ad661b5a21a1d02941c8064d54ee0b
********************************************************************************
Attempting to search unrolled perf builds
Found commits ["5cf66023", "16414e51", "0b6c069b", "aa349152", "275aad33", "eaf94402"]
installing 5cf660233fcc08fce21f8845d36982b25cb0535c
rust-std-nightly-x86_64-unknown-linux-gnu: 30.69 MB / 30.69 MB [==================================] 100.00 % 12.52 MB/s testing...
RESULT: 5cf660233fcc08fce21f8845d36982b25cb0535c, ===> Script found ICE
Regression in https://github.com/rust-lang-ci/rust/commit/5cf660233fcc08fce21f8845d36982b25cb0535c
The PR introducing the regression in this rollup is #134797: Ergonomic ref counting
Notes
- ICE location:
compiler/rustc_hir_typeck/src/upvar.rs Line-2431
rust/compiler/rustc_hir_typeck/src/upvar.rs
Lines 2425 to 2437 in 99e7c15
@rustbot label F-ergonomic_clones