-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #90218 - JakobDegen:adt_significant_drop_fix, r=nikomat…
…sakis Fixes incorrect handling of ADT's drop requirements Fixes #90024 and a bunch of duplicates. The main issue was just that the contract of `NeedsDropTypes::adt_components` was inconsistent; the list of types it might return were the generic parameters themselves or the fields of the ADT, depending on the nature of the drop impl. This meant that the caller could not determine whether a `.subst()` call was still needed on those types; it called `.subst()` in all cases, and this led to ICEs when the returned types were the generic params. First contribution of more than a few lines, so feedback definitely appreciated.
- Loading branch information
Showing
2 changed files
with
93 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/test/ui/closures/2229_closure_analysis/migrations/issue-90024-adt-correct-subst.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Test that rustc doesn't ICE as in #90024. | ||
// check-pass | ||
// edition=2018 | ||
|
||
#![warn(rust_2021_incompatible_closure_captures)] | ||
|
||
// Checks there's no double-subst into the generic args, otherwise we get OOB | ||
// MCVE by @lqd | ||
pub struct Graph<N, E, Ix> { | ||
_edges: E, | ||
_nodes: N, | ||
_ix: Vec<Ix>, | ||
} | ||
fn graph<N, E>() -> Graph<N, E, i32> { | ||
todo!() | ||
} | ||
fn first_ice() { | ||
let g = graph::<i32, i32>(); | ||
let _ = || g; | ||
} | ||
|
||
// Checks that there is a subst into the fields, otherwise we get normalization error | ||
// MCVE by @cuviper | ||
use std::iter::Empty; | ||
struct Foo<I: Iterator> { | ||
data: Vec<I::Item>, | ||
} | ||
pub fn second_ice() { | ||
let v = Foo::<Empty<()>> { data: vec![] }; | ||
|
||
(|| v.data[0])(); | ||
} | ||
|
||
pub fn main() { | ||
first_ice(); | ||
second_ice(); | ||
} |