rapx/analysis/core/api_dependency/graph/
std_tys.rs1use rustc_hir::LangItem;
2use rustc_middle::ty::{self, Ty, TyCtxt};
3use rustc_span::sym;
4
5pub fn std_vec<'tcx>(element_ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
6 let vec_def_id = tcx
7 .get_diagnostic_item(sym::Vec)
8 .expect("Vec should be defined in std");
9 let alloc_def_id = tcx
10 .lang_items()
11 .global_alloc_ty()
12 .expect("Global should be defined in std");
13 let alloc_ty = tcx.type_of(alloc_def_id).skip_binder();
14 let args = tcx.mk_args(&[
15 ty::GenericArg::from(element_ty),
16 ty::GenericArg::from(alloc_ty),
17 ]);
18 Ty::new_adt(tcx, tcx.adt_def(vec_def_id), args)
19}