X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_typeck%2Fsrc%2Fcheck%2Fwfcheck.rs;h=829485367e0a4ee9481a7fdca20fec61cb987f2c;hb=7907385999b4a83d37ed31d334f3ed9ca02983a1;hp=4e3e32670e96e0b29f32190317bc55ce924a6f0b;hpb=ea131bca17144d01434cc5ec5d12cb03bc69dbcb;p=rust.git diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 4e3e32670e9..829485367e0 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -37,7 +37,7 @@ /// Helper type of a temporary returned by `.for_item(...)`. /// This is necessary because we can't write the following bound: /// -/// ```rust +/// ```ignore (illustrative) /// F: for<'b, 'tcx> where 'tcx FnOnce(FnCtxt<'b, 'tcx>) /// ``` struct CheckWfFcxBuilder<'tcx> { @@ -420,15 +420,11 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe let suggestion = format!( "{} {}", - if !gat_item_hir.generics.where_clause.predicates.is_empty() { - "," - } else { - " where" - }, + if !gat_item_hir.generics.predicates.is_empty() { "," } else { " where" }, unsatisfied_bounds.join(", "), ); err.span_suggestion( - gat_item_hir.generics.where_clause.tail_span_for_suggestion(), + gat_item_hir.generics.tail_span_for_predicate_suggestion(), &format!("add the required where clause{plural}"), suggestion, Applicability::MachineApplicable, @@ -1733,7 +1729,6 @@ fn check_variances_for_type_defn<'tcx>( let explicitly_bounded_params = Lazy::new(|| { let icx = crate::collect::ItemCtxt::new(tcx, item.def_id.to_def_id()); hir_generics - .where_clause .predicates .iter() .filter_map(|predicate| match predicate { @@ -1760,8 +1755,7 @@ fn check_variances_for_type_defn<'tcx>( match param.name { hir::ParamName::Error => {} _ => { - let has_explicit_bounds = - !param.bounds.is_empty() || explicitly_bounded_params.contains(¶meter); + let has_explicit_bounds = explicitly_bounded_params.contains(¶meter); report_bivariance(tcx, param, has_explicit_bounds); } } @@ -1819,13 +1813,12 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, mut span: Span, id: hir::HirI // only use the span of the predicate clause (#90869) - if let Some(hir::Generics { where_clause, .. }) = + if let Some(hir::Generics { predicates, .. }) = hir_node.and_then(|node| node.generics()) { let obligation_span = obligation.cause.span(fcx.tcx); - span = where_clause - .predicates + span = predicates .iter() // There seems to be no better way to find out which predicate we are in .find(|pred| pred.span().contains(obligation_span))