-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #134776 - estebank:vanilla-ice, r=lcnr
Avoid ICE: Account for `for<'a>` types when checking for non-structural type in constant as pattern When we encounter a constant in a pattern, we check if it is non-structural. If so, we check if the type implements `PartialEq`, but for types with escaping bound vars the check would be incorrect as is, so we break early. This is ok because these types would be filtered anyways. Slight tweak to output to remove unnecessary context as a drive-by. Fix #134764.
- Loading branch information
Showing
3 changed files
with
104 additions
and
51 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
15 changes: 15 additions & 0 deletions
15
tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.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,15 @@ | ||
#![feature(structural_match)] | ||
impl<T: ?Sized> std::marker::StructuralPartialEq for O<T> { } | ||
|
||
enum O<T: ?Sized> { | ||
Some(*const T), | ||
None, | ||
} | ||
|
||
const C: O<dyn for<'a> Fn(Box<dyn Fn(&'a u8)>)> = O::None; | ||
|
||
fn main() { | ||
match O::None { | ||
C => (), //~ ERROR constant of non-structural type | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.stderr
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,13 @@ | ||
error: constant of non-structural type `O<dyn for<'a> Fn(Box<dyn Fn(&'a u8)>)>` in a pattern | ||
--> $DIR/non_structural_with_escaping_bounds.rs:13:9 | ||
| | ||
LL | const C: O<dyn for<'a> Fn(Box<dyn Fn(&'a u8)>)> = O::None; | ||
| ----------------------------------------------- constant defined here | ||
... | ||
LL | C => (), | ||
| ^ constant of non-structural type | ||
| | ||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details | ||
|
||
error: aborting due to 1 previous error | ||
|