Skip to content

Commit 1531fbe

Browse files
committed
Cleanup formatting
1 parent 9d7165f commit 1531fbe

File tree

7 files changed

+37
-79
lines changed

7 files changed

+37
-79
lines changed

src/librustc/traits/select.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
429429
intercrate: None,
430430
inferred_obligations: SnapshotVec::new(),
431431
intercrate_ambiguity_causes: None,
432-
allow_negative_impls: false
432+
allow_negative_impls: false,
433433
}
434434
}
435435

@@ -442,7 +442,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
442442
intercrate: Some(mode),
443443
inferred_obligations: SnapshotVec::new(),
444444
intercrate_ambiguity_causes: None,
445-
allow_negative_impls: false
445+
allow_negative_impls: false,
446446
}
447447
}
448448

@@ -455,7 +455,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
455455
intercrate: None,
456456
inferred_obligations: SnapshotVec::new(),
457457
intercrate_ambiguity_causes: None,
458-
allow_negative_impls
458+
allow_negative_impls,
459459
}
460460
}
461461

src/librustdoc/clean/auto_trait.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
315315

316316
// Due to the way projections are handled by SelectionContext, we need to run
317317
// evaluate_predicates twice: once on the original param env, and once on the result of
318-
// the first evaluate_predicates call
318+
// the first evaluate_predicates call.
319319
//
320320
// The problem is this: most of rustc, including SelectionContext and traits::project,
321321
// are designed to work with a concrete usage of a type (e.g. Vec<u8>
@@ -338,7 +338,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
338338
// We fix the first assumption by manually clearing out all of the InferCtxt's caches
339339
// in between calls to SelectionContext.select. This allows us to keep all of the
340340
// intermediate types we create bound to the 'tcx lifetime, rather than needing to lift
341-
// them between calls
341+
// them between calls.
342342
//
343343
// We fix the second assumption by reprocessing the result of our first call to
344344
// evaluate_predicates. Using the example of '<T as SomeTrait>::SomeItem = K', our first
@@ -457,13 +457,8 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
457457
infcx.freshen(p)
458458
}
459459

460-
fn evaluate_nested_obligations<
461-
'b,
462-
'c,
463-
'd,
464-
'cx,
465-
T: Iterator<Item = Obligation<'cx, ty::Predicate<'cx>>>,
466-
>(
460+
fn evaluate_nested_obligations<'b, 'c, 'd, 'cx,
461+
T: Iterator<Item = Obligation<'cx, ty::Predicate<'cx>>>>(
467462
&self,
468463
ty: ty::Ty,
469464
nested: T,
@@ -732,8 +727,8 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
732727
}
733728
}
734729

735-
// This is very simiiar to handle_lifetimes. Instead of matching ty::Region's to ty::Region's,
736-
// however, we match ty::RegionVid's to ty::Region's
730+
// This is very similar to handle_lifetimes. However, instead of matching ty::Region's
731+
// to each other, we match ty::RegionVid's to ty::Region's
737732
fn map_vid_to_region<'cx>(
738733
&self,
739734
regions: &RegionConstraintData<'cx>,
@@ -843,7 +838,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
843838
// with determining if a given set up constraints/predicates *are* met, given some
844839
// starting conditions (e.g. user-provided code). For this reason, it's easier
845840
// to perform the calculations we need on our own, rather than trying to make
846-
// existing inference/solver code do what we want
841+
// existing inference/solver code do what we want.
847842
fn handle_lifetimes<'cx>(
848843
&self,
849844
regions: &RegionConstraintData<'cx>,
@@ -852,8 +847,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
852847
// Our goal is to 'flatten' the list of constraints by eliminating
853848
// all intermediate RegionVids. At the end, all constraints should
854849
// be between Regions (aka region variables). This gives us the information
855-
// we need to create the Generics
856-
//
850+
// we need to create the Generics.
857851
let mut finished = FxHashMap();
858852

