Skip to content

Commit

Permalink
rustc: use intern_* instead of mk_* where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed May 21, 2018
1 parent 196b2e0 commit 7e4d871
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ty/context.rs
Expand Up @@ -2600,7 +2600,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

pub fn mk_goal(self, goal: Goal<'tcx>) -> &'tcx Goal {
&self.mk_goals(iter::once(goal))[0]
&self.intern_goals(&[goal])[0]
}

pub fn lint_node<S: Into<MultiSpan>>(self,
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_codegen_llvm/common.rs
Expand Up @@ -431,8 +431,10 @@ pub fn ty_fn_sig<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
sig.map_bound(|sig| {
let state_did = tcx.lang_items().gen_state().unwrap();
let state_adt_ref = tcx.adt_def(state_did);
let state_substs = tcx.mk_substs([sig.yield_ty.into(),
sig.return_ty.into()].iter());
let state_substs = tcx.intern_substs(&[
sig.yield_ty.into(),
sig.return_ty.into(),
]);
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);

tcx.mk_fn_sig(iter::once(env_ty),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/nll/universal_regions.rs
Expand Up @@ -669,7 +669,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
assert_eq!(self.mir_def_id, def_id);
let ty = tcx.type_of(def_id);
let ty = indices.fold_to_region_vids(tcx, &ty);
ty::Binder::dummy(tcx.mk_type_list(iter::once(ty)))
ty::Binder::dummy(tcx.intern_type_list(&[ty]))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/shim.rs
Expand Up @@ -170,7 +170,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}

let substs = if let Some(ty) = ty {
tcx.mk_substs(iter::once(ty.into()))
tcx.intern_substs(&[ty.into()])
} else {
Substs::identity_for_item(tcx, def_id)
};
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_mir/transform/generator.rs
Expand Up @@ -861,8 +861,10 @@ impl MirPass for StateTransform {
// Compute GeneratorState<yield_ty, return_ty>
let state_did = tcx.lang_items().gen_state().unwrap();
let state_adt_ref = tcx.adt_def(state_did);
let state_substs = tcx.mk_substs([yield_ty.into(),
mir.return_ty().into()].iter());
let state_substs = tcx.intern_substs(&[
yield_ty.into(),
mir.return_ty().into(),
]);
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);

// We rename RETURN_PLACE which has type mir.return_ty to new_ret_local
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_traits/lowering.rs
Expand Up @@ -220,7 +220,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
// `Implemented(Self: Trait<P1..Pn>) :- FromEnv(Self: Trait<P1..Pn>)`
let implemented_from_env = ProgramClause {
goal: impl_trait,
hypotheses: tcx.mk_goals(iter::once(from_env)),
hypotheses: tcx.intern_goals(&[from_env]),
};
let clauses = iter::once(Clause::ForAll(ty::Binder::dummy(implemented_from_env)));

Expand Down Expand Up @@ -256,7 +256,7 @@ fn implied_bound_from_trait<'a, 'tcx>(
// `FromEnv(WC) :- FromEnv(Self: Trait<P1..Pn>)`
Clause::ForAll(where_clause.lower().map_bound(|goal| ProgramClause {
goal: goal.into_from_env_goal(),
hypotheses: tcx.mk_goals(iter::once(Goal::from(impl_trait))),
hypotheses: tcx.intern_goals(&[Goal::from(impl_trait)]),
}))
}

Expand Down Expand Up @@ -290,7 +290,7 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
.map(|wc| Goal::from_poly_domain_goal(wc, tcx)),
),
};
tcx.mk_clauses(iter::once(Clause::ForAll(ty::Binder::dummy(clause))))
tcx.intern_clauses(&[Clause::ForAll(ty::Binder::dummy(clause))])
}

pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
Expand Down Expand Up @@ -344,7 +344,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
.map(|wc| Goal::from_poly_domain_goal(wc, tcx)),
),
};
tcx.mk_clauses(iter::once(Clause::ForAll(ty::Binder::dummy(clause))))
tcx.intern_clauses(&[Clause::ForAll(ty::Binder::dummy(clause))])
}

pub fn dump_program_clauses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
Expand Down

0 comments on commit 7e4d871

Please sign in to comment.