Skip to content

Commit 58797b0

Browse files
committed
review comments
1 parent 4556130 commit 58797b0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ fn suggest_restriction(
175175
trait_ref: ty::PolyTraitRef<'_>,
176176
super_traits: Option<(&Ident, &hir::GenericBounds<'_>)>,
177177
) {
178+
// When we are dealing with a trait, `super_traits` will be `Some`:
179+
// Given `trait T: A + B + C {}`
180+
// - ^^^^^^^^^ GenericBounds
181+
// |
182+
// &Ident
178183
let span = generics.where_clause.span_for_predicates_or_empty_place();
179184
if span.from_expansion() || span.desugaring_kind().is_some() {
180185
return;
@@ -311,7 +316,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
311316
ident,
312317
kind: hir::ItemKind::Trait(_, _, generics, bounds, _),
313318
..
314-
}) if param_ty && self_ty == self.tcx.types.self_param => {
319+
}) if self_ty == self.tcx.types.self_param => {
320+
assert!(param_ty);
315321
// Restricting `Self` for a single method.
316322
suggest_restriction(
317323
&generics,
@@ -329,7 +335,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
329335
generics,
330336
kind: hir::TraitItemKind::Fn(..),
331337
..
332-
}) if param_ty && self_ty == self.tcx.types.self_param => {
338+
}) if self_ty == self.tcx.types.self_param => {
339+
assert!(param_ty);
333340
// Restricting `Self` for a single method.
334341
suggest_restriction(
335342
&generics, "`Self`", err, None, projection, trait_ref, None,

0 commit comments

Comments
 (0)