Drop tracking ignores borrows with projections · Issue #93648 · rust-lang/rust (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
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:
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); |
} |
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 |
} |