Simplify DefIdForest.
This commit is contained in:
parent
c9de7d7a20
commit
a5b7e235d3
2 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
use crate::ty::context::TyCtxt;
|
use crate::ty::context::TyCtxt;
|
||||||
use crate::ty::{DefId, DefIdTree};
|
use crate::ty::{DefId, DefIdTree};
|
||||||
use rustc_hir::CRATE_HIR_ID;
|
use rustc_span::def_id::CRATE_DEF_ID;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -43,8 +43,8 @@ impl<'tcx> DefIdForest {
|
||||||
/// Creates a forest consisting of a single tree representing the entire
|
/// Creates a forest consisting of a single tree representing the entire
|
||||||
/// crate.
|
/// crate.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn full(tcx: TyCtxt<'tcx>) -> DefIdForest {
|
pub fn full() -> DefIdForest {
|
||||||
DefIdForest::from_id(tcx.hir().local_def_id(CRATE_HIR_ID).to_def_id())
|
DefIdForest::from_id(CRATE_DEF_ID.to_def_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a forest containing a `DefId` and all its descendants.
|
/// Creates a forest containing a `DefId` and all its descendants.
|
||||||
|
@ -96,7 +96,7 @@ impl<'tcx> DefIdForest {
|
||||||
let mut ret: SmallVec<[_; 1]> = if let Some(first) = iter.next() {
|
let mut ret: SmallVec<[_; 1]> = if let Some(first) = iter.next() {
|
||||||
SmallVec::from_slice(first.as_slice())
|
SmallVec::from_slice(first.as_slice())
|
||||||
} else {
|
} else {
|
||||||
return DefIdForest::full(tcx);
|
return DefIdForest::full();
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut next_ret: SmallVec<[_; 1]> = SmallVec::new();
|
let mut next_ret: SmallVec<[_; 1]> = SmallVec::new();
|
||||||
|
|
|
@ -205,7 +205,7 @@ pub(crate) fn type_uninhabited_from<'tcx>(
|
||||||
match *ty.kind() {
|
match *ty.kind() {
|
||||||
Adt(def, substs) => def.uninhabited_from(tcx, substs, param_env),
|
Adt(def, substs) => def.uninhabited_from(tcx, substs, param_env),
|
||||||
|
|
||||||
Never => DefIdForest::full(tcx),
|
Never => DefIdForest::full(),
|
||||||
|
|
||||||
Tuple(ref tys) => DefIdForest::union(
|
Tuple(ref tys) => DefIdForest::union(
|
||||||
tcx,
|
tcx,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue