diff options
| author | Michael Goulet <michael@errs.io> | 2025-10-03 10:32:11 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-10-03 10:32:23 -0400 |
| commit | e3f104608c0ad26e80b1ebedef2ab8a748189e52 (patch) | |
| tree | ddd35a62d99de62314acddbf2cb64530f2730367 /compiler | |
| parent | dd091003ace19d9556c647d87f7a9cd1e8dcc17e (diff) | |
| download | rust-e3f104608c0ad26e80b1ebedef2ab8a748189e52.tar.gz rust-e3f104608c0ad26e80b1ebedef2ab8a748189e52.zip | |
Don't normalize higher-ranked assumptions if they're not used
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/confirmation.rs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 7ad65a1df8e..708a53f6c65 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -423,19 +423,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { constituents.types, ); - // FIXME(coroutine_clone): We could uplift this into `collect_predicates_for_types` - // and do this for `Copy`/`Clone` too, but that's feature-gated so it doesn't really - // matter yet. - for assumption in constituents.assumptions { - let assumption = normalize_with_depth_to( - self, - obligation.param_env, - cause.clone(), - obligation.recursion_depth + 1, - assumption, - &mut obligations, - ); - self.infcx.register_region_assumption(assumption); + // Only normalize these goals if `-Zhigher-ranked-assumptions` is enabled, since + // we don't want to cause ourselves to do extra work if we're not even able to + // take advantage of these assumption clauses. + if self.tcx().sess.opts.unstable_opts.higher_ranked_assumptions { + // FIXME(coroutine_clone): We could uplift this into `collect_predicates_for_types` + // and do this for `Copy`/`Clone` too, but that's feature-gated so it doesn't really + // matter yet. + for assumption in constituents.assumptions { + let assumption = normalize_with_depth_to( + self, + obligation.param_env, + cause.clone(), + obligation.recursion_depth + 1, + assumption, + &mut obligations, + ); + self.infcx.register_region_assumption(assumption); + } } Ok(obligations) |
