-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Fix type resolution of associated const equality bounds (take 2) #119385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
// Regression test for issue #118040. | ||
// Ensure that we support assoc const eq bounds where the assoc const comes from a supertrait. | ||
|
||
//@ check-pass | ||
|
||
#![feature(associated_const_equality)] | ||
|
||
trait Trait: SuperTrait {} | ||
trait SuperTrait: SuperSuperTrait<i32> {} | ||
trait SuperSuperTrait<T> { | ||
const K: T; | ||
} | ||
|
||
fn take(_: impl Trait<K = 0>) {} | ||
|
||
fn main() {} |
16 changes: 10 additions & 6 deletions
16
tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs
This file contains hidden or 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 |
---|---|---|
@@ -1,21 +1,25 @@ | ||
// Regression test for issue #112560. | ||
// Respect the fact that (associated) types and constants live in different namespaces and | ||
// therefore equality bounds involving identically named associated items don't conflict if | ||
// their kind (type vs. const) differs. | ||
|
||
// FIXME(fmease): Extend this test to cover supertraits again | ||
// once #118040 is fixed. See initial version of PR #118360. | ||
// their kind (type vs. const) differs. This obviously extends to supertraits. | ||
|
||
//@ check-pass | ||
|
||
#![feature(associated_const_equality)] | ||
|
||
trait Trait { | ||
trait Trait: SuperTrait { | ||
type N; | ||
type Q; | ||
|
||
const N: usize; | ||
} | ||
|
||
fn take(_: impl Trait<N = 0, N = ()>) {} | ||
trait SuperTrait { | ||
const Q: &'static str; | ||
} | ||
|
||
fn take0(_: impl Trait<N = 0, N = ()>) {} | ||
|
||
fn take1(_: impl Trait<Q = "...", Q = [()]>) {} | ||
|
||
fn main() {} |
This file contains hidden or 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 |
---|---|---|
@@ -1,22 +1,31 @@ | ||
//@ check-pass | ||
|
||
#![feature(generic_const_items, associated_const_equality)] | ||
#![feature(generic_const_items, associated_const_equality, adt_const_params)] | ||
#![allow(incomplete_features)] | ||
|
||
trait Owner { | ||
const C<const N: u32>: u32; | ||
const K<const N: u32>: u32; | ||
const Q<T>: Maybe<T>; | ||
} | ||
|
||
impl Owner for () { | ||
const C<const N: u32>: u32 = N; | ||
const K<const N: u32>: u32 = N + 1; | ||
const Q<T>: Maybe<T> = Maybe::Nothing; | ||
} | ||
|
||
fn take0<const N: u32>(_: impl Owner<C<N> = { N }>) {} | ||
fn take1(_: impl Owner<K<99> = 100>) {} | ||
fn take2(_: impl Owner<Q<()> = { Maybe::Just(()) }>) {} | ||
|
||
fn main() { | ||
take0::<128>(()); | ||
take1(()); | ||
} | ||
|
||
#[derive(PartialEq, Eq, std::marker::ConstParamTy)] | ||
enum Maybe<T> { | ||
Nothing, | ||
Just(T), | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.