about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-27 06:53:47 +0000
committerbors <bors@rust-lang.org>2020-11-27 06:53:47 +0000
commit72d2a7cd357894be4076a6352da587e499c549b9 (patch)
tree5de1c0befb96a8930dd6fa9740d571e6c279294f
parentcfed9184f44cbd02662eb7715d6226ae885ef5c3 (diff)
parentaebea522632af459763c9aa75358906199066a6d (diff)
downloadrust-72d2a7cd357894be4076a6352da587e499c549b9.tar.gz
rust-72d2a7cd357894be4076a6352da587e499c549b9.zip
Auto merge of #78194 - bugadani:generic, r=varkor
Skip most of `create_substs_for_ast_path` if type is not generic
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index 9b814f6b7ee..2f64597a510 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> {