Skip to content

Commit 8f9ca24

Browse files
author
Alexander Regueiro
committed
A few cosmetic improvements.
1 parent 4be0675 commit 8f9ca24

File tree

8 files changed

+38
-37
lines changed

8 files changed

+38
-37
lines changed

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ pub enum UseKind {
22342234
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
22352235
pub struct TraitRef {
22362236
pub path: P<Path>,
2237-
// Don't hash the ref_id. It is tracked via the thing it is used to access
2237+
// Don't hash the `ref_id`. It is tracked via the thing it is used to access.
22382238
#[stable_hasher(ignore)]
22392239
pub hir_ref_id: HirId,
22402240
}

src/librustc/ty/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ pub struct Generics {
904904
pub parent_count: usize,
905905
pub params: Vec<GenericParamDef>,
906906

907-
/// Reverse map to the `index` field of each `GenericParamDef`
907+
/// Reverse map to the `index` field of each `GenericParamDef`.
908908
#[stable_hasher(ignore)]
909909
pub param_def_id_to_index: FxHashMap<DefId, u32>,
910910

@@ -1252,7 +1252,7 @@ impl<'tcx> TraitPredicate<'tcx> {
12521252

12531253
impl<'tcx> PolyTraitPredicate<'tcx> {
12541254
pub fn def_id(&self) -> DefId {
1255-
// Ok to skip binder since trait def-ID does not care about regions.
1255+
// Ok to skip binder since trait `DefId` does not care about regions.
12561256
self.skip_binder().def_id()
12571257
}
12581258
}
@@ -1319,7 +1319,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
13191319
/// Note that this is not the `DefId` of the `TraitRef` containing this
13201320
/// associated type, which is in `tcx.associated_item(projection_def_id()).container`.
13211321
pub fn projection_def_id(&self) -> DefId {
1322-
// Ok to skip binder since trait def-ID does not care about regions.
1322+
// Ok to skip binder since trait `DefId` does not care about regions.
13231323
self.skip_binder().projection_ty.item_def_id
13241324
}
13251325
}
@@ -1646,10 +1646,10 @@ pub type PlaceholderConst = Placeholder<BoundVar>;
16461646
/// particular point.
16471647
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
16481648
pub struct ParamEnv<'tcx> {
1649-
/// Obligations that the caller must satisfy. This is basically
1649+
/// `Obligation`s that the caller must satisfy. This is basically
16501650
/// the set of bounds on the in-scope type parameters, translated
1651-
/// into Obligations, and elaborated and normalized.
1652-
pub caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
1651+
/// into `Obligation`s, and elaborated and normalized.
1652+
pub caller_bounds: &'tcx List<(ty::Predicate<'tcx>, Span)>,
16531653

16541654
/// Typically, this is `Reveal::UserFacing`, but during codegen we
16551655
/// want `Reveal::All` -- note that this is always paired with an
@@ -2796,7 +2796,7 @@ impl<'tcx> TyCtxt<'tcx> {
27962796
_ => false,
27972797
}
27982798
} else {
2799-
match self.def_kind(def_id).expect("no def for def-id") {
2799+
match self.def_kind(def_id).expect("no def for `DefId`") {
28002800
DefKind::AssocConst
28012801
| DefKind::Method
28022802
| DefKind::AssocTy => true,

src/librustc/ty/sty.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
646646
///
647647
/// A Rust trait object type consists (in addition to a lifetime bound)
648648
/// of a set of trait bounds, which are separated into any number
649-
/// of auto-trait bounds, and at most 1 non-auto-trait bound. The
649+
/// of auto-trait bounds, and at most one non-auto-trait bound. The
650650
/// non-auto-trait bound is called the "principal" of the trait
651651
/// object.
652652
///
@@ -680,7 +680,8 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
680680

681681
#[inline]
682682
pub fn projection_bounds<'a>(&'a self) ->
683-
impl Iterator<Item=ExistentialProjection<'tcx>> + 'a {
683+
impl Iterator<Item = ExistentialProjection<'tcx>> + 'a
684+
{
684685
self.iter().filter_map(|predicate| {
685686
match *predicate {
686687
ExistentialPredicate::Projection(p) => Some(p),
@@ -690,7 +691,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
690691
}
691692

692693
#[inline]
693-
pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item=DefId> + 'a {
694+
pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item = DefId> + 'a {
694695
self.iter().filter_map(|predicate| {
695696
match *predicate {
696697
ExistentialPredicate::AutoTrait(d) => Some(d),
@@ -711,17 +712,17 @@ impl<'tcx> Binder<&'tcx List<ExistentialPredicate<'tcx>>> {
711712

712713
#[inline]
713714
pub fn projection_bounds<'a>(&'a self) ->
714-
impl Iterator<Item=PolyExistentialProjection<'tcx>> + 'a {
715+
impl Iterator<Item = PolyExistentialProjection<'tcx>> + 'a {
715716
self.skip_binder().projection_bounds().map(Binder::bind)
716717
}
717718

718719
#[inline]
719-
pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item=DefId> + 'a {
720+
pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item = DefId> + 'a {
720721
self.skip_binder().auto_traits()
721722
}
722723

723724
pub fn iter<'a>(&'a self)
724-
-> impl DoubleEndedIterator<Item=Binder<ExistentialPredicate<'tcx>>> + 'tcx {
725+
-> impl DoubleEndedIterator<Item = Binder<ExistentialPredicate<'tcx>>> + 'tcx {
725726
self.skip_binder().iter().cloned().map(Binder::bind)
726727
}
727728
}

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,11 @@ fn subroutine_type_metadata(
450450
false);
451451
}
452452

453-
// FIXME(1563) This is all a bit of a hack because 'trait pointer' is an ill-
454-
// defined concept. For the case of an actual trait pointer (i.e., Box<Trait>,
455-
// &Trait), trait_object_type should be the whole thing (e.g, Box<Trait>) and
456-
// trait_type should be the actual trait (e.g., Trait). Where the trait is part
457-
// of a DST struct, there is no trait_object_type and the results of this
453+
// FIXME(1563): This is all a bit of a hack because 'trait pointer' is an ill-
454+
// defined concept. For the case of an actual trait pointer (i.e., `Box<Trait>`,
455+
// `&Trait`), `trait_object_type` should be the whole thing (e.g, `Box<Trait>`) and
456+
// `trait_type` should be the actual trait (e.g., `Trait`). Where the trait is part
457+
// of a DST struct, there is no `trait_object_type` and the results of this
458458
// function will be a little bit weird.
459459
fn trait_pointer_metadata(
460460
cx: &CodegenCx<'ll, 'tcx>,
@@ -464,13 +464,13 @@ fn trait_pointer_metadata(
464464
) -> &'ll DIType {
465465
// The implementation provided here is a stub. It makes sure that the trait
466466
// type is assigned the correct name, size, namespace, and source location.
467-
// But it does not describe the trait's methods.
467+
// However, it does not describe the trait's methods.
468468

469469
let containing_scope = match trait_type.sty {
470470
ty::Dynamic(ref data, ..) =>
471471
data.principal_def_id().map(|did| get_namespace_for_item(cx, did)),
472472
_ => {
473-
bug!("debuginfo: Unexpected trait-object type in \
473+
bug!("debuginfo: unexpected trait-object type in \
474474
trait_pointer_metadata(): {:?}",
475475
trait_type);
476476
}

src/librustc_privacy/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
10561056
}
10571057
for (poly_predicate, _) in bounds.projection_bounds {
10581058
let tcx = self.tcx;
1059-
if self.visit(poly_predicate.skip_binder().ty) ||
1060-
self.visit_trait(poly_predicate.skip_binder().projection_ty.trait_ref(tcx)) {
1059+
if self.visit(poly_predicate.skip_binder().ty)
1060+
|| self.visit_trait(poly_predicate.skip_binder().projection_ty.trait_ref(tcx))
1061+
{
10611062
return;
10621063
}
10631064
}

src/librustc_typeck/astconv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15151515
assoc_name: ast::Ident,
15161516
span: Span)
15171517
-> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
1518-
where I: Iterator<Item=ty::PolyTraitRef<'tcx>>
1518+
where I: Iterator<Item = ty::PolyTraitRef<'tcx>>
15191519
{
15201520
let bound = match bounds.next() {
15211521
Some(bound) => bound,
@@ -1524,8 +1524,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15241524
"associated type `{}` not found for `{}`",
15251525
assoc_name,
15261526
ty_param_name)
1527-
.span_label(span, format!("associated type `{}` not found", assoc_name))
1528-
.emit();
1527+
.span_label(span, format!("associated type `{}` not found", assoc_name))
1528+
.emit();
15291529
return Err(ErrorReported);
15301530
}
15311531
};
@@ -1544,7 +1544,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15441544
item.kind == ty::AssocKind::Type &&
15451545
self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id())
15461546
})
1547-
.and_then(|item| self.tcx().hir().span_if_local(item.def_id));
1547+
.and_then(|item| self.tcx().hir().span_if_local(item.def_id));
15481548

15491549
if let Some(span) = bound_span {
15501550
err.span_label(span, format!("ambiguous `{}` from `{}`",

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span, qpath: &
20302030
impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
20312031
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
20322032
self.tcx
2033-
}
2033+
}
20342034

20352035
fn get_type_parameter_bounds(&self, _: Span, def_id: DefId)
20362036
-> &'tcx ty::GenericPredicates<'tcx>

src/librustc_typeck/collect.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
226226
if let Some(trait_ref) = poly_trait_ref.no_bound_vars() {
227227
self.tcx().mk_projection(item_def_id, trait_ref.substs)
228228
} else {
229-
// no late-bound regions, we can just ignore the binder
229+
// There are no late-bound regions; we can just ignore the binder.
230230
span_err!(
231231
self.tcx().sess,
232232
span,
@@ -239,17 +239,16 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
239239
}
240240

241241
fn normalize_ty(&self, _span: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
242-
// types in item signatures are not normalized, to avoid undue
243-
// dependencies.
242+
// Types in item signatures are not normalized to avoid undue dependencies.
244243
ty
245244
}
246245

247246
fn set_tainted_by_errors(&self) {
248-
// no obvious place to track this, so just let it go
247+
// There's no obvious place to track this, so just let it go.
249248
}
250249

251250
fn record_ty(&self, _hir_id: hir::HirId, _ty: Ty<'tcx>, _span: Span) {
252-
// no place to record types from signatures?
251+
// There's no place to record types from signatures?
253252
}
254253
}
255254

@@ -260,8 +259,8 @@ fn type_param_predicates(
260259
use rustc::hir::*;
261260

262261
// In the AST, bounds can derive from two places. Either
263-
// written inline like `<T : Foo>` or in a where clause like
264-
// `where T : Foo`.
262+
// written inline like `<T: Foo>` or in a where-clause like
263+
// `where T: Foo`.
265264

266265
let param_id = tcx.hir().as_local_hir_id(def_id).unwrap();
267266
let param_owner = tcx.hir().ty_param_owner(param_id);
@@ -334,7 +333,7 @@ fn type_param_predicates(
334333
impl ItemCtxt<'tcx> {
335334
/// Finds bounds from `hir::Generics`. This requires scanning through the
336335
/// AST. We do this to avoid having to convert *all* the bounds, which
337-
/// would create artificial cycles. Instead we can only convert the
336+
/// would create artificial cycles. Instead, we can only convert the
338337
/// bounds for a type parameter `X` if `X::Foo` is used.
339338
fn type_parameter_bounds_in_generics(
340339
&self,
@@ -2292,7 +2291,7 @@ fn explicit_predicates_of(
22922291
/// Converts a specific `GenericBound` from the AST into a set of
22932292
/// predicates that apply to the self type. A vector is returned
22942293
/// because this can be anywhere from zero predicates (`T: ?Sized` adds no
2295-
/// predicates) to one (`T: Foo`) to many (`T: Bar<X=i32>` adds `T: Bar`
2294+
/// predicates) to one (`T: Foo`) to many (`T: Bar<X = i32>` adds `T: Bar`
22962295
/// and `<T as Bar>::X == i32`).
22972296
fn predicates_from_bound<'tcx>(
22982297
astconv: &dyn AstConv<'tcx>,

0 commit comments

Comments
 (0)