mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
A few cosmetic improvements.
This commit is contained in:
parent
4be0675589
commit
8f9ca24f55
@ -2234,7 +2234,7 @@ pub enum UseKind {
|
|||||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||||
pub struct TraitRef {
|
pub struct TraitRef {
|
||||||
pub path: P<Path>,
|
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)]
|
#[stable_hasher(ignore)]
|
||||||
pub hir_ref_id: HirId,
|
pub hir_ref_id: HirId,
|
||||||
}
|
}
|
||||||
|
@ -904,7 +904,7 @@ pub struct Generics {
|
|||||||
pub parent_count: usize,
|
pub parent_count: usize,
|
||||||
pub params: Vec<GenericParamDef>,
|
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)]
|
#[stable_hasher(ignore)]
|
||||||
pub param_def_id_to_index: FxHashMap<DefId, u32>,
|
pub param_def_id_to_index: FxHashMap<DefId, u32>,
|
||||||
|
|
||||||
@ -1252,7 +1252,7 @@ impl<'tcx> TraitPredicate<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> PolyTraitPredicate<'tcx> {
|
impl<'tcx> PolyTraitPredicate<'tcx> {
|
||||||
pub fn def_id(&self) -> DefId {
|
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()
|
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
|
/// Note that this is not the `DefId` of the `TraitRef` containing this
|
||||||
/// associated type, which is in `tcx.associated_item(projection_def_id()).container`.
|
/// associated type, which is in `tcx.associated_item(projection_def_id()).container`.
|
||||||
pub fn projection_def_id(&self) -> DefId {
|
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
|
self.skip_binder().projection_ty.item_def_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1646,10 +1646,10 @@ pub type PlaceholderConst = Placeholder<BoundVar>;
|
|||||||
/// particular point.
|
/// particular point.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
|
||||||
pub struct ParamEnv<'tcx> {
|
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
|
/// the set of bounds on the in-scope type parameters, translated
|
||||||
/// into Obligations, and elaborated and normalized.
|
/// into `Obligation`s, and elaborated and normalized.
|
||||||
pub caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
|
pub caller_bounds: &'tcx List<(ty::Predicate<'tcx>, Span)>,
|
||||||
|
|
||||||
/// Typically, this is `Reveal::UserFacing`, but during codegen we
|
/// Typically, this is `Reveal::UserFacing`, but during codegen we
|
||||||
/// want `Reveal::All` -- note that this is always paired with an
|
/// want `Reveal::All` -- note that this is always paired with an
|
||||||
@ -2796,7 +2796,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
} else {
|
} 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::AssocConst
|
||||||
| DefKind::Method
|
| DefKind::Method
|
||||||
| DefKind::AssocTy => true,
|
| DefKind::AssocTy => true,
|
||||||
|
@ -646,7 +646,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
|
|||||||
///
|
///
|
||||||
/// A Rust trait object type consists (in addition to a lifetime bound)
|
/// 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 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
|
/// non-auto-trait bound is called the "principal" of the trait
|
||||||
/// object.
|
/// object.
|
||||||
///
|
///
|
||||||
@ -680,7 +680,8 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn projection_bounds<'a>(&'a self) ->
|
pub fn projection_bounds<'a>(&'a self) ->
|
||||||
impl Iterator<Item=ExistentialProjection<'tcx>> + 'a {
|
impl Iterator<Item = ExistentialProjection<'tcx>> + 'a
|
||||||
|
{
|
||||||
self.iter().filter_map(|predicate| {
|
self.iter().filter_map(|predicate| {
|
||||||
match *predicate {
|
match *predicate {
|
||||||
ExistentialPredicate::Projection(p) => Some(p),
|
ExistentialPredicate::Projection(p) => Some(p),
|
||||||
@ -690,7 +691,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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| {
|
self.iter().filter_map(|predicate| {
|
||||||
match *predicate {
|
match *predicate {
|
||||||
ExistentialPredicate::AutoTrait(d) => Some(d),
|
ExistentialPredicate::AutoTrait(d) => Some(d),
|
||||||
@ -711,17 +712,17 @@ impl<'tcx> Binder<&'tcx List<ExistentialPredicate<'tcx>>> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn projection_bounds<'a>(&'a self) ->
|
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)
|
self.skip_binder().projection_bounds().map(Binder::bind)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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()
|
self.skip_binder().auto_traits()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter<'a>(&'a self)
|
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)
|
self.skip_binder().iter().cloned().map(Binder::bind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,11 +450,11 @@ fn subroutine_type_metadata(
|
|||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(1563) This is all a bit of a hack because 'trait pointer' is an ill-
|
// 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>,
|
// 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`), `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
|
// `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
|
// of a DST struct, there is no `trait_object_type` and the results of this
|
||||||
// function will be a little bit weird.
|
// function will be a little bit weird.
|
||||||
fn trait_pointer_metadata(
|
fn trait_pointer_metadata(
|
||||||
cx: &CodegenCx<'ll, 'tcx>,
|
cx: &CodegenCx<'ll, 'tcx>,
|
||||||
@ -464,13 +464,13 @@ fn trait_pointer_metadata(
|
|||||||
) -> &'ll DIType {
|
) -> &'ll DIType {
|
||||||
// The implementation provided here is a stub. It makes sure that the trait
|
// The implementation provided here is a stub. It makes sure that the trait
|
||||||
// type is assigned the correct name, size, namespace, and source location.
|
// 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 {
|
let containing_scope = match trait_type.sty {
|
||||||
ty::Dynamic(ref data, ..) =>
|
ty::Dynamic(ref data, ..) =>
|
||||||
data.principal_def_id().map(|did| get_namespace_for_item(cx, did)),
|
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_pointer_metadata(): {:?}",
|
||||||
trait_type);
|
trait_type);
|
||||||
}
|
}
|
||||||
|
@ -1056,8 +1056,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
for (poly_predicate, _) in bounds.projection_bounds {
|
for (poly_predicate, _) in bounds.projection_bounds {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
if self.visit(poly_predicate.skip_binder().ty) ||
|
if self.visit(poly_predicate.skip_binder().ty)
|
||||||
self.visit_trait(poly_predicate.skip_binder().projection_ty.trait_ref(tcx)) {
|
|| self.visit_trait(poly_predicate.skip_binder().projection_ty.trait_ref(tcx))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1515,7 +1515,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
assoc_name: ast::Ident,
|
assoc_name: ast::Ident,
|
||||||
span: Span)
|
span: Span)
|
||||||
-> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
|
-> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
|
||||||
where I: Iterator<Item=ty::PolyTraitRef<'tcx>>
|
where I: Iterator<Item = ty::PolyTraitRef<'tcx>>
|
||||||
{
|
{
|
||||||
let bound = match bounds.next() {
|
let bound = match bounds.next() {
|
||||||
Some(bound) => bound,
|
Some(bound) => bound,
|
||||||
@ -1524,8 +1524,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
"associated type `{}` not found for `{}`",
|
"associated type `{}` not found for `{}`",
|
||||||
assoc_name,
|
assoc_name,
|
||||||
ty_param_name)
|
ty_param_name)
|
||||||
.span_label(span, format!("associated type `{}` not found", assoc_name))
|
.span_label(span, format!("associated type `{}` not found", assoc_name))
|
||||||
.emit();
|
.emit();
|
||||||
return Err(ErrorReported);
|
return Err(ErrorReported);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1544,7 +1544,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
item.kind == ty::AssocKind::Type &&
|
item.kind == ty::AssocKind::Type &&
|
||||||
self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id())
|
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 {
|
if let Some(span) = bound_span {
|
||||||
err.span_label(span, format!("ambiguous `{}` from `{}`",
|
err.span_label(span, format!("ambiguous `{}` from `{}`",
|
||||||
|
@ -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> {
|
impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
||||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_type_parameter_bounds(&self, _: Span, def_id: DefId)
|
fn get_type_parameter_bounds(&self, _: Span, def_id: DefId)
|
||||||
-> &'tcx ty::GenericPredicates<'tcx>
|
-> &'tcx ty::GenericPredicates<'tcx>
|
||||||
|
@ -226,7 +226,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||||||
if let Some(trait_ref) = poly_trait_ref.no_bound_vars() {
|
if let Some(trait_ref) = poly_trait_ref.no_bound_vars() {
|
||||||
self.tcx().mk_projection(item_def_id, trait_ref.substs)
|
self.tcx().mk_projection(item_def_id, trait_ref.substs)
|
||||||
} else {
|
} 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!(
|
span_err!(
|
||||||
self.tcx().sess,
|
self.tcx().sess,
|
||||||
span,
|
span,
|
||||||
@ -239,17 +239,16 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn normalize_ty(&self, _span: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn normalize_ty(&self, _span: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
// types in item signatures are not normalized, to avoid undue
|
// Types in item signatures are not normalized to avoid undue dependencies.
|
||||||
// dependencies.
|
|
||||||
ty
|
ty
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_tainted_by_errors(&self) {
|
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) {
|
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::*;
|
use rustc::hir::*;
|
||||||
|
|
||||||
// In the AST, bounds can derive from two places. Either
|
// In the AST, bounds can derive from two places. Either
|
||||||
// written inline like `<T : Foo>` or in a where clause like
|
// written inline like `<T: Foo>` or in a where-clause like
|
||||||
// `where T : Foo`.
|
// `where T: Foo`.
|
||||||
|
|
||||||
let param_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let param_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
let param_owner = tcx.hir().ty_param_owner(param_id);
|
let param_owner = tcx.hir().ty_param_owner(param_id);
|
||||||
@ -334,7 +333,7 @@ fn type_param_predicates(
|
|||||||
impl ItemCtxt<'tcx> {
|
impl ItemCtxt<'tcx> {
|
||||||
/// Finds bounds from `hir::Generics`. This requires scanning through the
|
/// Finds bounds from `hir::Generics`. This requires scanning through the
|
||||||
/// AST. We do this to avoid having to convert *all* the bounds, which
|
/// 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.
|
/// bounds for a type parameter `X` if `X::Foo` is used.
|
||||||
fn type_parameter_bounds_in_generics(
|
fn type_parameter_bounds_in_generics(
|
||||||
&self,
|
&self,
|
||||||
@ -2292,7 +2291,7 @@ fn explicit_predicates_of(
|
|||||||
/// Converts a specific `GenericBound` from the AST into a set of
|
/// Converts a specific `GenericBound` from the AST into a set of
|
||||||
/// predicates that apply to the self type. A vector is returned
|
/// predicates that apply to the self type. A vector is returned
|
||||||
/// because this can be anywhere from zero predicates (`T: ?Sized` adds no
|
/// 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`).
|
/// and `<T as Bar>::X == i32`).
|
||||||
fn predicates_from_bound<'tcx>(
|
fn predicates_from_bound<'tcx>(
|
||||||
astconv: &dyn AstConv<'tcx>,
|
astconv: &dyn AstConv<'tcx>,
|
||||||
|
Loading…
Reference in New Issue
Block a user