cargo fmt
This commit is contained in:
@@ -10,9 +10,9 @@ use rustc::hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisito
|
|||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
||||||
use rustc::ty::layout::LayoutOf;
|
use rustc::ty::layout::LayoutOf;
|
||||||
|
use rustc::ty::print::Printer;
|
||||||
use rustc::ty::{self, InferTy, Ty, TyCtxt, TypeckTables};
|
use rustc::ty::{self, InferTy, Ty, TyCtxt, TypeckTables};
|
||||||
use rustc::{declare_tool_lint, lint_array};
|
use rustc::{declare_tool_lint, lint_array};
|
||||||
use rustc::ty::print::Printer;
|
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc_typeck::hir_ty_to_ty;
|
use rustc_typeck::hir_ty_to_ty;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use rustc::hir::intravisit::{walk_item, walk_path, walk_ty, NestedVisitorMap, Vi
|
|||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
|
||||||
use rustc::ty;
|
use rustc::ty;
|
||||||
use rustc::{declare_tool_lint, lint_array};
|
|
||||||
use rustc::ty::DefIdTree;
|
use rustc::ty::DefIdTree;
|
||||||
|
use rustc::{declare_tool_lint, lint_array};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use syntax_pos::symbol::keywords::SelfUpper;
|
use syntax_pos::symbol::keywords::SelfUpper;
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ use if_chain::if_chain;
|
|||||||
use matches::matches;
|
use matches::matches;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::def::Def;
|
use rustc::hir::def::Def;
|
||||||
use rustc::hir::map::DisambiguatedDefPathData;
|
|
||||||
use rustc::hir::def_id::CrateNum;
|
use rustc::hir::def_id::CrateNum;
|
||||||
use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||||
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
|
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
|
||||||
|
use rustc::hir::map::DisambiguatedDefPathData;
|
||||||
use rustc::hir::Node;
|
use rustc::hir::Node;
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
use rustc::lint::{LateContext, Level, Lint, LintContext};
|
use rustc::lint::{LateContext, Level, Lint, LintContext};
|
||||||
@@ -43,7 +43,7 @@ use rustc_errors::Applicability;
|
|||||||
use syntax::ast::{self, LitKind};
|
use syntax::ast::{self, LitKind};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::source_map::{Span, DUMMY_SP};
|
use syntax::source_map::{Span, DUMMY_SP};
|
||||||
use syntax::symbol::{keywords, Symbol, LocalInternedString};
|
use syntax::symbol::{keywords, LocalInternedString, Symbol};
|
||||||
|
|
||||||
use crate::reexport::*;
|
use crate::reexport::*;
|
||||||
|
|
||||||
@@ -116,31 +116,22 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_region(
|
fn print_region(self, _region: ty::Region<'_>) -> Result<Self::Region, Self::Error> {
|
||||||
self,
|
|
||||||
_region: ty::Region<'_>,
|
|
||||||
) -> Result<Self::Region, Self::Error> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_type(
|
fn print_type(self, _ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
|
||||||
self,
|
|
||||||
_ty: Ty<'tcx>,
|
|
||||||
) -> Result<Self::Type, Self::Error> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
self,
|
self,
|
||||||
_predicates: &'tcx ty::List<ty::ExistentialPredicate<'tcx>>,
|
_predicates: &'tcx ty::List<ty::ExistentialPredicate<'tcx>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_crate(
|
fn path_crate(self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
|
||||||
self,
|
|
||||||
cnum: CrateNum,
|
|
||||||
) -> Result<Self::Path, Self::Error> {
|
|
||||||
Ok(vec![self.tcx.original_crate_name(cnum).as_str()])
|
Ok(vec![self.tcx.original_crate_name(cnum).as_str()])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +139,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
|
|||||||
self,
|
self,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
trait_ref: Option<ty::TraitRef<'tcx>>,
|
trait_ref: Option<ty::TraitRef<'tcx>>,
|
||||||
) -> Result<Self::Path, Self::Error> {
|
) -> Result<Self::Path, Self::Error> {
|
||||||
// This shouldn't ever be needed, but just in case:
|
// This shouldn't ever be needed, but just in case:
|
||||||
Ok(vec![match trait_ref {
|
Ok(vec![match trait_ref {
|
||||||
Some(trait_ref) => Symbol::intern(&format!("{:?}", trait_ref)).as_str(),
|
Some(trait_ref) => Symbol::intern(&format!("{:?}", trait_ref)).as_str(),
|
||||||
@@ -162,14 +153,12 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
|
|||||||
_disambiguated_data: &DisambiguatedDefPathData,
|
_disambiguated_data: &DisambiguatedDefPathData,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
trait_ref: Option<ty::TraitRef<'tcx>>,
|
trait_ref: Option<ty::TraitRef<'tcx>>,
|
||||||
) -> Result<Self::Path, Self::Error> {
|
) -> Result<Self::Path, Self::Error> {
|
||||||
let mut path = print_prefix(self)?;
|
let mut path = print_prefix(self)?;
|
||||||
|
|
||||||
// This shouldn't ever be needed, but just in case:
|
// This shouldn't ever be needed, but just in case:
|
||||||
path.push(match trait_ref {
|
path.push(match trait_ref {
|
||||||
Some(trait_ref) => {
|
Some(trait_ref) => Symbol::intern(&format!("<impl {} for {}>", trait_ref, self_ty)).as_str(),
|
||||||
Symbol::intern(&format!("<impl {} for {}>", trait_ref, self_ty)).as_str()
|
|
||||||
}
|
|
||||||
None => Symbol::intern(&format!("<impl {}>", self_ty)).as_str(),
|
None => Symbol::intern(&format!("<impl {}>", self_ty)).as_str(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -180,7 +169,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
|
|||||||
self,
|
self,
|
||||||
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
|
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
|
||||||
disambiguated_data: &DisambiguatedDefPathData,
|
disambiguated_data: &DisambiguatedDefPathData,
|
||||||
) -> Result<Self::Path, Self::Error> {
|
) -> Result<Self::Path, Self::Error> {
|
||||||
let mut path = print_prefix(self)?;
|
let mut path = print_prefix(self)?;
|
||||||
path.push(disambiguated_data.data.as_interned_str().as_str());
|
path.push(disambiguated_data.data.as_interned_str().as_str());
|
||||||
Ok(path)
|
Ok(path)
|
||||||
@@ -190,7 +179,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
|
|||||||
self,
|
self,
|
||||||
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
|
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
|
||||||
_args: &[Kind<'tcx>],
|
_args: &[Kind<'tcx>],
|
||||||
) -> Result<Self::Path, Self::Error> {
|
) -> Result<Self::Path, Self::Error> {
|
||||||
print_prefix(self)
|
print_prefix(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,7 +208,12 @@ pub fn match_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, path
|
|||||||
/// };
|
/// };
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Vec<&'static str> {
|
pub fn get_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Vec<&'static str> {
|
||||||
AbsolutePathPrinter { tcx }.print_def_path(def_id, &[]).unwrap().iter().map(LocalInternedString::get).collect()
|
AbsolutePathPrinter { tcx }
|
||||||
|
.print_def_path(def_id, &[])
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(LocalInternedString::get)
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if type is struct, enum or union type with the given def path.
|
/// Checks if type is struct, enum or union type with the given def path.
|
||||||
|
|||||||
Reference in New Issue
Block a user