Skip to content

Commit c6bd75c

Browse files
author
Alexander Regueiro
committed
Various cosmetic improvements
1 parent ec19464 commit c6bd75c

File tree

20 files changed

+113
-103
lines changed

20 files changed

+113
-103
lines changed

src/librustc/hir/map/def_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
116116
debug!("visit_item: {:?}", i);
117117

118118
// Pick the def data. This need not be unique, but the more
119-
// information we encapsulate into, the better
119+
// information we encapsulate into, the better.
120120
let def_data = match i.node {
121121
ItemKind::Impl(..) => DefPathData::Impl,
122122
ItemKind::Trait(..) => DefPathData::Trait(i.ident.as_interned_str()),

src/librustc/hir/map/definitions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! For each definition, we track the following data. A definition
1+
//! For each definition, we track the following data. A definition
22
//! here is defined somewhat circularly as "something with a def-id",
33
//! but it generally corresponds to things like structs, enums, etc.
44
//! There are also some rather random cases (like const initializer
@@ -114,7 +114,7 @@ impl Encodable for DefPathTable {
114114
self.index_to_key[DefIndexAddressSpace::Low.index()].encode(s)?;
115115
self.index_to_key[DefIndexAddressSpace::High.index()].encode(s)?;
116116

117-
// DefPath hashes
117+
// `DefPath` hashes
118118
self.def_path_hashes[DefIndexAddressSpace::Low.index()].encode(s)?;
119119
self.def_path_hashes[DefIndexAddressSpace::High.index()].encode(s)?;
120120

src/librustc/infer/nll_relate/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ where
373373
}
374374

375375
fn trait_object_mode(&self) -> relate::TraitObjectMode {
376-
// squashing should only be done in coherence, not NLL
376+
// Squashing should only be done in coherence, not in NLL.
377377
assert_eq!(self.infcx.trait_object_mode(),
378378
relate::TraitObjectMode::NoSquash);
379379
relate::TraitObjectMode::NoSquash

src/librustc/traits/specialize/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(
305305

306306
for impl_def_id in trait_impls {
307307
if impl_def_id.is_local() {
308-
// This is where impl overlap checking happens:
308+
// This is where impl overlap checking happens.
309309
let insert_result = sg.insert(tcx, impl_def_id);
310310
// Report error if there was one.
311311
let (overlap, used_to_be_allowed) = match insert_result {
@@ -381,7 +381,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(
381381
Lrc::new(sg)
382382
}
383383

384-
/// Recovers the "impl X for Y" signature from `impl_def_id` and returns it as a
384+
/// Recovers the `impl X for Y` signature from `impl_def_id` and returns it as a
385385
/// string.
386386
fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<String> {
387387
use std::fmt::Write;
@@ -396,8 +396,8 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<
396396

397397
let substs = Substs::identity_for_item(tcx, impl_def_id);
398398

399-
// FIXME: Currently only handles ?Sized.
400-
// Needs to support ?Move and ?DynSized when they are implemented.
399+
// FIXME: currently only handles `?Sized`; needs to support `?Move` and `?DynSized` when
400+
// they are implemented.
401401
let mut types_without_default_bounds = FxHashSet::default();
402402
let sized_trait = tcx.lang_items().sized_trait();
403403

src/librustc/traits/specialize/specialization_graph.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ use util::nodemap::{DefIdMap, FxHashMap};
3030
/// has at most one parent.
3131
#[derive(RustcEncodable, RustcDecodable)]
3232
pub struct Graph {
33-
// All impls have a parent; the "root" impls have as their parent the `def_id`
34-
// of the trait.
33+
// All impls have a parent; the "root" impls have as their parent the trait's def-ID.
3534
parent: DefIdMap<DefId>,
3635

37-
// The "root" impls are found by looking up the trait's def_id.
36+
// The "root" impls are found by looking up the trait's def-ID.
3837
children: DefIdMap<Children>,
3938
}
4039

@@ -63,12 +62,13 @@ struct Children {
6362
pub enum FutureCompatOverlapErrorKind {
6463
Issue43355,
6564
Issue33140,
65+
Issue57057,
6666
}
6767

6868
#[derive(Debug)]
6969
pub struct FutureCompatOverlapError {
7070
pub error: OverlapError,
71-
pub kind: FutureCompatOverlapErrorKind
71+
pub kind: FutureCompatOverlapErrorKind,
7272
}
7373

7474
/// The result of attempting to insert an impl into a group of children.
@@ -204,8 +204,8 @@ impl<'a, 'gcx, 'tcx> Children {
204204
replace_children.push(possible_sibling);
205205
} else {
206206
if !tcx.impls_are_allowed_to_overlap(impl_def_id, possible_sibling) {
207-
// do future-compat checks for overlap. Have issue #43355
208-
// errors overwrite issue #33140 errors when both are present.
207+
// Do future-compat checks for overlap.
208+
// Make issue #43355 errors overwrite issue #33140 errors when both are present.
209209

210210
traits::overlapping_impls(
211211
tcx,
@@ -238,7 +238,7 @@ impl<'a, 'gcx, 'tcx> Children {
238238
);
239239
}
240240

241-
// no overlap (error bailed already via ?)
241+
// No overlap (error bailed already via `?`).
242242
}
243243
}
244244

src/librustc/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! type context book-keeping
1+
//! Type context book-keeping.
22
33
use dep_graph::DepGraph;
44
use dep_graph::{DepNode, DepConstructor};

src/librustc/ty/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,9 +2499,9 @@ impl<'a, 'gcx, 'tcx> FieldDef {
24992499
/// `tcx.closure_env_ty()`.
25002500
#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
25012501
pub enum ClosureKind {
2502-
// Warning: Ordering is significant here! The ordering is chosen
2503-
// because the trait Fn is a subtrait of FnMut and so in turn, and
2504-
// hence we order it so that Fn < FnMut < FnOnce.
2502+
// Warning: ordering is significant here! The ordering is chosen
2503+
// because the trait `Fn` is a subtrait of `FnMut` and so in turn, and
2504+
// hence we order it so that `Fn < FnMut < FnOnce`.
25052505
Fn,
25062506
FnMut,
25072507
FnOnce,
@@ -2852,7 +2852,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
28522852
self.original_crate_name(id.krate).as_interned_str()
28532853
} else {
28542854
let def_key = self.def_key(id);
2855-
// The name of a StructCtor is that of its struct parent.
2855+
// The name of a `StructCtor` is that of its parent struct.
28562856
if let hir_map::DefPathData::StructCtor = def_key.disambiguated_data.data {
28572857
self.item_name(DefId {
28582858
krate: id.krate,

src/librustc/ty/relate.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ pub type RelateResult<'tcx, T> = Result<T, TypeError<'tcx>>;
2222

2323
#[derive(Clone, Debug)]
2424
pub enum Cause {
25-
ExistentialRegionBound, // relating an existential region bound
25+
/// Relating to an existential region bound.
26+
ExistentialRegionBound,
2627
}
2728

2829
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2930
pub enum TraitObjectMode {
3031
NoSquash,
31-
/// A temporary mode to treat `Send + Sync = Sync + Send`, should be
32-
/// used only in coherence.
33-
SquashAutoTraitsIssue33140
32+
/// A temporary mode to treat `Send + Sync == Sync + Send` (e.g.); should be
33+
/// used only in coherence checking.
34+
SquashAutoTraitsIssue33140,
3435
}
3536

3637
pub trait TypeRelation<'a, 'gcx: 'a+'tcx, 'tcx: 'a> : Sized {
@@ -609,13 +610,13 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
609610
TraitObjectMode::SquashAutoTraitsIssue33140 => {
610611
// Treat auto-trait "principal" components as equal
611612
// to the non-principal components, to make
612-
// `dyn Send+Sync = dyn Sync+Send`.
613+
// `dyn Send + Sync = dyn Sync + Send`.
613614
let normalize = |d: &[ty::ExistentialPredicate<'tcx>]| {
614615
let mut result: Vec<_> = d.iter().map(|pi| match pi {
615616
Trait(ref a) if tcx.trait_is_auto(a.def_id) => {
616617
AutoTrait(a.def_id)
617618
},
618-
other => *other
619+
other => *other,
619620
}).collect();
620621

621622
result.sort_by(|a, b| a.stable_cmp(tcx, b));

src/librustc/ty/wf.rs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
3838
}
3939

4040
/// Returns the obligations that make this trait reference
41-
/// well-formed. For example, if there is a trait `Set` defined like
41+
/// well-formed. For example, if there is a trait `Set` defined like
4242
/// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF
4343
/// if `Bar: Eq`.
4444
pub fn trait_obligations<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
@@ -190,7 +190,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
190190
/// into `self.out`.
191191
fn compute_projection(&mut self, data: ty::ProjectionTy<'tcx>) {
192192
// A projection is well-formed if (a) the trait ref itself is
193-
// WF and (b) the trait-ref holds. (It may also be
193+
// WF and (b) the trait-ref holds. (It may also be
194194
// normalizable and be WF that way.)
195195
let trait_ref = data.trait_ref(self.infcx.tcx);
196196
self.compute_trait_ref(&trait_ref, Elaborate::None);
@@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
251251
ty::Bound(..) |
252252
ty::Placeholder(..) |
253253
ty::Foreign(..) => {
254-
// WfScalar, WfParameter, etc
254+
// `WfScalar`, `WfParameter`, etc.
255255
}
256256

257257
ty::Slice(subty) => {
@@ -273,18 +273,19 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
273273
}
274274

275275
ty::RawPtr(_) => {
276-
// simple cases that are WF if their type args are WF
276+
// Simple cases that are WF if their type args are WF.
277277
}
278278

279279
ty::Projection(data) => {
280-
subtys.skip_current_subtree(); // subtree handled by compute_projection
280+
// Subtree is handled by `compute_projection`.
281+
subtys.skip_current_subtree();
281282
self.compute_projection(data);
282283
}
283284

284285
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
285286

286287
ty::Adt(def, substs) => {
287-
// WfNominalType
288+
// `WfNominalType`
288289
let obligations = self.nominal_obligations(def.did, substs);
289290
self.out.extend(obligations);
290291
}
@@ -295,7 +296,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
295296
}
296297

297298
ty::Ref(r, rty, _) => {
298-
// WfReference
299+
// `WfReference`
299300
if !r.has_escaping_bound_vars() && !rty.has_escaping_bound_vars() {
300301
let cause = self.cause(traits::ReferenceOutlivesReferent(ty));
301302
self.out.push(
@@ -309,7 +310,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
309310
}
310311

311312
ty::Generator(..) => {
312-
// Walk ALL the types in the generator: this will
313+
// Walk _all_ the types in the generator: this will
313314
// include the upvar types as well as the yield
314315
// type. Note that this is mildly distinct from
315316
// the closure case, where we have to be careful
@@ -355,32 +356,32 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
355356
}
356357

357358
ty::FnPtr(_) => {
358-
// let the loop iterate into the argument/return
359-
// types appearing in the fn signature
359+
// Let the loop iterate into the argument/return
360+
// types appearing in the fn signature.
360361
}
361362

362363
ty::Opaque(did, substs) => {
363-
// all of the requirements on type parameters
364+
// All of the requirements on type parameters
364365
// should've been checked by the instantiation
365366
// of whatever returned this exact `impl Trait`.
366367

367-
// for named existential types we still need to check them
368+
// For named existential types, we still need to check them.
368369
if super::is_impl_trait_defn(self.infcx.tcx, did).is_none() {
369370
let obligations = self.nominal_obligations(did, substs);
370371
self.out.extend(obligations);
371372
}
372373
}
373374

374375
ty::Dynamic(data, r) => {
375-
// WfObject
376+
// `WfObject`
376377
//
377378
// Here, we defer WF checking due to higher-ranked
378379
// regions. This is perhaps not ideal.
379380
self.from_object_ty(ty, data, r);
380381

381-
// FIXME(#27579) RFC also considers adding trait
382-
// obligations that don't refer to Self and
383-
// checking those
382+
// FIXME(#27579): RFC also considers adding trait
383+
// obligations that don't refer to `Self` and
384+
// checking those.
384385

385386
let cause = self.cause(traits::MiscObligation);
386387
let component_traits =
@@ -398,9 +399,9 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
398399
// know what type they are. We do two things:
399400
//
400401
// 1. Check if they have been resolved, and if so proceed with
401-
// THAT type.
402+
// _that_ type.
402403
// 2. If not, check whether this is the type that we
403-
// started with (ty0). In that case, we've made no
404+
// started with (`ty0`). In that case, we've made no
404405
// progress at all, so return false. Otherwise,
405406
// we've at least simplified things (i.e., we went
406407
// from `Vec<$0>: WF` to `$0: WF`, so we can
@@ -409,27 +410,30 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
409410
// is satisfied to ensure termination.)
410411
ty::Infer(_) => {
411412
let ty = self.infcx.shallow_resolve(ty);
412-
if let ty::Infer(_) = ty.sty { // not yet resolved...
413-
if ty == ty0 { // ...this is the type we started from! no progress.
413+
if let ty::Infer(_) = ty.sty {
414+
// Not yet resolved...
415+
if ty == ty0 {
416+
// ... this is the type we started from, so no progress!
414417
return false;
415418
}
416419

417420
let cause = self.cause(traits::MiscObligation);
418-
self.out.push( // ...not the type we started from, so we made progress.
421+
self.out.push(
422+
// ... this is not the type we started from, so we made progress.
419423
traits::Obligation::new(cause,
420424
self.param_env,
421425
ty::Predicate::WellFormed(ty)));
422426
} else {
423427
// Yes, resolved, proceed with the
424428
// result. Should never return false because
425-
// `ty` is not a Infer.
429+
// `ty` is not a `Infer`.
426430
assert!(self.compute(ty));
427431
}
428432
}
429433
}
430434
}
431435

432-
// if we made it through that loop above, we made progress!
436+
// If we made it through that loop above, we made progress!
433437
return true;
434438
}
435439

src/librustc_lint/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
308308
id: LintId::of(UNSTABLE_NAME_COLLISIONS),
309309
reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
310310
edition: None,
311-
// Note: this item represents future incompatibility of all unstable functions in the
312-
// standard library, and thus should never be removed or changed to an error.
311+
// N.B., this item represents future incompatibility of all unstable functions in the
312+
// standard library, and thus should never be removed or changed to an error.
313313
},
314314
FutureIncompatibleInfo {
315315
id: LintId::of(ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE),

0 commit comments

Comments
 (0)