forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#121359 - lcnr:typesystem-cleanup, r=compile…
…r-errors miscellaneous type system improvements see review comments for rationale r? `@compiler-errors`
- Loading branch information
Showing
9 changed files
with
169 additions
and
151 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
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
25 changes: 25 additions & 0 deletions
25
compiler/rustc_trait_selection/src/solve/normalizes_to/anon_const.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,25 @@ | ||
use crate::solve::EvalCtxt; | ||
use rustc_middle::traits::solve::{Certainty, Goal, QueryResult}; | ||
use rustc_middle::ty; | ||
|
||
impl<'tcx> EvalCtxt<'_, 'tcx> { | ||
#[instrument(level = "debug", skip(self), ret)] | ||
pub(super) fn normalize_anon_const( | ||
&mut self, | ||
goal: Goal<'tcx, ty::NormalizesTo<'tcx>>, | ||
) -> QueryResult<'tcx> { | ||
if let Some(normalized_const) = self.try_const_eval_resolve( | ||
goal.param_env, | ||
ty::UnevaluatedConst::new(goal.predicate.alias.def_id, goal.predicate.alias.args), | ||
self.tcx() | ||
.type_of(goal.predicate.alias.def_id) | ||
.no_bound_vars() | ||
.expect("const ty should not rely on other generics"), | ||
) { | ||
self.eq(goal.param_env, normalized_const, goal.predicate.term.ct().unwrap())?; | ||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) | ||
} else { | ||
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS) | ||
} | ||
} | ||
} |
Oops, something went wrong.