Do not normalize closure signature when building FnOnce shim#120139
Merged
bors merged 1 commit intorust-lang:masterfrom Jan 24, 2024
Merged
Do not normalize closure signature when building FnOnce shim#120139bors merged 1 commit intorust-lang:masterfrom
FnOnce shim#120139bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
r? @BoxyUwU (rustbot has picked a reviewer for you, use r? to override) |
Collaborator
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
compiler-errors
commented
Jan 19, 2024
| assert_eq!(sig.inputs().len(), 1); | ||
| let args = tcx.mk_args_trait(self_ty, [sig.inputs()[0].into()]); | ||
| let tupled_inputs_ty = args.as_closure().sig().map_bound(|sig| sig.inputs()[0]); | ||
| let tupled_inputs_ty = tcx.instantiate_bound_regions_with_erased(tupled_inputs_ty); |
Contributor
Author
There was a problem hiding this comment.
If the types need normalization after monomorphization, then codegen will deal with this already.
Collaborator
|
☔ The latest upstream changes (presumably #120196) made this pull request unmergeable. Please resolve the merge conflicts. |
oli-obk
approved these changes
Jan 22, 2024
d3408f3 to
f700ee4
Compare
Member
|
@bors r+ |
Collaborator
fmease
added a commit
to fmease/rust
that referenced
this pull request
Jan 23, 2024
…yUwU Do not normalize closure signature when building `FnOnce` shim It is not necessary to normalize the closure signature when building an `FnOnce` shim for an `Fn`/`FnMut` closure. That closure shim is just calling `FnMut::call_mut(&mut self)` anyways. It's also somewhat sketchy that we were ever doing this to begin with, since we're normalizing with a `ParamEnv::reveal_all()` param-env, which is definitely not right with possibly polymorphic substs. This cuts out a tiny bit of unnecessary work in `Instance::resolve` and simplifies the signature because now we can unconditionally return an `Instance`.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 23, 2024
Rollup of 12 pull requests Successful merges: - rust-lang#112806 (Small code improvements in `collect_intra_doc_links.rs`) - rust-lang#119460 (coverage: Never emit improperly-ordered coverage regions) - rust-lang#119766 (Split tait and impl trait in assoc items logic) - rust-lang#120062 (llvm: change data layout bug to an error and make it trigger more) - rust-lang#120099 (linker: Refactor library linking methods in `trait Linker`) - rust-lang#120139 (Do not normalize closure signature when building `FnOnce` shim) - rust-lang#120160 (Manually implement derived `NonZero` traits.) - rust-lang#120171 (Fix assume and assert in jump threading) - rust-lang#120183 (Add `#[coverage(off)]` to closures introduced by `#[test]` and `#[bench]`) - rust-lang#120195 (add several resolution test cases) - rust-lang#120259 (Split Diagnostics for Uncommon Codepoints: Add List to Display Characters Involved) - rust-lang#120261 (Provide structured suggestion to use trait objects in some cases of `if` arm type divergence) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 23, 2024
Rollup of 9 pull requests Successful merges: - rust-lang#112806 (Small code improvements in `collect_intra_doc_links.rs`) - rust-lang#119766 (Split tait and impl trait in assoc items logic) - rust-lang#120139 (Do not normalize closure signature when building `FnOnce` shim) - rust-lang#120160 (Manually implement derived `NonZero` traits.) - rust-lang#120171 (Fix assume and assert in jump threading) - rust-lang#120183 (Add `#[coverage(off)]` to closures introduced by `#[test]` and `#[bench]`) - rust-lang#120195 (add several resolution test cases) - rust-lang#120259 (Split Diagnostics for Uncommon Codepoints: Add List to Display Characters Involved) - rust-lang#120261 (Provide structured suggestion to use trait objects in some cases of `if` arm type divergence) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 24, 2024
Rollup merge of rust-lang#120139 - compiler-errors:fnonce-shim, r=BoxyUwU Do not normalize closure signature when building `FnOnce` shim It is not necessary to normalize the closure signature when building an `FnOnce` shim for an `Fn`/`FnMut` closure. That closure shim is just calling `FnMut::call_mut(&mut self)` anyways. It's also somewhat sketchy that we were ever doing this to begin with, since we're normalizing with a `ParamEnv::reveal_all()` param-env, which is definitely not right with possibly polymorphic substs. This cuts out a tiny bit of unnecessary work in `Instance::resolve` and simplifies the signature because now we can unconditionally return an `Instance`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It is not necessary to normalize the closure signature when building an
FnOnceshim for anFn/FnMutclosure. That closure shim is just callingFnMut::call_mut(&mut self)anyways.It's also somewhat sketchy that we were ever doing this to begin with, since we're normalizing with a
ParamEnv::reveal_all()param-env, which is definitely not right with possibly polymorphic substs.This cuts out a tiny bit of unnecessary work in
Instance::resolveand simplifies the signature because now we can unconditionally return anInstance.