Skip to content

Skip most of create_substs_for_ast_path if type is not generic #78194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down