-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make (try_)subst_and_normalize_erasing_regions
take EarlyBinder
#110297
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
@@ -435,7 +435,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty< | |||
let output_ty = fn_sig.output(); | |||
if output_ty.contains(*param_ty) { | |||
if let Ok(new_ty) = cx.tcx.try_subst_and_normalize_erasing_regions( | |||
new_subst, cx.param_env, output_ty) { | |||
new_subst, cx.param_env, EarlyBinder(output_ty)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, seems like the subst_identity().skip_binder()
call to create this isn't correct...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yeah I agree that this looks weird now. Would it be better as skip_binder().skip_binder()
? Or are you envisioning a larger change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to look a bit more at this. But likely the easiest thing is to either just leave it as-is with a comment, or map/skip_binder above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay thanks! I changed it to skip_binder()
above in the most recent commit, but happy to try to improve it further.
Yeah, I also thought about mapping it, it seems like we always skip the inner Binder
there but want to keep the EarlyBinder
around, so could do something like
let fn_sig = cx.tcx.fn_sig(def_id).map_bound(|t| t.skip_binder());
(and then replace the calls to .inputs()
with .skip_binder().inputs()
)
but I wasn't sure if this was more or less readable than how it is now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR doesn't necessarily need to fix this, at minimum we should probably open a clippy issue about it and add a FIXME before this PR lands
823b771
to
7753208
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
☔ The latest upstream changes (presumably #96840) made this pull request unmergeable. Please resolve the merge conflicts. |
7753208
to
8f57d5b
Compare
I will r+ this once its been rebased again, that |
… skip_binder in mir subst methods
8f57d5b
to
d27f401
Compare
Hi @BoxyUwU, thanks for taking a look! Sorry, I've also been busy recently and sort of forgot about this PR 😅 I rebased and added the FIXME as you suggested, the |
@bors r+ |
Rollup of 7 pull requests Successful merges: - rust-lang#110297 (Make `(try_)subst_and_normalize_erasing_regions` take `EarlyBinder`) - rust-lang#110827 (Fix lifetime suggestion for type aliases with objects in them) - rust-lang#111022 (Use smaller ints for bitflags) - rust-lang#111056 (Fix some suggestions where a `Box<T>` is expected.) - rust-lang#111262 (Further normalize msvc-non-utf8-ouput) - rust-lang#111265 (Make generics_of has_self on RPITITs delegate to the opaque) - rust-lang#111323 (Give a more helpful error when running the rustc shim directly) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Changes
subst_and_normalize_erasing_regions
andtry_subst_and_normalize_erasing_regions
to takeEarlyBinder<T>
instead ofT
.(related to #105779)
This was suggested by @BoxyUwU in #107753 (comment). After changing
type_of
to returnEarlyBinder
, there were several places where the binder was immediately skipped to calltcx.subst_and_normalize_erasing_regions
, only for the binder to be reconstructed inside of that method.r? @BoxyUwU