-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #98013 - compiler-errors:guide-inference-2, r=lcnr
Subtype FRU fields first in `type_changing_struct_update` So this fixes a subtle bug that `type_changing_struct_update` introduced, where it'll no longer coerce the base expr correctly. I actually think this code is easier to understand now, too. r? `@lcnr` since you reviewed the last one
- Loading branch information
Showing
4 changed files
with
93 additions
and
78 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
28 changes: 28 additions & 0 deletions
28
src/test/ui/rfcs/rfc-2528-type-changing-struct-update/coerce-in-base-expr.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,28 @@ | ||
// check-pass | ||
|
||
#![feature(type_changing_struct_update)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::any::Any; | ||
|
||
struct Foo<A, B: ?Sized, C: ?Sized> { | ||
a: A, | ||
b: Box<B>, | ||
c: Box<C>, | ||
} | ||
|
||
struct B; | ||
struct C; | ||
|
||
fn main() { | ||
let y = Foo::<usize, dyn Any, dyn Any> { | ||
a: 0, | ||
b: Box::new(B), | ||
..Foo { | ||
a: 0, | ||
b: Box::new(B), | ||
// C needs to be told to coerce to `Box<dyn Any>` | ||
c: Box::new(C), | ||
} | ||
}; | ||
} |
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