-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Constify trait aliases #144291
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
Open
oli-obk
wants to merge
8
commits into
rust-lang:master
Choose a base branch
from
oli-obk:const_trait_alias
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Constify trait aliases #144291
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
305847d
Trait aliases are rare large ast nodes, box them
oli-obk 66e880b
Constify trait aliases
oli-obk 0740aa1
Generate const predicates for const trait aliases
oli-obk 7c49bc5
Make const trait aliases work in next solver
oli-obk e7dfc25
Prepare test for old solver
oli-obk b2763b9
Make const trait aliases work in the old solver
oli-obk 8d9ea3a
Add more tests
oli-obk 82973ed
Fix formatting of const trait aliases
oli-obk 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
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
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
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
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -196,10 +196,35 @@ where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fn consider_trait_alias_candidate( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
_ecx: &mut EvalCtxt<'_, D>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
_goal: Goal<I, Self>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ecx: &mut EvalCtxt<'_, D>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
goal: Goal<I, Self>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) -> Result<Candidate<I>, NoSolution> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unreachable!("trait aliases are never const") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let cx = ecx.cx(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let where_clause_bounds = cx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.predicates_of(goal.predicate.def_id().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.iter_instantiated(cx, goal.predicate.trait_ref.args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.map(|p| goal.with(cx, p)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ecx.add_goals(GoalSource::Misc, where_clause_bounds); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let const_conditions = cx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.const_conditions(goal.predicate.def_id().into()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.iter_instantiated(cx, goal.predicate.trait_ref.args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.map(|bound_trait_ref| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
goal.with( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bound_trait_ref.to_host_effect_clause(cx, goal.predicate.constness), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// While you could think of trait aliases to have a single builtin impl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// which uses its implied trait bounds as where-clauses, using | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// `GoalSource::ImplWhereClause` here would be incorrect, as we also | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// impl them, which means we're "stepping out of the impl constructor" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// again. To handle this, we treat these cycles as ambiguous for now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ecx.add_goals(GoalSource::Misc, const_conditions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+209
to
+225
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment really applies to both of those lines, so
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fn consider_builtin_sizedness_candidates( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
👍