Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
33696fa
Add Arc::into_inner for safely discarding Arcs without calling the de…
steffahn Aug 25, 2020
26e2360
Use correct pseudo-element selector
GuillaumeGomez Jan 22, 2023
e0b3d72
add fmease to mailmap
fmease Jan 22, 2023
12a72f0
Update universal_regions.rs
smoelius Jan 22, 2023
81ee6ae
Remove duplicated debug call
spastorino Nov 24, 2022
7fe4722
Store relationships on Inherent
spastorino Nov 25, 2022
fb0a4e9
Move relationships::update to Inherited::update_infer_var_info
spastorino Jan 20, 2023
6155a80
Rename relationships to infer_var_info
spastorino Jan 20, 2023
b905f80
fn-trait-closure test now pass on new solver
spastorino Jan 22, 2023
2aa5555
Fix #106496, suggest remove deref for type mismatch
chenyukang Jan 22, 2023
f908f0b
Consider doc(alias) when providing typo suggestions
sulami Jan 18, 2023
3d4c312
Rollup merge of #104926 - spastorino:calculate_diverging_fallback-cle…
Dylan-DPC Jan 23, 2023
28081a6
Rollup merge of #106854 - steffahn:drop_linear_arc_rebased, r=Mark-Si…
Dylan-DPC Jan 23, 2023
f4f3335
Rollup merge of #107108 - sulami:issue-83968-doc-alias-typo-suggestio…
Dylan-DPC Jan 23, 2023
d959376
Rollup merge of #107186 - GuillaumeGomez:correct-pseudo-element-selec…
Dylan-DPC Jan 23, 2023
4f6fc4d
Rollup merge of #107192 - fmease:mailmap-me-at-fmease-dev, r=albertla…
Dylan-DPC Jan 23, 2023
e4ed082
Rollup merge of #107195 - smoelius:patch-2, r=Nilstrieb
Dylan-DPC Jan 23, 2023
66d6a0b
Rollup merge of #107203 - chenyukang:yukang/fix-106496-remove-deref, …
Dylan-DPC Jan 23, 2023
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
Move relationships::update to Inherited::update_infer_var_info
  • Loading branch information
spastorino committed Jan 22, 2023
commit fb0a4e958950ed4dabc954c8a258594847b1d9bc
48 changes: 42 additions & 6 deletions compiler/rustc_hir_typeck/src/inherited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use rustc_middle::ty::visit::TypeVisitable;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::def_id::LocalDefIdMap;
use rustc_span::{self, Span};
use rustc_trait_selection::traits::{self, TraitEngine, TraitEngineExt as _};
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use rustc_trait_selection::traits::{self, PredicateObligation, TraitEngine, TraitEngineExt as _};

use std::cell::RefCell;
use std::ops::Deref;
Expand Down Expand Up @@ -140,11 +141,7 @@ impl<'tcx> Inherited<'tcx> {
span_bug!(obligation.cause.span, "escaping bound vars in predicate {:?}", obligation);
}

super::relationships::update(
&self.infcx,
&mut self.relationships.borrow_mut(),
&obligation,
);
self.update_infer_var_info(&obligation);

self.fulfillment_cx.borrow_mut().register_predicate_obligation(self, obligation);
}
Expand All @@ -162,4 +159,43 @@ impl<'tcx> Inherited<'tcx> {
self.register_predicates(infer_ok.obligations);
infer_ok.value
}

pub fn update_infer_var_info(&self, obligation: &PredicateObligation<'tcx>) {
let relationships = &mut self.relationships.borrow_mut();

// (*) binder skipped
if let ty::PredicateKind::Clause(ty::Clause::Trait(tpred)) = obligation.predicate.kind().skip_binder()
&& let Some(ty) = self.shallow_resolve(tpred.self_ty()).ty_vid().map(|t| self.root_var(t))
&& self.tcx.lang_items().sized_trait().map_or(false, |st| st != tpred.trait_ref.def_id)
{
let new_self_ty = self.tcx.types.unit;

// Then construct a new obligation with Self = () added
// to the ParamEnv, and see if it holds.
let o = obligation.with(self.tcx,
obligation
.predicate
.kind()
.rebind(
// (*) binder moved here
ty::PredicateKind::Clause(ty::Clause::Trait(tpred.with_self_ty(self.tcx, new_self_ty)))
),
);
// Don't report overflow errors. Otherwise equivalent to may_hold.
if let Ok(result) = self.probe(|_| self.evaluate_obligation(&o)) && result.may_apply() {
relationships.entry(ty).or_default().self_in_trait = true;
}
}

if let ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) =
obligation.predicate.kind().skip_binder()
{
// If the projection predicate (Foo::Bar == X) has X as a non-TyVid,
// we need to make it into one.
if let Some(vid) = predicate.term.ty().and_then(|ty| ty.ty_vid()) {
debug!("relationships: {:?}.output = true", vid);
relationships.entry(vid).or_default().output = true;
}
}
}
}
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mod method;
mod op;
mod pat;
mod place_op;
mod relationships;
mod rvalue_scopes;
mod upvar;
mod writeback;
Expand Down
46 changes: 0 additions & 46 deletions compiler/rustc_hir_typeck/src/relationships.rs

This file was deleted.