diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index b8d8394a02c..3d049fe4ccd 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2234,7 +2234,7 @@ pub enum UseKind { #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct TraitRef { pub path: P, - // Don't hash the ref_id. It is tracked via the thing it is used to access + // Don't hash the `ref_id`. It is tracked via the thing it is used to access. #[stable_hasher(ignore)] pub hir_ref_id: HirId, } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 8e170578227..c6aadc598b7 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -904,7 +904,7 @@ pub struct Generics { pub parent_count: usize, pub params: Vec, - /// Reverse map to the `index` field of each `GenericParamDef` + /// Reverse map to the `index` field of each `GenericParamDef`. #[stable_hasher(ignore)] pub param_def_id_to_index: FxHashMap, @@ -1252,7 +1252,7 @@ impl<'tcx> TraitPredicate<'tcx> { impl<'tcx> PolyTraitPredicate<'tcx> { pub fn def_id(&self) -> DefId { - // Ok to skip binder since trait def-ID does not care about regions. + // Ok to skip binder since trait `DefId` does not care about regions. self.skip_binder().def_id() } } @@ -1319,7 +1319,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> { /// Note that this is not the `DefId` of the `TraitRef` containing this /// associated type, which is in `tcx.associated_item(projection_def_id()).container`. pub fn projection_def_id(&self) -> DefId { - // Ok to skip binder since trait def-ID does not care about regions. + // Ok to skip binder since trait `DefId` does not care about regions. self.skip_binder().projection_ty.item_def_id } } @@ -1646,10 +1646,10 @@ pub type PlaceholderConst = Placeholder; /// particular point. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)] pub struct ParamEnv<'tcx> { - /// Obligations that the caller must satisfy. This is basically + /// `Obligation`s that the caller must satisfy. This is basically /// the set of bounds on the in-scope type parameters, translated - /// into Obligations, and elaborated and normalized. - pub caller_bounds: &'tcx List>, + /// into `Obligation`s, and elaborated and normalized. + pub caller_bounds: &'tcx List<(ty::Predicate<'tcx>, Span)>, /// Typically, this is `Reveal::UserFacing`, but during codegen we /// want `Reveal::All` -- note that this is always paired with an @@ -2796,7 +2796,7 @@ impl<'tcx> TyCtxt<'tcx> { _ => false, } } else { - match self.def_kind(def_id).expect("no def for def-id") { + match self.def_kind(def_id).expect("no def for `DefId`") { DefKind::AssocConst | DefKind::Method | DefKind::AssocTy => true, diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 2b14558de69..820e9990b92 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -646,7 +646,7 @@ impl<'tcx> List> { /// /// A Rust trait object type consists (in addition to a lifetime bound) /// of a set of trait bounds, which are separated into any number - /// of auto-trait bounds, and at most 1 non-auto-trait bound. The + /// of auto-trait bounds, and at most one non-auto-trait bound. The /// non-auto-trait bound is called the "principal" of the trait /// object. /// @@ -680,7 +680,8 @@ impl<'tcx> List> { #[inline] pub fn projection_bounds<'a>(&'a self) -> - impl Iterator> + 'a { + impl Iterator> + 'a + { self.iter().filter_map(|predicate| { match *predicate { ExistentialPredicate::Projection(p) => Some(p), @@ -690,7 +691,7 @@ impl<'tcx> List> { } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { + pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { self.iter().filter_map(|predicate| { match *predicate { ExistentialPredicate::AutoTrait(d) => Some(d), @@ -711,17 +712,17 @@ impl<'tcx> Binder<&'tcx List>> { #[inline] pub fn projection_bounds<'a>(&'a self) -> - impl Iterator> + 'a { + impl Iterator> + 'a { self.skip_binder().projection_bounds().map(Binder::bind) } #[inline] - pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { + pub fn auto_traits<'a>(&'a self) -> impl Iterator + 'a { self.skip_binder().auto_traits() } pub fn iter<'a>(&'a self) - -> impl DoubleEndedIterator>> + 'tcx { + -> impl DoubleEndedIterator>> + 'tcx { self.skip_binder().iter().cloned().map(Binder::bind) } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index f0bdb0018ef..f52ad33b3d0 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -450,11 +450,11 @@ fn subroutine_type_metadata( false); } -// FIXME(1563) This is all a bit of a hack because 'trait pointer' is an ill- -// defined concept. For the case of an actual trait pointer (i.e., Box, -// &Trait), trait_object_type should be the whole thing (e.g, Box) and -// trait_type should be the actual trait (e.g., Trait). Where the trait is part -// of a DST struct, there is no trait_object_type and the results of this +// FIXME(1563): This is all a bit of a hack because 'trait pointer' is an ill- +// defined concept. For the case of an actual trait pointer (i.e., `Box`, +// `&Trait`), `trait_object_type` should be the whole thing (e.g, `Box`) and +// `trait_type` should be the actual trait (e.g., `Trait`). Where the trait is part +// of a DST struct, there is no `trait_object_type` and the results of this // function will be a little bit weird. fn trait_pointer_metadata( cx: &CodegenCx<'ll, 'tcx>, @@ -464,13 +464,13 @@ fn trait_pointer_metadata( ) -> &'ll DIType { // The implementation provided here is a stub. It makes sure that the trait // type is assigned the correct name, size, namespace, and source location. - // But it does not describe the trait's methods. + // However, it does not describe the trait's methods. let containing_scope = match trait_type.sty { ty::Dynamic(ref data, ..) => data.principal_def_id().map(|did| get_namespace_for_item(cx, did)), _ => { - bug!("debuginfo: Unexpected trait-object type in \ + bug!("debuginfo: unexpected trait-object type in \ trait_pointer_metadata(): {:?}", trait_type); } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 4800bb9365c..05fbe07cac2 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1056,8 +1056,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { } for (poly_predicate, _) in bounds.projection_bounds { let tcx = self.tcx; - if self.visit(poly_predicate.skip_binder().ty) || - self.visit_trait(poly_predicate.skip_binder().projection_ty.trait_ref(tcx)) { + if self.visit(poly_predicate.skip_binder().ty) + || self.visit_trait(poly_predicate.skip_binder().projection_ty.trait_ref(tcx)) + { return; } } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index e8e0dd8425b..9857dee0583 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1515,7 +1515,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { assoc_name: ast::Ident, span: Span) -> Result, ErrorReported> - where I: Iterator> + where I: Iterator> { let bound = match bounds.next() { Some(bound) => bound, @@ -1524,8 +1524,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { "associated type `{}` not found for `{}`", assoc_name, ty_param_name) - .span_label(span, format!("associated type `{}` not found", assoc_name)) - .emit(); + .span_label(span, format!("associated type `{}` not found", assoc_name)) + .emit(); return Err(ErrorReported); } }; @@ -1544,7 +1544,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { item.kind == ty::AssocKind::Type && self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id()) }) - .and_then(|item| self.tcx().hir().span_if_local(item.def_id)); + .and_then(|item| self.tcx().hir().span_if_local(item.def_id)); if let Some(span) = bound_span { err.span_label(span, format!("ambiguous `{}` from `{}`", diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index e8ff83e7d2b..08033b46b80 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2030,7 +2030,7 @@ fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span, qpath: & impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx - } + } fn get_type_parameter_bounds(&self, _: Span, def_id: DefId) -> &'tcx ty::GenericPredicates<'tcx> diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index a14040fe59a..44f9b82f8cd 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -226,7 +226,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> { if let Some(trait_ref) = poly_trait_ref.no_bound_vars() { self.tcx().mk_projection(item_def_id, trait_ref.substs) } else { - // no late-bound regions, we can just ignore the binder + // There are no late-bound regions; we can just ignore the binder. span_err!( self.tcx().sess, span, @@ -239,17 +239,16 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> { } fn normalize_ty(&self, _span: Span, ty: Ty<'tcx>) -> Ty<'tcx> { - // types in item signatures are not normalized, to avoid undue - // dependencies. + // Types in item signatures are not normalized to avoid undue dependencies. ty } fn set_tainted_by_errors(&self) { - // no obvious place to track this, so just let it go + // There's no obvious place to track this, so just let it go. } fn record_ty(&self, _hir_id: hir::HirId, _ty: Ty<'tcx>, _span: Span) { - // no place to record types from signatures? + // There's no place to record types from signatures? } } @@ -260,8 +259,8 @@ fn type_param_predicates( use rustc::hir::*; // In the AST, bounds can derive from two places. Either - // written inline like `` or in a where clause like - // `where T : Foo`. + // written inline like `` or in a where-clause like + // `where T: Foo`. let param_id = tcx.hir().as_local_hir_id(def_id).unwrap(); let param_owner = tcx.hir().ty_param_owner(param_id); @@ -334,7 +333,7 @@ fn type_param_predicates( impl ItemCtxt<'tcx> { /// Finds bounds from `hir::Generics`. This requires scanning through the /// AST. We do this to avoid having to convert *all* the bounds, which - /// would create artificial cycles. Instead we can only convert the + /// would create artificial cycles. Instead, we can only convert the /// bounds for a type parameter `X` if `X::Foo` is used. fn type_parameter_bounds_in_generics( &self, @@ -2292,7 +2291,7 @@ fn explicit_predicates_of( /// Converts a specific `GenericBound` from the AST into a set of /// predicates that apply to the self type. A vector is returned /// because this can be anywhere from zero predicates (`T: ?Sized` adds no -/// predicates) to one (`T: Foo`) to many (`T: Bar` adds `T: Bar` +/// predicates) to one (`T: Foo`) to many (`T: Bar` adds `T: Bar` /// and `::X == i32`). fn predicates_from_bound<'tcx>( astconv: &dyn AstConv<'tcx>,