X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_typeck%2Fsrc%2Fastconv%2Fmod.rs;h=2303e64e1007456e76f2343d6215cf3fe4caf676;hb=7907385999b4a83d37ed31d334f3ed9ca02983a1;hp=3e36ffa7fe0d2f4291dfae5a032f7cb9752ca61f;hpb=cbfbc3be7d1fd5090bdcb1e3c53fa4d894aa99f4;p=rust.git diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 3e36ffa7fe0..2303e64e100 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -294,9 +294,9 @@ pub fn ast_path_substs_for_ty( /// /// Example: /// - /// ``` - /// T: std::ops::Index - /// ^1 ^^^^^^^^^^^^^^2 ^^^^3 ^^^^^^^^^^^4 + /// ```ignore (illustrative) + /// T: std::ops::Index + /// // ^1 ^^^^^^^^^^^^^^2 ^^^^3 ^^^^^^^^^^^4 /// ``` /// /// 1. The `self_ty` here would refer to the type `T`. @@ -310,7 +310,7 @@ pub fn ast_path_substs_for_ty( /// /// For (generic) associated types /// - /// ``` + /// ```ignore (illustrative) /// as Iterable>::Iter::<'a> /// ``` /// @@ -756,7 +756,7 @@ fn instantiate_poly_trait_ref_inner( /// /// Example: /// - /// ``` + /// ```ignore (illustrative) /// poly_trait_ref = Iterator /// self_ty = Foo /// ``` @@ -924,14 +924,9 @@ pub(crate) fn add_implicitly_sized<'hir>( 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); } } } @@ -1026,10 +1021,10 @@ pub(crate) fn add_bounds<'hir, I: Iterator> /// /// Example: /// - /// ``` + /// ```ignore (illustrative) /// fn foo() { } - /// ^ ^^^^^^^^^ ast_bounds - /// param_ty + /// // ^ ^^^^^^^^^ ast_bounds + /// // param_ty /// ``` /// /// The `sized_by_default` parameter indicates if, in this context, the `param_ty` should be @@ -2389,7 +2384,6 @@ fn ast_ty_to_ty_inner(&self, ast_ty: &hir::Ty<'_>, borrowed: bool, in_path: bool bf.unsafety, bf.abi, bf.decl, - &hir::Generics::empty(), None, Some(ast_ty), )) @@ -2551,8 +2545,7 @@ pub fn ty_of_fn( unsafety: hir::Unsafety, abi: abi::Abi, decl: &hir::FnDecl<'_>, - generics: &hir::Generics<'_>, - ident_span: Option, + generics: Option<&hir::Generics<'_>>, hir_ty: Option<&hir::Ty<'_>>, ) -> ty::PolyFnSig<'tcx> { debug!("ty_of_fn"); @@ -2565,7 +2558,9 @@ pub fn 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 @@ -2617,8 +2612,7 @@ pub fn ty_of_fn( 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,