///
/// Example:
///
- /// ```
- /// T: std::ops::Index<usize, Output = u32>
- /// ^1 ^^^^^^^^^^^^^^2 ^^^^3 ^^^^^^^^^^^4
+ /// ```ignore (illustrative)
+ /// T: std::ops::Index<usize, Output = u32>
+ /// // ^1 ^^^^^^^^^^^^^^2 ^^^^3 ^^^^^^^^^^^4
/// ```
///
/// 1. The `self_ty` here would refer to the type `T`.
///
/// For (generic) associated types
///
- /// ```
+ /// ```ignore (illustrative)
/// <Vec<u8> as Iterable<u8>>::Iter::<'a>
/// ```
///
///
/// Example:
///
- /// ```
+ /// ```ignore (illustrative)
/// poly_trait_ref = Iterator<Item = u32>
/// self_ty = Foo
/// ```
let self_ty_def_id = tcx.hir().local_def_id(self_ty).to_def_id();
for clause in where_clause {
if let hir::WherePredicate::BoundPredicate(pred) = clause {
- match pred.bounded_ty.kind {
- hir::TyKind::Path(hir::QPath::Resolved(_, path)) => match path.res {
- Res::Def(DefKind::TyParam, def_id) if def_id == self_ty_def_id => {}
- _ => continue,
- },
- _ => continue,
+ if pred.is_param_bound(self_ty_def_id) {
+ search_bounds(pred.bounds);
}
- search_bounds(pred.bounds);
}
}
}
///
/// Example:
///
- /// ```
+ /// ```ignore (illustrative)
/// fn foo<T: Bar + Baz>() { }
- /// ^ ^^^^^^^^^ ast_bounds
- /// param_ty
+ /// // ^ ^^^^^^^^^ ast_bounds
+ /// // param_ty
/// ```
///
/// The `sized_by_default` parameter indicates if, in this context, the `param_ty` should be
bf.unsafety,
bf.abi,
bf.decl,
- &hir::Generics::empty(),
None,
Some(ast_ty),
))
unsafety: hir::Unsafety,
abi: abi::Abi,
decl: &hir::FnDecl<'_>,
- generics: &hir::Generics<'_>,
- ident_span: Option<Span>,
+ generics: Option<&hir::Generics<'_>>,
hir_ty: Option<&hir::Ty<'_>>,
) -> ty::PolyFnSig<'tcx> {
debug!("ty_of_fn");
let mut visitor = HirPlaceholderCollector::default();
let mut infer_replacements = vec![];
- walk_generics(&mut visitor, generics);
+ if let Some(generics) = generics {
+ walk_generics(&mut visitor, generics);
+ }
let input_tys: Vec<_> = decl
.inputs
let mut diag = crate::collect::placeholder_type_error_diag(
tcx,
- ident_span.map(|sp| sp.shrink_to_hi()),
- generics.params,
+ generics,
visitor.0,
infer_replacements.iter().map(|(s, _)| *s).collect(),
true,