Skip to content

Refactor auto trait handling in librustdoc to be accessible from librustc. #49711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 9, 2018
Merged
Prev Previous commit
Next Next commit
Simplified name mapping in auto trait handling.
  • Loading branch information
ibabushkin committed Apr 26, 2018
commit 388defad2d754cf9fc6ec69d67692f437393fd03
8 changes: 3 additions & 5 deletions src/librustc/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<A> AutoTraitResult<A> {
pub struct AutoTraitInfo<'cx> {
pub full_user_env: ty::ParamEnv<'cx>,
pub region_data: RegionConstraintData<'cx>,
pub names_map: FxHashMap<String, String>,
pub names_map: FxHashSet<String>,
pub vid_to_region: FxHashMap<ty::RegionVid, ty::Region<'cx>>,
}

Expand Down Expand Up @@ -206,12 +206,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
)
});

let names_map: FxHashMap<String, String> = generics
let names_map: FxHashSet<String> = generics
.regions
.iter()
.map(|l| (l.name.to_string(), l.name.to_string()))
// TODO(twk): Lifetime branding and why is this map a set?!
// l.clean(self.cx) was present in the original code
.map(|l| l.name.to_string())
.collect();

let body_ids: FxHashSet<_> = infcx
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
let names_map =
info.names_map
.drain()
.map(|(name, lifetime)| (name, Lifetime(lifetime)))
.map(|name| (name.clone(), Lifetime(name)))
.collect();
let lifetime_predicates =
self.handle_lifetimes(&region_data, &names_map);
Expand Down