From 893772025d4350ba1c8bb417825a03ccd50ea046 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 12 Dec 2022 16:43:38 -0300 Subject: [PATCH 1/4] Fix typo --- compiler/rustc_hir_analysis/src/collect/predicates_of.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 45e241f4e093d..32dfd5831ef9b 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -75,7 +75,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP const NO_GENERICS: &hir::Generics<'_> = hir::Generics::empty(); - // We use an `IndexSet` to preserves order of insertion. + // We use an `IndexSet` to preserve order of insertion. // Preserving the order of insertion is important here so as not to break UI tests. let mut predicates: FxIndexSet<(ty::Predicate<'_>, Span)> = FxIndexSet::default(); From b0c32284043220ac83243a3362a772a0312d8707 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 12 Dec 2022 16:44:39 -0300 Subject: [PATCH 2/4] Join match arms since they do the same thing --- compiler/rustc_hir_analysis/src/collect/predicates_of.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 32dfd5831ef9b..d7dd015fb6803 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -97,11 +97,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP | ItemKind::Struct(_, ref generics) | ItemKind::Union(_, ref generics) => *generics, - ItemKind::Trait(_, _, ref generics, ..) => { - is_trait = Some(ty::TraitRef::identity(tcx, def_id)); - *generics - } - ItemKind::TraitAlias(ref generics, _) => { + ItemKind::Trait(_, _, ref generics, ..) | ItemKind::TraitAlias(ref generics, _) => { is_trait = Some(ty::TraitRef::identity(tcx, def_id)); *generics } From 4ae0c5518d0d8a835a84bac05dc1691aca06222e Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 12 Dec 2022 16:46:54 -0300 Subject: [PATCH 3/4] Make InternalSubsts rust docs a bit clearer --- compiler/rustc_middle/src/ty/subst.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index a1b084a5e891e..f8385c4701605 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -252,7 +252,7 @@ impl<'tcx, D: TyDecoder>> Decodable for GenericArg<'tcx> { } } -/// A substitution mapping generic parameters to new values. +/// List of generic arguments that are gonna be used to substitute generic parameters. pub type InternalSubsts<'tcx> = List>; pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>; From b22769a7bdd40ba01bf0792c86ba763a525d8857 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 12 Dec 2022 16:46:18 -0300 Subject: [PATCH 4/4] Clarify explicit_predicates_of is_assoc_item_ty comment --- compiler/rustc_hir_analysis/src/collect/predicates_of.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index d7dd015fb6803..19a1b5da41d77 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -402,9 +402,10 @@ pub(super) fn explicit_predicates_of<'tcx>( // For a predicate from a where clause to become a bound on an // associated type: // * It must use the identity substs of the item. - // * Since any generic parameters on the item are not in scope, - // this means that the item is not a GAT, and its identity - // substs are the same as the trait's. + // * We're in the scope of the trait, so we can't name any + // parameters of the GAT. That means that all we need to + // check are that the substs of the projection are the + // identity substs of the trait. // * It must be an associated type for this trait (*not* a // supertrait). if let ty::Projection(projection) = ty.kind() {