-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove interior mutability from TraitDef by turning fields into queries #41911
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c2d9b4e
ICH: Hash lists of local trait impls as part of the HIR.
michaelwoerister 513cc6d
Make incr. comp. test case dependent on specific ICH instead of SVH
michaelwoerister 77b7df3
Fix instability in GlobalMetadata::Impls ICH.
michaelwoerister 8da2fe8
Remove interior mutability from TraitDef by turning fields into queries.
michaelwoerister 40a6734
Re-introduce cycle-check in assoc. item resolution.
michaelwoerister 742ebc1
Share lists of blanket impls in results of relevant_impls_for() query.
michaelwoerister d731b04
Don't use queries::try_get() in assoc_ty projection
michaelwoerister 0a77a58
Add test cases for cyclic specialization graph construction
michaelwoerister 42051ce
Use tcx.type_of(impl) instead of TraitRef::self_ty() for getting Self…
michaelwoerister 08660af
Remove unreachable branches in traits::project
michaelwoerister 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 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
34 changes: 34 additions & 0 deletions
34
src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.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,34 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Formerly this ICEd with the following message: | ||
// Tried to project an inherited associated type during coherence checking, | ||
// which is currently not supported. | ||
// | ||
// No we expect to run into a more user-friendly cycle error instead. | ||
|
||
#![feature(specialization)] | ||
|
||
trait Trait<T> { type Assoc; } | ||
//~^ unsupported cyclic reference between types/traits detected [E0391] | ||
|
||
impl<T> Trait<T> for Vec<T> { | ||
type Assoc = (); | ||
} | ||
|
||
impl Trait<u8> for Vec<u8> {} | ||
|
||
impl<T> Trait<T> for String { | ||
type Assoc = (); | ||
} | ||
|
||
impl Trait<<Vec<u8> as Trait<u8>>::Assoc> for String {} | ||
|
||
fn main() {} |
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,33 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Make sure we don't crash with a cycle error during coherence. | ||
|
||
#![feature(specialization)] | ||
|
||
trait Trait<T> { | ||
type Assoc; | ||
} | ||
|
||
impl<T> Trait<T> for Vec<T> { | ||
default type Assoc = (); | ||
} | ||
|
||
impl Trait<u8> for Vec<u8> { | ||
type Assoc = u8; | ||
} | ||
|
||
impl<T> Trait<T> for String { | ||
type Assoc = (); | ||
} | ||
|
||
impl Trait<<Vec<u8> as Trait<u8>>::Assoc> for String {} | ||
|
||
fn main() {} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is that message in the source? Could that codepath be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It here:
rust/src/librustc/traits/project.rs
Line 989 in 4d09a0e
But it has this nice, long comment which made me reluctant to remove it. I could move the comment to
assoc_ty_def()
, make its return value non-optional, and then remove the branch though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, moving the comment should be fine.