forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#102559 - compiler-errors:issue-102553, r=ol…
…i-obk Don't ICE when trying to copy unsized value in const prop When we have a trivially false where-clause predicate like `Self: Sized` where `Self = dyn Trait`, we sometimes don't throw an error during typeck for an illegal operation such as copying an unsized type. This, unfortunately, cannot be made into an error (at least not without some migration -- see rust-lang#95611 for example), but we should at least not ICE, since this function will never actually be reachable from main, for example. r? `@RalfJung` since I think you added these assertions? but feel free to reassign. Fixes rust-lang#102553
- Loading branch information
Showing
2 changed files
with
35 additions
and
5 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
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,24 @@ | ||
// compile-flags: --crate-type=lib | ||
// check-pass | ||
|
||
pub trait Widget<E> { | ||
fn boxed<'w>(self) -> Box<dyn WidgetDyn<E> + 'w> | ||
where | ||
Self: Sized + 'w; | ||
} | ||
|
||
pub trait WidgetDyn<E> {} | ||
|
||
impl<T, E> WidgetDyn<E> for T where T: Widget<E> {} | ||
|
||
impl<E> Widget<E> for dyn WidgetDyn<E> + '_ { | ||
fn boxed<'w>(self) -> Box<dyn WidgetDyn<E> + 'w> | ||
where | ||
Self: Sized + 'w, | ||
{ | ||
// Even though this is illegal to const evaluate, this should never | ||
// trigger an ICE because it can never be called from actual code | ||
// (due to the trivially false where-clause predicate). | ||
Box::new(self) | ||
} | ||
} |