diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 9b814f6b7ee66a371961d63e45695356f9e7acd8..2f64597a510f090367505aa9303db3a47a3673d4 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -337,6 +337,14 @@ fn create_substs_for_ast_path<'a>( infer_args, ); + // Skip processing if type has no generic parameters. + // Traits always have `Self` as a generic parameter, which means they will not return early + // here and so associated type bindings will be handled regardless of whether there are any + // non-`Self` generic parameters. + if generic_params.params.len() == 0 { + return (tcx.intern_substs(&[]), vec![], arg_count); + } + let is_object = self_ty.map_or(false, |ty| ty == self.tcx().types.trait_object_dummy_self); struct SubstsForAstPathCtxt<'a, 'tcx> {