expose a method for converting hir::Ty
to Ty<'tcx>
Also, remove a lot of `pub` things from `librustc_typeck`.
This commit is contained in:
parent
ed1f26ddda
commit
5efc86a838
@ -965,10 +965,6 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.pushed == 0
|
||||
}
|
||||
|
||||
/// Return the "expected type" with which this coercion was
|
||||
/// constructed. This represents the "downward propagated" type
|
||||
/// that was given to us at the start of typing whatever construct
|
||||
|
@ -116,7 +116,7 @@ pub fn provide(providers: &mut Providers) {
|
||||
/// `ItemCtxt` is parameterized by a `DefId` that it uses to satisfy
|
||||
/// `get_type_parameter_bounds` requests, drawing the information from
|
||||
/// the AST (`hir::Generics`), recursively.
|
||||
struct ItemCtxt<'a,'tcx:'a> {
|
||||
pub struct ItemCtxt<'a,'tcx:'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
item_def_id: DefId,
|
||||
}
|
||||
@ -180,7 +180,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||
// Utility types and common code for the above passes.
|
||||
|
||||
impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
|
||||
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId)
|
||||
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId)
|
||||
-> ItemCtxt<'a,'tcx> {
|
||||
ItemCtxt {
|
||||
tcx: tcx,
|
||||
@ -190,7 +190,7 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a,'tcx> ItemCtxt<'a,'tcx> {
|
||||
fn to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
|
||||
pub fn to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
|
||||
AstConv::ast_ty_to_ty(self, ast_ty)
|
||||
}
|
||||
}
|
||||
|
@ -122,14 +122,14 @@ use std::iter;
|
||||
// registered before they are used.
|
||||
pub mod diagnostics;
|
||||
|
||||
pub mod check;
|
||||
pub mod check_unused;
|
||||
mod check;
|
||||
mod check_unused;
|
||||
mod astconv;
|
||||
pub mod collect;
|
||||
mod collect;
|
||||
mod constrained_type_params;
|
||||
mod impl_wf_check;
|
||||
pub mod coherence;
|
||||
pub mod variance;
|
||||
mod coherence;
|
||||
mod variance;
|
||||
|
||||
pub struct TypeAndSubsts<'tcx> {
|
||||
pub substs: &'tcx Substs<'tcx>,
|
||||
@ -337,4 +337,16 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
||||
}
|
||||
}
|
||||
|
||||
/// A quasi-deprecated helper used in rustdoc and save-analysis to get
|
||||
/// the type from a HIR node.
|
||||
pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) -> Ty<'tcx> {
|
||||
// In case there are any projections etc, find the "environment"
|
||||
// def-id that will be used to determine the traits/predicates in
|
||||
// scope. This is derived from the enclosing item-like thing.
|
||||
let env_node_id = tcx.hir.get_parent(hir_ty.id);
|
||||
let env_def_id = tcx.hir.local_def_id(env_node_id);
|
||||
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id);
|
||||
item_cx.to_ty(hir_ty)
|
||||
}
|
||||
|
||||
__build_diagnostic_array! { librustc_typeck, DIAGNOSTICS }
|
||||
|
Loading…
Reference in New Issue
Block a user