Skip to content

Commit 8dc79e0

Browse files
author
Alexander Regueiro
committed
WIP
1 parent faed02c commit 8dc79e0

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/librustc_typeck/astconv.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
13611361
let span = path.span;
13621362
match path.def {
13631363
Def::Existential(did) => {
1364-
// check for desugared impl trait
1364+
// Check for desugared impl trait.
13651365
assert!(ty::is_impl_trait_defn(tcx, did).is_none());
13661366
let item_segment = path.segments.split_last().unwrap();
13671367
self.prohibit_generics(item_segment.1);
@@ -1398,8 +1398,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
13981398
tcx.mk_ty_param(index, tcx.hir.name(node_id).as_interned_str())
13991399
}
14001400
Def::SelfTy(_, Some(def_id)) => {
1401-
// Self in impl (we know the concrete type).
1402-
1401+
// Self in impl. (We know the concrete type.)
14031402
assert_eq!(opt_self_ty, None);
14041403
self.prohibit_generics(&path.segments);
14051404

src/librustc_typeck/check/coercion.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use rustc::infer::{Coercion, InferResult, InferOk};
6868
use rustc::infer::type_variable::TypeVariableOrigin;
6969
use rustc::traits::{self, ObligationCause, ObligationCauseCode};
7070
use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
71-
use rustc::ty::{self, TypeAndMut, Ty, ClosureSubsts};
71+
use rustc::ty::{self, DefIdTree, TypeAndMut, Ty, ClosureSubsts};
7272
use rustc::ty::fold::TypeFoldable;
7373
use rustc::ty::error::TypeError;
7474
use rustc::ty::relate::RelateResult;
@@ -537,9 +537,6 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> {
537537
}
538538
})?;
539539

540-
// Instantiate opaque type in tables.
541-
self.fcx.instantiate_opaque_types_from_return_value(self., &coerce_source);
542-
543540
// Create the obligations for `Source` satisfying the target predicates.
544541
let cause = ObligationCause::misc(self.cause.span, self.fcx.body_id);
545542
let obligations = traits::predicates_for_generics(cause,

src/librustc_typeck/check/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
1313
# check.rs
1414
15-
Within the check phase of type check, we check each item one at a time
15+
Within the check phase of type checking, we check each item one at a time
1616
(bodies of function expressions are checked as part of the containing
17-
function). Inference is used to supply types wherever they are
18-
unknown.
17+
function). Inference is used to supply types wherever they are unknown.
1918
2019
By far the most complex case is checking the body of a function. This
2120
can be broken down into several distinct phases:
@@ -1026,9 +1025,11 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
10261025
let mut fcx = FnCtxt::new(inherited, param_env, body.value.id);
10271026
*fcx.ps.borrow_mut() = UnsafetyState::function(fn_sig.unsafety, fn_id);
10281027

1028+
let fn_def_id = fcx.tcx.hir.local_def_id(fn_id);
10291029
let declared_ret_ty = fn_sig.output();
10301030
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
1031-
let revealed_ret_ty = fcx.instantiate_opaque_types_from_return_value(fn_id, &declared_ret_ty);
1031+
let revealed_ret_ty = fcx.instantiate_opaque_types_from_return_value(
1032+
fn_def_id, &declared_ret_ty);
10321033
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty)));
10331034
fn_sig = fcx.tcx.mk_fn_sig(
10341035
fn_sig.inputs().iter().cloned(),
@@ -2248,10 +2249,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
22482249
/// `InferCtxt::instantiate_opaque_types` for more details.
22492250
fn instantiate_opaque_types_from_return_value<T: TypeFoldable<'tcx>>(
22502251
&self,
2251-
parent_id: ast::NodeId,
2252+
parent_def_id: DefId,
22522253
value: &T,
22532254
) -> T {
2254-
let parent_def_id = self.tcx.hir.local_def_id(parent_id);
22552255
debug!("instantiate_opaque_types_from_return_value(parent_def_id={:?}, value={:?})",
22562256
parent_def_id,
22572257
value);
@@ -5274,7 +5274,9 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
52745274
if own_counts.types == 0 {
52755275
return;
52765276
}
5277+
52775278
// Make a vector of booleans initially false, set to true when used.
5279+
// FIXME: use `BitSet` here instead.
52785280
let mut types_used = vec![false; own_counts.types];
52795281

52805282
for leaf_ty in ty.walk() {

src/librustc_typeck/collect.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@ fn find_existential_constraints<'a, 'tcx>(
13651365
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
13661366
intravisit::NestedVisitorMap::All(&self.tcx.hir)
13671367
}
1368+
13681369
fn visit_item(&mut self, it: &'tcx Item) {
13691370
let def_id = self.tcx.hir.local_def_id(it.id);
13701371
// The existential type itself or its children are not within its reveal scope.
@@ -1373,6 +1374,7 @@ fn find_existential_constraints<'a, 'tcx>(
13731374
intravisit::walk_item(self, it);
13741375
}
13751376
}
1377+
13761378
fn visit_impl_item(&mut self, it: &'tcx ImplItem) {
13771379
let def_id = self.tcx.hir.local_def_id(it.id);
13781380
// The existential type itself or its children are not within its reveal scope.
@@ -1381,6 +1383,7 @@ fn find_existential_constraints<'a, 'tcx>(
13811383
intravisit::walk_impl_item(self, it);
13821384
}
13831385
}
1386+
13841387
fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
13851388
let def_id = self.tcx.hir.local_def_id(it.id);
13861389
self.check(def_id);

0 commit comments

Comments
 (0)