Expose Span for all DefIds in rustc_public#152912
Expose Span for all DefIds in rustc_public#152912rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
|
r? @scottmcm rustbot has assigned @scottmcm. Use Why was this reviewer chosen?The reviewer was selected based on:
|
fdce1f8 to
1ded3a6
Compare
| impl<'tcx> Stable<'tcx> for rustc_span::def_id::DefId { | ||
| type T = crate::DefId; | ||
|
|
||
| fn stable<'cx>( | ||
| &self, | ||
| tables: &mut Tables<'cx, BridgeTys>, | ||
| _: &CompilerCtxt<'cx, BridgeTys>, | ||
| ) -> Self::T { | ||
| tables.create_def_id(*self) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I believe we don't really need this impl. We can just use create_def_id everywhere.
There was a problem hiding this comment.
create_def_id is not publicly available. This impl enables rustc_public::rustc_internal::stable for creating DefId for variants, which is not possible using current rustc_public api. Is there any downside for having this impl?
There was a problem hiding this comment.
The Stable trait is also not publicly available and shouldn't be exposed to users, so adding this impl here doesn't make sense for getting the DefId of a variant. I think we probably could add an api to the CompilerInterface for retrieving the DefId of a VariantDef given that we have the Internal trait implemented for VariantDef, then we don't have to store a def_id in that struct.
There was a problem hiding this comment.
The rustc_public::unstable::Stable trait is not public, but the rustc_public::rustc_internal::stable function is public for users who mix rustc_public with unstable rustc apis (like me).
Adding an api for retrieving DefId from a variant is needed for the completeness of rustc_public, but even with that, I think this impl is useful for the stable function users.
|
r? me |
…uwer Rollup of 9 pull requests Successful merges: - #146832 (Not linting irrefutable_let_patterns on let chains) - #146972 (Support importing path-segment keyword with renaming) - #152241 (For panic=unwind on Wasm targets, define __cpp_exception tag) - #152527 (Remove -Zemit-thin-lto flag) - #152769 (Do not cancel try builds after first job failure) - #152907 (Add tests for delegation generics) - #152455 (Remove the translation `-Z` options and the `Translator` type. ) - #152813 (Skip the `use_existential_projection_new_instead` field in the `Debug` impl) - #152912 (Expose Span for all DefIds in rustc_public)
Rollup merge of #152912 - HKalbasi:rustc_public_def_span, r=makai410 Expose Span for all DefIds in rustc_public Part of rust-lang/project-stable-mir#118 To be maximally useful, `VariantDef` and `FieldDef` should be changed to be a wrapper around `DefId` instead of holding their parent and index. I can do this change in this PR or a follow-up if it is desired. For now, I added the missing `impl Stable for DefId` in internals so you can convert from rustc internals.
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#146832 (Not linting irrefutable_let_patterns on let chains) - rust-lang/rust#146972 (Support importing path-segment keyword with renaming) - rust-lang/rust#152241 (For panic=unwind on Wasm targets, define __cpp_exception tag) - rust-lang/rust#152527 (Remove -Zemit-thin-lto flag) - rust-lang/rust#152769 (Do not cancel try builds after first job failure) - rust-lang/rust#152907 (Add tests for delegation generics) - rust-lang/rust#152455 (Remove the translation `-Z` options and the `Translator` type. ) - rust-lang/rust#152813 (Skip the `use_existential_projection_new_instead` field in the `Debug` impl) - rust-lang/rust#152912 (Expose Span for all DefIds in rustc_public)
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#146832 (Not linting irrefutable_let_patterns on let chains) - rust-lang/rust#146972 (Support importing path-segment keyword with renaming) - rust-lang/rust#152241 (For panic=unwind on Wasm targets, define __cpp_exception tag) - rust-lang/rust#152527 (Remove -Zemit-thin-lto flag) - rust-lang/rust#152769 (Do not cancel try builds after first job failure) - rust-lang/rust#152907 (Add tests for delegation generics) - rust-lang/rust#152455 (Remove the translation `-Z` options and the `Translator` type. ) - rust-lang/rust#152813 (Skip the `use_existential_projection_new_instead` field in the `Debug` impl) - rust-lang/rust#152912 (Expose Span for all DefIds in rustc_public)
Part of rust-lang/project-stable-mir#118
To be maximally useful,
VariantDefandFieldDefshould be changed to be a wrapper aroundDefIdinstead of holding their parent and index. I can do this change in this PR or a follow-up if it is desired. For now, I added the missingimpl Stable for DefIdin internals so you can convert from rustc internals.