Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
033bd8c
Explain a test
matthewjasper Dec 26, 2019
7f41cf4
Check associated opaque types don't use unconstrained lifetimes
matthewjasper Dec 26, 2019
4af0952
Call `is_freeze` less in unsafety-checking
matthewjasper Dec 28, 2019
60970be
Distinguish RPIT from other impl trait
matthewjasper Dec 28, 2019
43dae91
Give some more queries descriptions
matthewjasper Dec 28, 2019
9664122
Simplify function signature in opaque_types
matthewjasper Dec 26, 2019
378b5b4
Generate more accurate MIR in `construct_error`
matthewjasper Dec 26, 2019
43a3348
Arena allocate the result of mir_borrowck
matthewjasper Dec 26, 2019
75ac0cc
Prepare to use borrowck to resolve opaque types
matthewjasper Dec 25, 2019
d9b9f00
Infer opaque type regions in borrow checking
matthewjasper Dec 26, 2019
edee23e
Avoid unnecessary opaque type errors in borrowck
matthewjasper Dec 28, 2019
2fb0254
Ensure RPIT types get recorded in borrowck
matthewjasper Dec 28, 2019
bb8c991
Erase regions in opaque types in typeck
matthewjasper Dec 28, 2019
93ac5bc
Update tests
matthewjasper Dec 28, 2019
f23bca7
Address review comments
matthewjasper Dec 29, 2019
728224d
Show inferred opaque types with `#[rustc_regions]`
matthewjasper Jan 5, 2020
5cfa7d1
Handle equal regions in opaque type inference
matthewjasper Jan 8, 2020
2bd16f3
Improve opaque type lifetime errors
matthewjasper Jan 11, 2020
dd1687e
Always check upper bounds when choosing member regions
matthewjasper Jan 11, 2020
e3e5d27
Use member constraint for most opaque types in NLL
matthewjasper Jan 11, 2020
78e0ab5
Update tests
matthewjasper Jan 11, 2020
6d9e270
Fix and test nested impl Trait
matthewjasper Jan 12, 2020
223a2ee
Add fast path to eq_opaque_type_and_type
matthewjasper Jan 17, 2020
edddb62
Split `type_of` out of collect.rs
matthewjasper Jan 17, 2020
d863978
Fix tests after rebase
matthewjasper Feb 14, 2020
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
Add fast path to eq_opaque_type_and_type
  • Loading branch information
matthewjasper committed Feb 14, 2020
commit 223a2ee3061a4bfe31df8aee70c682618ef28fe1
2 changes: 1 addition & 1 deletion src/librustc/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl FlagComputation {
}

&ty::Opaque(_, substs) => {
self.add_flags(TypeFlags::HAS_PROJECTION);
self.add_flags(TypeFlags::HAS_PROJECTION | TypeFlags::HAS_TY_OPAQUE);
self.add_substs(substs);
}

Expand Down
3 changes: 3 additions & 0 deletions src/librustc/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
fn has_projections(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_PROJECTION)
}
fn has_opaque_types(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_TY_OPAQUE)
}
fn references_error(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_TY_ERR)
}
Expand Down
5 changes: 4 additions & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ bitflags! {

const HAS_CT_INFER = 1 << 14;
const HAS_CT_PLACEHOLDER = 1 << 15;
/// Does this have any [Opaque] types.
const HAS_TY_OPAQUE = 1 << 16;

const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
TypeFlags::HAS_RE_EARLY_BOUND.bits;
Expand All @@ -503,7 +505,8 @@ bitflags! {
TypeFlags::HAS_RE_ERASED.bits |
TypeFlags::HAS_TY_PLACEHOLDER.bits |
TypeFlags::HAS_CT_INFER.bits |
TypeFlags::HAS_CT_PLACEHOLDER.bits;
TypeFlags::HAS_CT_PLACEHOLDER.bits |
TypeFlags::HAS_TY_OPAQUE.bits;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ impl<'tcx> TyCtxt<'tcx> {
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Opaque(def_id, substs) = t.kind {
self.expand_opaque_ty(def_id, substs).unwrap_or(t)
} else if t.has_projections() {
} else if t.has_opaque_types() {
t.super_fold_with(self)
} else {
t
Expand Down
16 changes: 16 additions & 0 deletions src/librustc_mir/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,22 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
anon_ty={:?})",
revealed_ty, anon_ty
);

// Fast path for the common case.
if !anon_ty.has_opaque_types() {
if let Err(terr) = self.eq_types(anon_ty, revealed_ty, locations, category) {
span_mirbug!(
self,
locations,
"eq_opaque_type_and_type: `{:?}=={:?}` failed with `{:?}`",
revealed_ty,
anon_ty,
terr
);
}
return Ok(());
}

let infcx = self.infcx;
let tcx = infcx.tcx;
let param_env = self.param_env;
Expand Down