-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 the lifetime parameters of tcx consistent. #58926
Merged
Merged
Conversation
This file contains 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
(rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Mar 5, 2019
@bors r+ rollup |
📌 Commit cd9a0cf has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Mar 5, 2019
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this pull request
Mar 8, 2019
Make the lifetime parameters of tcx consistent. I have implemented `codegen_allocator` for my backend, but I've had to make a small change to its signature in `ExtraBackendMethods`. I wonder if this change is justified, or if it is too specific to my use case to be useful to anyone else. `write_metadata` and `codegen_allocator` are both called from `codegen_crate` (in `librustc_codegen_ssa/base.rs`), and they both receive the same `tcx` as an argument: https://github.com/rust-lang/rust/blob/c196097e588b05e86b5ce6de992b2a6e6a7027bd/src/librustc_codegen_ssa/base.rs#L555-L557 and: https://github.com/rust-lang/rust/blob/c196097e588b05e86b5ce6de992b2a6e6a7027bd/src/librustc_codegen_ssa/base.rs#L640-L642 However, `codegen_allocator` accepts a `TyCtxt` with any lifetime parameters (`tcx: TyCtxt<'_, '_, '_>`), while `write_metadata` requires that the `tcx` argument is of type `TyCtxt<'b, 'gcx, 'gcx>`. In my implementation, I've found that it's necessary for `tcx` in `codegen_allocator` to also have the `<'b, 'gcx, 'gcx>` lifetime parameters. Have I misunderstood the purpose of the parameters of `TyCtxt`? I've read [here](https://rust-lang.github.io/rustc-guide/ty.html) that the last two parameters only need to be distinct if the function needs to be used during type inference, but I don't think that is the case here.
bors
added a commit
that referenced
this pull request
Mar 9, 2019
Rollup of 24 pull requests Successful merges: - #58080 (Add FreeBSD armv6 and armv7 targets) - #58204 (On return type `impl Trait` for block with no expr point at last semi) - #58269 (Add librustc and libsyntax to rust-src distribution.) - #58369 (Make the Entry API of HashMap<K, V> Sync and Send) - #58861 (Expand where negative supertrait specific error is shown) - #58877 (Suggest removal of `&` when borrowing macro and appropriate) - #58883 (Suggest appropriate code for unused field when destructuring pattern) - #58891 (Remove stray ` in the docs for the FromIterator implementation for Option) - #58893 (race condition in thread local storage example) - #58906 (Monomorphize generator field types for debuginfo) - #58911 (Regression test for #58435.) - #58912 (Regression test for #58813) - #58916 (Fix release note problems noticed after merging.) - #58918 (Regression test added for an async ICE.) - #58921 (Add an explicit test for issue #50582) - #58926 (Make the lifetime parameters of tcx consistent.) - #58931 (Elide invalid method receiver error when it contains TyErr) - #58940 (Remove JSBackend from config.toml) - #58950 (Add self to mailmap) - #58961 (On incorrect cfg literal/identifier, point at the right span) - #58963 (libstd: implement Error::source for io::Error) - #58970 (delay_span_bug in wfcheck's ty.lift_to_tcx unwrap) - #58984 (Teach `-Z treat-err-as-bug` to take a number of errors to emit) - #59007 (Add a test for invalid const arguments) Failed merges: - #58959 (Add release notes for PR #56243) r? @ghost
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
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.
I have implemented
codegen_allocator
for my backend, but I've had to make a small change to its signature inExtraBackendMethods
. I wonder if this change is justified, or if it is too specific to my use case to be useful to anyone else.write_metadata
andcodegen_allocator
are both called fromcodegen_crate
(inlibrustc_codegen_ssa/base.rs
), and they both receive the sametcx
as an argument:rust/src/librustc_codegen_ssa/base.rs
Lines 555 to 557 in c196097
and:
rust/src/librustc_codegen_ssa/base.rs
Lines 640 to 642 in c196097
However,
codegen_allocator
accepts aTyCtxt
with any lifetime parameters (tcx: TyCtxt<'_, '_, '_>
), whilewrite_metadata
requires that thetcx
argument is of typeTyCtxt<'b, 'gcx, 'gcx>
. In my implementation, I've found that it's necessary fortcx
incodegen_allocator
to also have the<'b, 'gcx, 'gcx>
lifetime parameters.Have I misunderstood the purpose of the parameters of
TyCtxt
? I've read here that the last two parameters only need to be distinct if the function needs to be used during type inference, but I don't think that is the case here.