859853
let mut vid_map: FxHashMap<RegionTarget, RegionDeps> = FxHashMap();
@@ -1021,7 +1015,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
10211015
ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)>,
10221016
lifetime_to_bounds: FxHashMap<Lifetime, FxHashSet<Lifetime>>,
10231017
) -> Vec<WherePredicate> {
1024-
let final_predicates = ty_to_bounds
1018+
ty_to_bounds
10251019
.into_iter()
10261020
.flat_map(|(ty, mut bounds)| {
10271021
if let Some(data) = ty_to_fn.get(&ty) {
@@ -1096,9 +1090,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
10961090
bounds: bounds.into_iter().collect(),
10971091
}),
10981092
)
1099-
.collect();
1100-
1101-
final_predicates
1093+
.collect()
11021094
}
11031095

11041096
// Converts the calculated ParamEnv and lifetime information to a clean::Generics, suitable for
@@ -1380,7 +1372,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
13801372
}
13811373

13821374
// This is an ugly hack, but it's the simplest way to handle synthetic impls without greatly
1383-
// refactorying either librustdoc or librustc. In particular, allowing new DefIds to be
1375+
// refactoring either librustdoc or librustc. In particular, allowing new DefIds to be
13841376
// registered after the AST is constructed would require storing the defid mapping in a
13851377
// RefCell, decreasing the performance for normal compilation for very little gain.
13861378
//

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ pub fn load_attrs(cx: &DocContext, did: DefId) -> clean::Attributes {
120120
cx.tcx.get_attrs(did).clean(cx)
121121
}
122122

123-
124123
/// Record an external fully qualified name in the external_paths cache.
125124
///
126125
/// These names are used later on by HTML rendering to generate things like
@@ -267,7 +266,6 @@ pub fn build_impls(cx: &DocContext, did: DefId, auto_traits: bool) -> Vec<clean:
267266

268267
cx.populated_all_crate_impls.set(true);
269268

270-
271269
for &cnum in tcx.crates().iter() {
272270
for did in tcx.all_trait_implementations(cnum).iter() {
273271
build_impl(cx, *did, &mut impls);
@@ -373,7 +371,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
373371
for_,
374372
items: trait_items,
375373
polarity: Some(polarity.clean(cx)),
376-
synthetic: false
374+
synthetic: false,
377375
}),
378376
source: tcx.def_span(did).clean(cx),
379377
name: None,

src/librustdoc/clean/mod.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,7 +3077,7 @@ impl Path {
30773077
params: PathParameters::AngleBracketed {
30783078
lifetimes: Vec::new(),
30793079
types: Vec::new(),
3080-
bindings: Vec::new()
3080+
bindings: Vec::new(),
30813081
}
30823082
}]
30833083
}
@@ -3152,23 +3152,23 @@ fn strip_type(ty: Type) -> Type {
31523152
match ty {
31533153
Type::ResolvedPath { path, typarams, did, is_generic } => {
31543154
Type::ResolvedPath { path: strip_path(&path), typarams, did, is_generic }
3155-
},
3155+
}
31563156
Type::Tuple(inner_tys) => {
31573157
Type::Tuple(inner_tys.iter().map(|t| strip_type(t.clone())).collect())
3158-
},
3158+
}
31593159
Type::Slice(inner_ty) => Type::Slice(Box::new(strip_type(*inner_ty))),
31603160
Type::Array(inner_ty, s) => Type::Array(Box::new(strip_type(*inner_ty)), s),
31613161
Type::Unique(inner_ty) => Type::Unique(Box::new(strip_type(*inner_ty))),
31623162
Type::RawPointer(m, inner_ty) => Type::RawPointer(m, Box::new(strip_type(*inner_ty))),
31633163
Type::BorrowedRef { lifetime, mutability, type_ } => {
31643164
Type::BorrowedRef { lifetime, mutability, type_: Box::new(strip_type(*type_)) }
3165-
},
3165+
}
31663166
Type::QPath { name, self_type, trait_ } => {
31673167
Type::QPath {
31683168
name,
31693169
self_type: Box::new(strip_type(*self_type)), trait_: Box::new(strip_type(*trait_))
31703170
}
3171-
},
3171+
}
31723172
_ => ty
31733173
}
31743174
}
@@ -3180,15 +3180,15 @@ fn strip_path(path: &Path) -> Path {
31803180
params: PathParameters::AngleBracketed {
31813181
lifetimes: Vec::new(),
31823182
types: Vec::new(),
3183-
bindings: Vec::new()
3183+
bindings: Vec::new(),
31843184
}
31853185
}
31863186
}).collect();
31873187

