1
Fork 0

rustc: use intern_* instead of mk_* where possible.

This commit is contained in:
Eduard-Mihai Burtescu 2018-05-16 10:43:24 +03:00
parent 196b2e0d82
commit 7e4d8718cb
6 changed files with 15 additions and 11 deletions

View file

@ -2600,7 +2600,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
pub fn mk_goal(self, goal: Goal<'tcx>) -> &'tcx Goal { 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, pub fn lint_node<S: Into<MultiSpan>>(self,

View file

@ -431,8 +431,10 @@ pub fn ty_fn_sig<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
sig.map_bound(|sig| { sig.map_bound(|sig| {
let state_did = tcx.lang_items().gen_state().unwrap(); let state_did = tcx.lang_items().gen_state().unwrap();
let state_adt_ref = tcx.adt_def(state_did); let state_adt_ref = tcx.adt_def(state_did);
let state_substs = tcx.mk_substs([sig.yield_ty.into(), let state_substs = tcx.intern_substs(&[
sig.return_ty.into()].iter()); sig.yield_ty.into(),
sig.return_ty.into(),
]);
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
tcx.mk_fn_sig(iter::once(env_ty), tcx.mk_fn_sig(iter::once(env_ty),

View file

@ -669,7 +669,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
assert_eq!(self.mir_def_id, def_id); assert_eq!(self.mir_def_id, def_id);
let ty = tcx.type_of(def_id); let ty = tcx.type_of(def_id);
let ty = indices.fold_to_region_vids(tcx, &ty); 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]))
} }
} }
} }

View file

@ -170,7 +170,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
} }
let substs = if let Some(ty) = ty { let substs = if let Some(ty) = ty {
tcx.mk_substs(iter::once(ty.into())) tcx.intern_substs(&[ty.into()])
} else { } else {
Substs::identity_for_item(tcx, def_id) Substs::identity_for_item(tcx, def_id)
}; };

View file

@ -861,8 +861,10 @@ impl MirPass for StateTransform {
// Compute GeneratorState<yield_ty, return_ty> // Compute GeneratorState<yield_ty, return_ty>
let state_did = tcx.lang_items().gen_state().unwrap(); let state_did = tcx.lang_items().gen_state().unwrap();
let state_adt_ref = tcx.adt_def(state_did); let state_adt_ref = tcx.adt_def(state_did);
let state_substs = tcx.mk_substs([yield_ty.into(), let state_substs = tcx.intern_substs(&[
mir.return_ty().into()].iter()); yield_ty.into(),
mir.return_ty().into(),
]);
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); 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 // We rename RETURN_PLACE which has type mir.return_ty to new_ret_local

View file

@ -220,7 +220,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
// `Implemented(Self: Trait<P1..Pn>) :- FromEnv(Self: Trait<P1..Pn>)` // `Implemented(Self: Trait<P1..Pn>) :- FromEnv(Self: Trait<P1..Pn>)`
let implemented_from_env = ProgramClause { let implemented_from_env = ProgramClause {
goal: impl_trait, 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))); let clauses = iter::once(Clause::ForAll(ty::Binder::dummy(implemented_from_env)));
@ -256,7 +256,7 @@ fn implied_bound_from_trait<'a, 'tcx>(
// `FromEnv(WC) :- FromEnv(Self: Trait<P1..Pn>)` // `FromEnv(WC) :- FromEnv(Self: Trait<P1..Pn>)`
Clause::ForAll(where_clause.lower().map_bound(|goal| ProgramClause { Clause::ForAll(where_clause.lower().map_bound(|goal| ProgramClause {
goal: goal.into_from_env_goal(), goal: goal.into_from_env_goal(),
hypotheses: tcx.mk_goals(iter::once(Goal::from(impl_trait))), hypotheses: tcx.intern_goals(&[Goal::from(impl_trait)]),
})) }))
} }
@ -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)), .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>( pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
@ -344,7 +344,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
.map(|wc| Goal::from_poly_domain_goal(wc, 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>) { pub fn dump_program_clauses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {