diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 3486a986c88eb..d019c75545d16 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -310,6 +310,9 @@ pub(crate) fn build_function<'tcx>( generics.params.sort_by_key(|param| cx.tcx.def_ident_span(param.def_id).unwrap()); } + // FIXME(fmease): @Temporary + crate::clean::simplify::move_bounds_to_generic_parameters(&mut generics); + let decl = clean_poly_fn_sig(cx, Some(def_id), sig); Box::new(clean::Function { decl, generics }) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index f4110428e5c27..67196b002ae9a 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -750,7 +750,7 @@ pub(crate) fn clean_generics<'tcx>( fn clean_ty_generics<'tcx>( cx: &mut DocContext<'tcx>, - generics: &ty::Generics, + generics: &'tcx ty::Generics, predicates: ty::GenericPredicates<'tcx>, _item_def_id: DefId, ) -> Generics { @@ -787,10 +787,48 @@ fn clean_ty_generics<'tcx>( let mut impl_trait_proj = FxHashMap::>)>>::default(); + let item_span = { + if !predicates.predicates.is_empty() { + let span = cx.tcx.def_span(_item_def_id); + // FIXME: this is not correct if spans come from different expansions! + let params_sp = { + let mut params = generics.params.iter(); + if let Some(param) = params.next() { + let mut sp = cx.tcx.def_ident_span(param.def_id).unwrap(); + while let Some(param) = params.next() { + sp = sp.to(cx.tcx.def_ident_span(param.def_id).unwrap()); + } + sp + } else { + None + } + }; + + Some(span) + } else { + None + } + }; + let where_predicates = predicates .predicates .iter() - .flat_map(|(pred, _)| { + .flat_map(|(pred, span)| { + if !(span.is_dummy() + || span.is_empty() + || span.from_expansion() + || !cx.tcx.sess.source_map().is_span_accessible(*span)) + { + let mut diag = cx.tcx.dcx().struct_span_warn(*span, format!("pred={pred:?}")); + + if let Some(item_span) = item_span { + diag.span_note(item_span, "span"); + diag.note(if item_span.contains(*span) { "<...>" } else { "where ... " }); + } + + diag.emit(); + } + let mut projection = None; let param_idx = (|| { let bound_p = pred.kind();