rust-lang / types-team

Home of the "types team", affiliated with the compiler and lang teams.
https://rust-lang.github.io/types-team/
Apache License 2.0
94 stars 19 forks source link

`EarlyBinder` as default #78

Closed lcnr closed 1 year ago

lcnr commented 1 year ago

Proposal

Change all queries which currently have a bound_X variant to return EarlyBinder<T> by default and remove the bound_X version. Add a method fn EarlyBinder::<T>::subst_identity(self) -> T if these queries are used in the identity context and don't need to actually substitute anything.

Not having EarlyBinder be the default can very easily result in incorrect uses of these queries, e.g. https://github.com/rust-lang/rust/blob/736c675d2ab65bcde6554e1b73340c2dbc27c85a/compiler/rustc_hir_analysis/src/astconv/mod.rs#L2720 which I found while reviewing https://github.com/rust-lang/rust/pull/101947. The normalize_ty normalizes type_of(def_id) in the wrong environment as we only call subst afterwards.

Mentors or Reviewers

I am available to mentor and review this work.

Process

The main points of the Major Change Process are as follows:

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

rustbot commented 1 year ago

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/types

oli-obk commented 1 year ago

@rustbot second

lcnr commented 1 year ago

closing as accepted