31883188
Path {
31893189
global: path.global,
31903190
def: path.def.clone(),
3191-
segments
3191+
segments,
31923192
}
31933193
}
31943194

@@ -3361,7 +3361,6 @@ pub fn get_auto_traits_with_node_id(cx: &DocContext, id: ast::NodeId, name: Stri
33613361
}
33623362

33633363
pub fn get_auto_traits_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
3364-
33653364
let finder = AutoTraitFinder {
33663365
cx,
33673366
};
@@ -3404,7 +3403,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
34043403
for_: self.for_.clean(cx),
34053404
items,
34063405
polarity: Some(self.polarity.clean(cx)),
3407-
synthetic: false
3406+
synthetic: false,
34083407
})
34093408
});
34103409
ret
@@ -3819,8 +3818,6 @@ impl Clean<TypeBinding> for hir::TypeBinding {
38193818
}
38203819
}
38213820

3822-
3823-
38243821
pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<String> {
38253822
let crate_name = name.unwrap_or_else(|| cx.tcx.crate_name(did.krate).to_string());
38263823
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
@@ -3835,15 +3832,14 @@ pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<
38353832
once(crate_name).chain(relative).collect()
38363833
}
38373834

3838-
38393835
// Start of code copied from rust-clippy
38403836

38413837
pub fn get_trait_def_id(tcx: &TyCtxt, path: &[&str], use_local: bool) -> Option<DefId> {
3842-
return if use_local {
3838+
if use_local {
38433839
path_to_def_local(tcx, path)
38443840
} else {
38453841
path_to_def(tcx, path)
3846-
};
3842+
}
38473843
}
38483844

38493845
pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
@@ -3878,7 +3874,6 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
38783874
pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
38793875
let crates = tcx.crates();
38803876

3881-
38823877
let krate = crates
38833878
.iter()
38843879
.find(|&&krate| tcx.crate_name(krate) == path[0]);
@@ -3902,7 +3897,7 @@ pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
39023897
if path_it.peek().is_none() {
39033898
return match item.def {
39043899
def::Def::Trait(did) => Some(did),
3905-
_ => None
3900+
_ => None,
39063901
}
39073902
}
39083903

@@ -3942,7 +3937,7 @@ fn get_path_for_type(tcx: TyCtxt, def_id: DefId, def_ctor: fn(DefId) -> Def) ->
39423937
segments: hir::HirVec::from_vec(apb.names.iter().map(|s| hir::PathSegment {
39433938
name: ast::Name::intern(&s),
39443939
parameters: None,
3945-
infer_types: false
3940+
infer_types: false,
39463941
}).collect())
39473942
}
39483943
}
@@ -3970,24 +3965,20 @@ enum SimpleBound {
39703965

39713966
enum AutoTraitResult {
39723967
ExplicitImpl,
3973-
39743968
PositiveImpl(Generics),
3975-
39763969
NegativeImpl,
39773970
}
39783971

39793972
impl AutoTraitResult {
3980-
39813973
fn is_auto(&self) -> bool {
39823974
match *self {
39833975
AutoTraitResult::PositiveImpl(_) | AutoTraitResult::NegativeImpl => true,
3984-
_ => false
3976+
_ => false,
39853977
}
39863978
}
39873979
}
39883980

39893981
impl From<TyParamBound> for SimpleBound {
3990-
39913982
fn from(bound: TyParamBound) -> Self {
39923983
match bound.clone() {
39933984
TyParamBound::RegionBound(l) => SimpleBound::RegionBound(l),
@@ -4001,7 +3992,7 @@ impl From<TyParamBound> for SimpleBound {
40013992
t.generic_params,
40023993
mod_)
40033994
},
4004-
_ => panic!("Unexpected bound {:?}", bound)
3995+
_ => panic!("Unexpected bound {:?}", bound),
40053996
}
40063997
}
40073998
}

