-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-coroutinesArea: CoroutinesArea: CoroutinesC-bugCategory: This is a bug.Category: This is a bug.
Description
For example:
fn main() {
let _ = async {
let mut s = (String::new(),);
s.0.push_str("abc");
std::mem::drop(s);
async {}.await;
};
}
$ rustc +nightly-2022-01-22 --edition=2021 b.rs
error: internal compiler error: compiler/rustc_mir_transform/src/generator.rs:755:13: Broken MIR: generator contains type (String,) in MIR, but typeck only knows about {ResumeTy, impl Future<Output = [async output]>, ()} and []
The TryFrom<&PlaceWithHirId<'_>> for TrackedValue
fails for places with projections, so in that case borrow is never recorded:
rust/compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs
Lines 133 to 143 in 4c55c83
impl TryFrom<&PlaceWithHirId<'_>> for TrackedValue { | |
type Error = TrackedValueConversionError; | |
fn try_from(place_with_id: &PlaceWithHirId<'_>) -> Result<Self, Self::Error> { | |
if !place_with_id.place.projections.is_empty() { | |
debug!( | |
"TrackedValue from PlaceWithHirId: {:?} has projections, which are not supported.", | |
place_with_id | |
); | |
return Err(TrackedValueConversionError::PlaceProjectionsNotSupported); | |
} |
rust/compiler/rustc_typeck/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs
Lines 93 to 102 in 4c55c83
fn borrow( | |
&mut self, | |
place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>, | |
_diag_expr_id: HirId, | |
_bk: rustc_middle::ty::BorrowKind, | |
) { | |
place_with_id | |
.try_into() | |
.map_or(false, |tracked_value| self.places.borrowed.insert(tracked_value)); | |
} |
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-coroutinesArea: CoroutinesArea: CoroutinesC-bugCategory: This is a bug.Category: This is a bug.