Skip to content
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

Rollup of 10 pull requests #82263

Merged
merged 30 commits into from
Feb 18, 2021
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dfa581f
Fix pretty printing of generic associated type constraints
matthewjasper Feb 11, 2021
9bbd3e0
Remove ProjectionTy::from_ref_and_name
matthewjasper Feb 11, 2021
0bf1d73
Don't go through TraitRef to relate projections
matthewjasper Feb 12, 2021
9526c0c
Avoid `trait_ref` when lowering ExistentialProjections
matthewjasper Feb 12, 2021
79f6f11
Remove some unnecessary `trait_ref` calls
matthewjasper Feb 12, 2021
dfee89f
Make ProjectionTy::trait_ref truncate substs again
matthewjasper Feb 12, 2021
d785c8c
Remove unnecessary function parameters project.rs
matthewjasper Feb 12, 2021
eeb82e4
Add more tests for generic associated type bounds
matthewjasper Feb 12, 2021
7e368e5
the environment round here is awfully empty
BoxyUwU Feb 15, 2021
0f04875
replace if-let and while-let with `if let` and `while let`
TaKO8Ki Feb 17, 2021
43aed74
[libtest] Run the test synchronously when hitting thread limit
Jan 29, 2021
2a66685
Make sure pdbs are copied along with exe and dlls when bootstrapping
rylev Feb 17, 2021
32c97da
In some limited cases, suggest `where` bounds for non-type params
estebank Feb 16, 2021
ec50a20
avoid converting types into themselves (clippy::useless_conversion)
matthiaskrgr Feb 17, 2021
5ae392f
Add long explanation for E0549
jesusprubio Feb 18, 2021
5112cf0
Update compiler/rustc_error_codes/src/error_codes/E0549.md
jesusprubio Feb 18, 2021
0e01c41
Update compiler/rustc_error_codes/src/error_codes/E0549.md
jesusprubio Feb 18, 2021
3c4fe1e
Update compiler/rustc_error_codes/src/error_codes/E0549.md
jesusprubio Feb 18, 2021
6165d1c
Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.
eddyb Feb 18, 2021
8a5c568
nhwn: optimize counting digits in line numbers
nhwn Feb 18, 2021
55ab2e3
Rollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-S…
Dylan-DPC Feb 18, 2021
66211f6
Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726
Dylan-DPC Feb 18, 2021
928819a
Rollup merge of #82112 - BoxyUwU:tumbleweed, r=varkor
Dylan-DPC Feb 18, 2021
f01b339
Rollup merge of #82194 - estebank:arbitrary-bounds-suggestion, r=petr…
Dylan-DPC Feb 18, 2021
b3d3251
Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor
Dylan-DPC Feb 18, 2021
01104b5
Rollup merge of #82218 - rylev:copy-pdbs, r=Mark-Simulacrum
Dylan-DPC Feb 18, 2021
04df75a
Rollup merge of #82236 - matthiaskrgr:useless_conv, r=jyn514
Dylan-DPC Feb 18, 2021
5ca94cd
Rollup merge of #82246 - jesusprubio:add-long-explanation-e0549, r=Gu…
Dylan-DPC Feb 18, 2021
555db2d
Rollup merge of #82248 - nhwn:optimize-counting-digits, r=varkor
Dylan-DPC Feb 18, 2021
efdcb43
Rollup merge of #82256 - eddyb:time-passes-stderr, r=varkor
Dylan-DPC Feb 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unnecessary function parameters project.rs
  • Loading branch information
matthewjasper committed Feb 13, 2021
commit d785c8c447bd7f972e68e346a3f7b04c56ce486b
30 changes: 9 additions & 21 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,7 @@ fn project_type<'cx, 'tcx>(
return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
}

let obligation_trait_ref = &obligation.predicate.trait_ref(selcx.tcx());

debug!(?obligation_trait_ref);