src/librustdoc/core.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,11 @@ pub fn run_core(search_paths: SearchPaths,
239239
.collect()
240240
};
241241

242-
let send_trait;
243-
244-
if crate_name == Some("core".to_string()) {
245-
send_trait = clean::get_trait_def_id(&tcx, &["marker", "Send"], true);
242+
let send_trait = if crate_name == Some("core".to_string()) {
243+
clean::get_trait_def_id(&tcx, &["marker", "Send"], true)
246244
} else {
247-
send_trait = clean::get_trait_def_id(&tcx, &["core", "marker", "Send"], false)
248-
}
245+
clean::get_trait_def_id(&tcx, &["core", "marker", "Send"], false)
246+
};
249247

250248
let ctxt = DocContext {
251249
tcx,
@@ -262,7 +260,7 @@ pub fn run_core(search_paths: SearchPaths,
262260
send_trait: send_trait,
263261
fake_def_ids: RefCell::new(FxHashMap()),
264262
all_fake_def_ids: RefCell::new(FxHashSet()),
265-
generated_synthetics: RefCell::new(FxHashSet())
263+
generated_synthetics: RefCell::new(FxHashSet()),
266264
};
267265
debug!("crate: {:?}", tcx.hir.krate());
268266

src/librustdoc/html/render.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ pub enum ExternalLocation {
169169
Unknown,
170170
}
171171

172-
173172
/// Metadata about implementations for a type or trait.
174173
#[derive(Clone)]
175174
pub struct Impl {
@@ -523,7 +522,6 @@ pub fn run(mut krate: clean::Crate,
523522
themes,
524523
};
525524

526-
527525
// If user passed in `--playground-url` arg, we fill in crate name here
528526
if let Some(url) = playground_url {
529527
markdown::PLAYGROUND.with(|slot| {
@@ -2512,22 +2510,6 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
25122510
}
25132511
write!(w, "</ul>")?;
25142512
}
2515-
2516-
write!(w, r#"<script type="text/javascript">
2517-
window.inlined_types=new Set();"#)?;
2518-
2519-
write!(w, r#"<script type="text/javascript" async
2520-
src="{root_path}/implementors/{path}/{ty}.{name}.js">
2521-
</script>"#,
2522-
root_path = vec![".."; cx.current.len()].join("/"),
2523-
path = if it.def_id.is_local() {
2524-
cx.current.join("/")
2525-
} else {
2526-
let (ref path, _) = cache.external_paths[&it.def_id];
2527-
path[..path.len() - 1].join("/")
2528-
},
2529-
ty = it.type_().css_class(),
2530-
name = *it.name.as_ref().unwrap())?;
25312513
} else {
25322514
// even without any implementations to write in, we still want the heading and list, so the
25332515
// implementors javascript file pulled in below has somewhere to write the impls into

src/librustdoc/html/static/main.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,20 +1569,17 @@
15691569
for (var i = 0; i < libs.length; ++i) {
15701570
if (libs[i] === currentCrate) { continue; }
15711571
var structs = imp[libs[i]];
1572+
1573+
struct_loop:
15721574
for (var j = 0; j < structs.length; ++j) {
15731575
var struct = structs[j];
15741576
var list = struct.synthetic ? synthetic_implementors : implementors;
15751577

1576-
var bail = false;
15771578
for (var k = 0; k < struct.types.length; k++) {
15781579
if (window.inlined_types.has(struct.types[k])) {
1579-
bail = true;
1580-
break;
1580+
continue struct_loop;
15811581
}
15821582
}
1583-
if (bail) {
1584-
continue;
1585-
}
15861583

15871584
var code = document.createElement('code');
15881585
code.innerHTML = struct.text;

0 commit comments

Comments
 (0)