Skip to content

Commit 4d8b73d

Browse files
committed
Cleanup formatting
1 parent 14534ff commit 4d8b73d

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
@@ -3066,7 +3066,7 @@ impl Path {
30663066
params: PathParameters::AngleBracketed {
30673067
lifetimes: Vec::new(),
30683068
types: Vec::new(),
3069-
bindings: Vec::new()
3069+
bindings: Vec::new(),
30703070
}
30713071
}]
30723072
}
@@ -3141,23 +3141,23 @@ fn strip_type(ty: Type) -> Type {
31413141
match ty {
31423142
Type::ResolvedPath { path, typarams, did, is_generic } => {
31433143
Type::ResolvedPath { path: strip_path(&path), typarams, did, is_generic }
3144-
},
3144+
}
31453145
Type::Tuple(inner_tys) => {
31463146
Type::Tuple(inner_tys.iter().map(|t| strip_type(t.clone())).collect())
3147-
},
3147+
}
31483148
Type::Slice(inner_ty) => Type::Slice(Box::new(strip_type(*inner_ty))),
31493149
Type::Array(inner_ty, s) => Type::Array(Box::new(strip_type(*inner_ty)), s),
31503150
Type::Unique(inner_ty) => Type::Unique(Box::new(strip_type(*inner_ty))),
31513151
Type::RawPointer(m, inner_ty) => Type::RawPointer(m, Box::new(strip_type(*inner_ty))),
31523152
Type::BorrowedRef { lifetime, mutability, type_ } => {
31533153
Type::BorrowedRef { lifetime, mutability, type_: Box::new(strip_type(*type_)) }
3154-
},
3154+
}
31553155
Type::QPath { name, self_type, trait_ } => {
31563156
Type::QPath {
31573157
name,
31583158
self_type: Box::new(strip_type(*self_type)), trait_: Box::new(strip_type(*trait_))
31593159
}
3160-
},
3160+
}
31613161
_ => ty
31623162
}
31633163
}
@@ -3169,15 +3169,15 @@ fn strip_path(path: &Path) -> Path {
31693169
params: PathParameters::AngleBracketed {
31703170
lifetimes: Vec::new(),
31713171
types: Vec::new(),
3172-
bindings: Vec::new()
3172+
bindings: Vec::new(),
31733173
}
31743174
}
31753175
}).collect();
31763176

31773177
Path {
31783178
global: path.global,
31793179
def: path.def.clone(),
3180-
segments
3180+
segments,
31813181
}
31823182
}
31833183

@@ -3350,7 +3350,6 @@ pub fn get_auto_traits_with_node_id(cx: &DocContext, id: ast::NodeId, name: Stri
33503350
}
33513351

33523352
pub fn get_auto_traits_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
3353-
33543353
let finder = AutoTraitFinder {
33553354
cx,
33563355
};
@@ -3393,7 +3392,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
33933392
for_: self.for_.clean(cx),
33943393
items,
33953394
polarity: Some(self.polarity.clean(cx)),
3396-
synthetic: false
3395+
synthetic: false,
33973396
})
33983397
});
33993398
ret
@@ -3808,8 +3807,6 @@ impl Clean<TypeBinding> for hir::TypeBinding {
38083807
}
38093808
}
38103809

3811-
3812-
38133810
pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<String> {
38143811
let crate_name = name.unwrap_or_else(|| cx.tcx.crate_name(did.krate).to_string());
38153812
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
@@ -3824,15 +3821,14 @@ pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<
38243821
once(crate_name).chain(relative).collect()
38253822
}
38263823

3827-
38283824
// Start of code copied from rust-clippy
38293825

38303826
pub fn get_trait_def_id(tcx: &TyCtxt, path: &[&str], use_local: bool) -> Option<DefId> {
3831-
return if use_local {
3827+
if use_local {
38323828
path_to_def_local(tcx, path)
38333829
} else {
38343830
path_to_def(tcx, path)
3835-
};
3831+
}
38363832
}
38373833

38383834
pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
@@ -3867,7 +3863,6 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
38673863
pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
38683864
let crates = tcx.crates();
38693865

3870-
38713866
let krate = crates
38723867
.iter()
38733868
.find(|&&krate| tcx.crate_name(krate) == path[0]);
@@ -3891,7 +3886,7 @@ pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
38913886
if path_it.peek().is_none() {
38923887
return match item.def {
38933888
def::Def::Trait(did) => Some(did),
3894-
_ => None
3889+
_ => None,
38953890
}
38963891
}
38973892

