Skip to content

Commit 0bff861

Browse files
Remove FinderTrait and move its functions into DocContext
1 parent fc81adb commit 0bff861

File tree

5 files changed

+150
-180
lines changed

5 files changed

+150
-180
lines changed

src/librustdoc/clean/auto_trait.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use rustc::middle::cstore::CrateStore;
1717
use std::fmt::Debug;
1818

1919
use self::def_ctor::{get_def_from_def_id, get_def_from_node_id};
20-
use self::finder_trait::Finder;
2120

2221
use super::*;
2322

@@ -168,14 +167,14 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
168167
_ => unreachable!(),
169168
};
170169
let real_name = name.map(|name| Ident::from_str(&name));
171-
let ty = self.get_real_ty(def_id, def_ctor, &real_name, &generics);
170+
let ty = self.cx.get_real_ty(def_id, def_ctor, &real_name, &generics);
172171

173172
return Some(Item {
174173
source: Span::empty(),
175174
name: None,
176175
attrs: Default::default(),
177176
visibility: None,
178-
def_id: self.next_def_id(def_id.krate),
177+
def_id: self.cx.next_def_id(def_id.krate),
179178
stability: None,
180179
deprecation: None,
181180
inner: ImplItem(Impl {
@@ -862,12 +861,6 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
862861
}
863862
}
864863

865-
impl<'a, 'tcx: 'a, 'rcx: 'a> Finder<'a, 'tcx, 'rcx> for AutoTraitFinder<'a, 'tcx, 'rcx> {
866-
fn get_cx(&self) -> &DocContext<'a, 'tcx, 'rcx> {
867-
&self.cx
868-
}
869-
}
870-
871864
// Replaces all ReVars in a type with ty::Region's, using the provided map
872865
struct RegionReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
873866
vid_to_region: &'a FxHashMap<ty::RegionVid, ty::Region<'tcx>>,

src/librustdoc/clean/blanket_impl.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use core::DocAccessLevels;
2020
use super::*;
2121

2222
use self::def_ctor::{get_def_from_def_id, get_def_from_node_id};
23-
use self::finder_trait::Finder;
2423

2524
pub struct BlanketImplFinder<'a, 'tcx: 'a, 'rcx: 'a> {
2625
pub cx: &'a core::DocContext<'a, 'tcx, 'rcx>,
@@ -127,15 +126,15 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
127126
.map(|meth| meth.ident.to_string())
128127
.collect();
129128

130-
let ty = self.get_real_ty(def_id, def_ctor, &real_name, generics);
129+
let ty = self.cx.get_real_ty(def_id, def_ctor, &real_name, generics);
131130
let predicates = infcx.tcx.predicates_of(impl_def_id);
132131

133132
impls.push(Item {
134133
source: infcx.tcx.def_span(impl_def_id).clean(self.cx),
135134
name: None,
136135
attrs: Default::default(),
137136
visibility: None,
138-
def_id: self.next_def_id(impl_def_id.krate),
137+
def_id: self.cx.next_def_id(impl_def_id.krate),
139138
stability: None,
140139
deprecation: None,
141140
inner: ImplItem(Impl {
@@ -161,9 +160,3 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
161160
impls
162161
}
163162
}
164-
165-
impl<'a, 'tcx: 'a, 'rcx: 'a> Finder<'a, 'tcx, 'rcx> for BlanketImplFinder<'a, 'tcx, 'rcx> {
166-
fn get_cx(&self) -> &DocContext<'a, 'tcx, 'rcx> {
167-
&self.cx
168-
}
169-
}

src/librustdoc/clean/finder_trait.rs

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/librustdoc/clean/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ use rustc::middle::lang_items;
3737
use rustc::mir::interpret::GlobalId;
3838
use rustc::hir::{self, GenericArg, HirVec};
3939
use rustc::hir::def::{self, Def, CtorKind};
40-
use rustc::hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
41-
use rustc::hir::def_id::DefIndexAddressSpace;
40+
use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
4241
use rustc::hir::map::Node;
4342
use rustc::ty::subst::Substs;
4443
use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind};
@@ -75,13 +74,13 @@ mod simplify;
7574
mod auto_trait;
7675
mod blanket_impl;
7776
pub mod def_ctor;
78-
mod finder_trait;
7977

8078
use self::cfg::Cfg;
8179
use self::auto_trait::AutoTraitFinder;
8280
use self::blanket_impl::BlanketImplFinder;
8381

84-
thread_local!(static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = RefCell::new(FxHashMap()));
82+
thread_local!(pub static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> =
83+
RefCell::new(FxHashMap()));
8584

8685
const FN_OUTPUT_NAME: &'static str = "Output";
8786

@@ -4505,7 +4504,7 @@ pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
45054504
}
45064505
}
45074506

4508-
fn get_path_for_type<F>(tcx: TyCtxt, def_id: DefId, def_ctor: F) -> hir::Path
4507+
pub fn get_path_for_type<F>(tcx: TyCtxt, def_id: DefId, def_ctor: F) -> hir::Path
45094508
where F: Fn(DefId) -> Def {
45104509
struct AbsolutePathBuffer {
45114510
names: Vec<String>,

0 commit comments

Comments
 (0)