if obligation_trait_ref.references_error() {
if obligation.predicate.references_error() {
return Ok(ProjectedTy::Progress(Progress::error(selcx.tcx())));
}

Expand All @@ -754,19 +750,19 @@ fn project_type<'cx, 'tcx>(
// Make sure that the following procedures are kept in order. ParamEnv
// needs to be first because it has highest priority, and Select checks
// the return value of push_candidate which assumes it's ran at last.
assemble_candidates_from_param_env(selcx, obligation, &obligation_trait_ref, &mut candidates);
assemble_candidates_from_param_env(selcx, obligation, &mut candidates);

assemble_candidates_from_trait_def(selcx, obligation, &obligation_trait_ref, &mut candidates);
assemble_candidates_from_trait_def(selcx, obligation, &mut candidates);

assemble_candidates_from_object_ty(selcx, obligation, &obligation_trait_ref, &mut candidates);
assemble_candidates_from_object_ty(selcx, obligation, &mut candidates);

if let ProjectionTyCandidateSet::Single(ProjectionTyCandidate::Object(_)) = candidates {
// Avoid normalization cycle from selection (see
// `assemble_candidates_from_object_ty`).
// FIXME(lazy_normalization): Lazy normalization should save us from
// having to do special case this.
// having to special case this.
} else {
assemble_candidates_from_impls(selcx, obligation, &obligation_trait_ref, &mut candidates);
assemble_candidates_from_impls(selcx, obligation, &mut candidates);
};

match candidates {
Expand All @@ -792,14 +788,12 @@ fn project_type<'cx, 'tcx>(
fn assemble_candidates_from_param_env<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
) {
debug!("assemble_candidates_from_param_env(..)");
assemble_candidates_from_predicates(
selcx,
obligation,
obligation_trait_ref,
candidate_set,
ProjectionTyCandidate::ParamEnv,
obligation.param_env.caller_bounds().iter(),
Expand All @@ -820,15 +814,14 @@ fn assemble_candidates_from_param_env<'cx, 'tcx>(
fn assemble_candidates_from_trait_def<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
) {
debug!("assemble_candidates_from_trait_def(..)");

let tcx = selcx.tcx();
// Check whether the self-type is itself a projection.
// If so, extract what we know from the trait and try to come up with a good answer.
let bounds = match *obligation_trait_ref.self_ty().kind() {
let bounds = match *obligation.predicate.self_ty().kind() {
ty::Projection(ref data) => tcx.item_bounds(data.item_def_id).subst(tcx, data.substs),
ty::Opaque(def_id, substs) => tcx.item_bounds(def_id).subst(tcx, substs),
ty::Infer(ty::TyVar(_)) => {
Expand All @@ -843,7 +836,6 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
assemble_candidates_from_predicates(
selcx,
obligation,
obligation_trait_ref,
candidate_set,
ProjectionTyCandidate::TraitDef,
bounds.iter(),
Expand All @@ -863,14 +855,13 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
fn assemble_candidates_from_object_ty<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
) {
debug!("assemble_candidates_from_object_ty(..)");

let tcx = selcx.tcx();

let self_ty = obligation_trait_ref.self_ty();
let self_ty = obligation.predicate.self_ty();
let object_ty = selcx.infcx().shallow_resolve(self_ty);
let data = match object_ty.kind() {
ty::Dynamic(data, ..) => data,
Expand All @@ -890,7 +881,6 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
assemble_candidates_from_predicates(
selcx,
obligation,
obligation_trait_ref,
candidate_set,
ProjectionTyCandidate::Object,
env_predicates,
Expand All @@ -901,7 +891,6 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
fn assemble_candidates_from_predicates<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
ctor: fn(ty::PolyProjectionPredicate<'tcx>) -> ProjectionTyCandidate<'tcx>,
env_predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
Expand Down Expand Up @@ -947,14 +936,13 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
fn assemble_candidates_from_impls<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,
obligation_trait_ref: &ty::TraitRef<'tcx>,
candidate_set: &mut ProjectionTyCandidateSet<'tcx>,
) {
debug!("assemble_candidates_from_impls");

// If we are resolving `<T as TraitRef<...>>::Item == Type`,
// start out by selecting the predicate `T as TraitRef<...>`:
let poly_trait_ref = ty::Binder::dummy(*obligation_trait_ref);
let poly_trait_ref = obligation.predicate.trait_ref(selcx.tcx()).to_poly_trait_ref();
let trait_obligation = obligation.with(poly_trait_ref.to_poly_trait_predicate());
let _ = selcx.infcx().commit_if_ok(|_| {
let impl_source = match selcx.select(&trait_obligation) {
Expand Down