diff options
| author | Alexander Regueiro <alexreg@me.com> | 2018-11-01 02:00:32 +0000 |
|---|---|---|
| committer | Alexander Regueiro <alexreg@me.com> | 2018-11-03 04:09:34 +0000 |
| commit | 469c3bf75b5768611f65c65c3bbafab3c315dcdf (patch) | |
| tree | 0ca777b106340f31e58412882de04f901735a714 | |
| parent | 4bdc3d833af1229420fce37b245d5cccd1d7cc3f (diff) | |
| download | rust-469c3bf75b5768611f65c65c3bbafab3c315dcdf.tar.gz rust-469c3bf75b5768611f65c65c3bbafab3c315dcdf.zip | |
Resolve nits brought up in review.
| -rw-r--r-- | src/librustc_typeck/collect.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 21a1abd97a5..9ffbe1a68b8 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -58,6 +58,8 @@ use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety}; use std::iter; +struct OnlySelfBounds(bool); + /////////////////////////////////////////////////////////////////////////// // Main entry point @@ -331,7 +333,7 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> { ast_generics: &hir::Generics, param_id: ast::NodeId, ty: Ty<'tcx>, - only_self_bounds: bool, + only_self_bounds: OnlySelfBounds, ) -> Vec<(ty::Predicate<'tcx>, Span)> { let from_ty_params = ast_generics .params @@ -354,12 +356,10 @@ impl<'a, 'tcx> ItemCtxt<'a, 'tcx> { .flat_map(|bp| { let bt = if is_param(self.tcx, &bp.bounded_ty, param_id) { Some(ty) + } else if only_self_bounds.0 { + None } else { - if only_self_bounds { - None - } else { - Some(self.to_ty(&bp.bounded_ty)) - } + Some(self.to_ty(&bp.bounded_ty)) }; bp.bounds.iter().filter_map(move |b| { if let Some(bt) = bt { Some((bt, b)) } else { None } @@ -710,7 +710,10 @@ fn super_predicates_of<'a, 'tcx>( let superbounds1 = superbounds1.predicates(tcx, self_param_ty); // Convert any explicit superbounds in the where clause, - // e.g. `trait Foo where Self : Bar`: + // e.g. `trait Foo where Self : Bar`. + // In the case of trait aliases, however, we include all bounds in the where clause, + // so e.g. `trait Foo = where u32: PartialEq<Self>` would include `u32: PartialEq<Self>` + // as one of its "superpredicates". let is_trait_alias = ty::is_trait_alias(tcx, trait_def_id); let superbounds2 = icx.type_parameter_bounds_in_generics( generics, item.id, self_param_ty, !is_trait_alias); |
