-
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 #74670 - tmandry:issue-73818, r=matthewjasper
Normalize bounds fully when checking defaulted types When checking that the default type for `<T as X>::Y` is valid in this example: ``` trait X { type Y: PartialEq<<Self as X>::Y> } impl X for T { default type Y = S; } ``` We will have to prove the bound `S: PartialEq<<T as X>::Y>`. In this case we want `<T as X>::Y` to normalize to `S`. This is valid because we are checking the default value specifically here. Add `<T as X>::Y = S` to the ParamEnv for normalization _of the bound we are checking_ only. Fixes #73818. --- I noticed that adding this to the env for bounds checking didn't break any tests. Not sure if this is because we can't rely on it to prove anything, or because of missing test coverage. r? @matthewjasper, @nikomatsakis
- Loading branch information
Showing
2 changed files
with
52 additions
and
48 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,25 @@ | ||
// Test that associated type bounds are correctly normalized when checking | ||
// default associated type values. | ||
// check-pass | ||
|
||
#![allow(incomplete_features)] | ||
#![feature(specialization)] | ||
|
||
#[derive(PartialEq)] | ||
enum Never {} | ||
trait Foo { | ||
type Assoc: PartialEq; // PartialEq<<Self as Foo>::Assoc> | ||
} | ||
impl<T> Foo for T { | ||
default type Assoc = Never; | ||
} | ||
|
||
trait Trait1 { | ||
type Selection: PartialEq; | ||
} | ||
trait Trait2: PartialEq<Self> {} | ||
impl<T: Trait2> Trait1 for T { | ||
default type Selection = T; | ||
} | ||
|
||
fn main() {} |