@@ -3931,7 +3926,7 @@ fn get_path_for_type(tcx: TyCtxt, def_id: DefId, def_ctor: fn(DefId) -> Def) ->
39313926
segments: hir::HirVec::from_vec(apb.names.iter().map(|s| hir::PathSegment {
39323927
name: ast::Name::intern(&s),
39333928
parameters: None,
3934-
infer_types: false
3929+
infer_types: false,
39353930
}).collect())
39363931
}
39373932
}
@@ -3959,24 +3954,20 @@ enum SimpleBound {
39593954

39603955
enum AutoTraitResult {
39613956
ExplicitImpl,
3962-
39633957
PositiveImpl(Generics),
3964-
39653958
NegativeImpl,
39663959
}
39673960

39683961
impl AutoTraitResult {
3969-
39703962
fn is_auto(&self) -> bool {
39713963
match *self {
39723964
AutoTraitResult::PositiveImpl(_) | AutoTraitResult::NegativeImpl => true,
3973-
_ => false
3965+
_ => false,
39743966
}
39753967
}
39763968
}
39773969

39783970
impl From<TyParamBound> for SimpleBound {
3979-
39803971
fn from(bound: TyParamBound) -> Self {
39813972
match bound.clone() {
39823973
TyParamBound::RegionBound(l) => SimpleBound::RegionBound(l),
@@ -3990,7 +3981,7 @@ impl From<TyParamBound> for SimpleBound {
39903981
t.generic_params,
39913982
mod_)
39923983
},
3993-
_ => panic!("Unexpected bound {:?}", bound)
3984+
_ => panic!("Unexpected bound {:?}", bound),
39943985
}
39953986
}
39963987
}

src/librustdoc/core.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,11 @@ pub fn run_core(search_paths: SearchPaths,
244244
.collect()
245245
};
246246

247-
let send_trait;
248-
249-
if crate_name == Some("core".to_string()) {
250-
send_trait = clean::get_trait_def_id(&tcx, &["marker", "Send"], true);
247+
let send_trait = if crate_name == Some("core".to_string()) {
248+
clean::get_trait_def_id(&tcx, &["marker", "Send"], true)
251249
} else {
252-
send_trait = clean::get_trait_def_id(&tcx, &["core", "marker", "Send"], false)
253-
}
250+
clean::get_trait_def_id(&tcx, &["core", "marker", "Send"], false)
251+
};
254252

255253
let ctxt = DocContext {
256254
tcx,
@@ -268,7 +266,7 @@ pub fn run_core(search_paths: SearchPaths,
268266
send_trait: send_trait,
269267
fake_def_ids: RefCell::new(FxHashMap()),
270268
all_fake_def_ids: RefCell::new(FxHashSet()),
271-
generated_synthetics: RefCell::new(FxHashSet())
269+
generated_synthetics: RefCell::new(FxHashSet()),
272270
};
273271
debug!("crate: {:?}", tcx.hir.krate());
274272

src/librustdoc/html/render.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ pub enum ExternalLocation {
175175
Unknown,
176176
}
177177

178-
179178
/// Metadata about implementations for a type or trait.
180179
#[derive(Clone)]
181180
pub struct Impl {
@@ -546,7 +545,6 @@ pub fn run(mut krate: clean::Crate,
546545
themes,
547546
};
548547

549-
550548
// If user passed in `--playground-url` arg, we fill in crate name here
551549
if let Some(url) = playground_url {
552550
markdown::PLAYGROUND.with(|slot| {
@@ -2712,22 +2710,6 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
27122710
}
27132711
write!(w, "</ul>")?;
27142712
}
2715-
2716-
write!(w, r#"<script type="text/javascript">
2717-
window.inlined_types=new Set();"#)?;
2718-
2719-
write!(w, r#"<script type="text/javascript" async
2720-
src="{root_path}/implementors/{path}/{ty}.{name}.js">
2721-
</script>"#,
2722-
root_path = vec![".."; cx.current.len()].join("/"),
2723-
path = if it.def_id.is_local() {
2724-
cx.current.join("/")
2725-
} else {
2726-
let (ref path, _) = cache.external_paths[&it.def_id];
2727-
path[..path.len() - 1].join("/")
2728-
},
2729-
ty = it.type_().css_class(),
2730-
name = *it.name.as_ref().unwrap())?;
27312713
} else {
27322714
// even without any implementations to write in, we still want the heading and list, so the
27332715
// 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
@@ -1568,20 +1568,17 @@
15681568
for (var i = 0; i < libs.length; ++i) {
15691569
if (libs[i] === currentCrate) { continue; }
15701570
var structs = imp[libs[i]];
1571+
1572+
struct_loop:
15711573
for (var j = 0; j < structs.length; ++j) {
15721574
var struct = structs[j];
15731575
var list = struct.synthetic ? synthetic_implementors : implementors;
15741576

1575-
var bail = false;
15761577
for (var k = 0; k < struct.types.length; k++) {
15771578
if (window.inlined_types.has(struct.types[k])) {
1578-
bail = true;
1579-
break;
1579+
continue struct_loop;
15801580
}
15811581
}
1582-
if (bail) {
1583-
continue;
1584-
}
15851582

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

0 commit comments

Comments
 (0)