-
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.
Auto merge of #97705 - compiler-errors:guide-inference, r=lcnr
Fix inference issues with unconstrained base expr in `type_changing_struct_update` Use fresh infer vars to guide inference along in `type_changing_struct_update`. Fixes #96878
- Loading branch information
Showing
2 changed files
with
116 additions
and
67 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
31 changes: 31 additions & 0 deletions
31
src/test/ui/rfcs/rfc-2528-type-changing-struct-update/issue-96878.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,31 @@ | ||
// check-pass | ||
|
||
#![feature(type_changing_struct_update)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::borrow::Cow; | ||
use std::marker::PhantomData; | ||
|
||
#[derive(Default)] | ||
struct NonGeneric { | ||
field1: usize, | ||
} | ||
|
||
#[derive(Default)] | ||
struct Generic<T, U> { | ||
field1: T, | ||
field2: U, | ||
} | ||
|
||
#[derive(Default)] | ||
struct MoreGeneric<'a, const N: usize> { | ||
// If only `for<const N: usize> [u32; N]: Default`... | ||
field1: PhantomData<[u32; N]>, | ||
field2: Cow<'a, str>, | ||
} | ||
|
||
fn main() { | ||
let default1 = NonGeneric { ..Default::default() }; | ||
let default2: Generic<i32, f32> = Generic { ..Default::default() }; | ||
let default3: MoreGeneric<'static, 12> = MoreGeneric { ..Default::default() }; | ||
} |