Skip to content

Commit

Permalink
A few cosmetic improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Regueiro committed Aug 5, 2019
1 parent 4be0675 commit 8f9ca24
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Expand Up @@ -2234,7 +2234,7 @@ pub enum UseKind {
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct TraitRef {
pub path: P<Path>,
// 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,
}
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/ty/mod.rs
Expand Up @@ -904,7 +904,7 @@ pub struct Generics {
pub parent_count: usize,
pub params: Vec<GenericParamDef>,

/// 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<DefId, u32>,

Expand Down Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -1646,10 +1646,10 @@ pub type PlaceholderConst = Placeholder<BoundVar>;
/// 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<ty::Predicate<'tcx>>,
/// 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
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions src/librustc/ty/sty.rs
Expand Up @@ -646,7 +646,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
///
/// 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.
///
Expand Down Expand Up @@ -680,7 +680,8 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {

#[inline]
pub fn projection_bounds<'a>(&'a self) ->
impl Iterator<Item=ExistentialProjection<'tcx>> + 'a {
impl Iterator<Item = ExistentialProjection<'tcx>> + 'a
{
self.iter().filter_map(|predicate| {
match *predicate {
ExistentialPredicate::Projection(p) => Some(p),
Expand All @@ -690,7 +691,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
}

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

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

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

pub fn iter<'a>(&'a self)
-> impl DoubleEndedIterator<Item=Binder<ExistentialPredicate<'tcx>>> + 'tcx {
-> impl DoubleEndedIterator<Item = Binder<ExistentialPredicate<'tcx>>> + 'tcx {
self.skip_binder().iter().cloned().map(Binder::bind)
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Expand Up @@ -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), trait_object_type should be the whole thing (e.g, Box<Trait>) 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`), `trait_object_type` should be the whole thing (e.g, `Box<Trait>`) 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>,
Expand All @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_privacy/lib.rs
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -1515,7 +1515,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
assoc_name: ast::Ident,
span: Span)
-> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
where I: Iterator<Item=ty::PolyTraitRef<'tcx>>
where I: Iterator<Item = ty::PolyTraitRef<'tcx>>
{
let bound = match bounds.next() {
Some(bound) => bound,
Expand All @@ -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);
}
};
Expand All @@ -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 `{}`",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Expand Up @@ -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>
Expand Down
17 changes: 8 additions & 9 deletions src/librustc_typeck/collect.rs
Expand Up @@ -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,
Expand All @@ -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?
}
}

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

// In the AST, bounds can derive from two places. Either
// written inline like `<T : Foo>` or in a where clause like
// `where T : Foo`.
// written inline like `<T: Foo>` 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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<X=i32>` adds `T: Bar`
/// predicates) to one (`T: Foo`) to many (`T: Bar<X = i32>` adds `T: Bar`
/// and `<T as Bar>::X == i32`).
fn predicates_from_bound<'tcx>(
astconv: &dyn AstConv<'tcx>,
Expand Down

0 comments on commit 8f9ca24

Please sign in to comment.