From aebea522632af459763c9aa75358906199066a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Wed, 21 Oct 2020 18:25:28 +0200 Subject: [PATCH] Skip most of create_substs_for_ast_path if type is not generic Co-authored-by: varkor --- compiler/rustc_typeck/src/astconv/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 9b814f6b7ee66..2f64597a510f0 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -337,6 +337,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { 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> {