Skip to content

Commit 5b63d3f

Browse files
committed
Only call generics_of query in should_encode_mir when necessary
1 parent e0d89e5 commit 5b63d3f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,10 @@ fn should_encode_mir(
11131113
DefKind::SyntheticCoroutineBody => (false, true),
11141114
// Full-fledged functions + closures
11151115
DefKind::AssocFn | DefKind::Fn | DefKind::Closure => {
1116-
let generics = tcx.generics_of(def_id);
11171116
let opt = tcx.sess.opts.unstable_opts.always_encode_mir
11181117
|| (tcx.sess.opts.output_types.should_codegen()
11191118
&& reachable_set.contains(&def_id)
1120-
&& (generics.requires_monomorphization(tcx)
1119+
&& (tcx.generics_of(def_id).requires_monomorphization(tcx)
11211120
|| tcx.cross_crate_inlinable(def_id)));
11221121
// The function has a `const` modifier or is in a `const trait`.
11231122
let is_const_fn = tcx.is_const_fn(def_id.to_def_id());

0 commit comments

Comments
 (0)