-
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
save-analysis: Pull associated type definition using qpath_def
#59894
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
r? @eddyb |
@@ -379,7 +379,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) | |||
} | |||
} | |||
|
|||
/// A quasi-deprecated helper used in rustdoc and save-analysis to get | |||
/// A quasi-deprecated helper used in rustdoc and clippy to get |
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.
cc @oli-obk @Manishearth We should maybe have an issue for getting clippy off of this.
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.
cc @flip1995 in case this is on your list of clippy utilities
@bors r+ |
📌 Commit bcd263e has been approved by |
save-analysis: Pull associated type definition using `qpath_def` Closes rust-lang/rls#1390 This (probably?) fixes the case where we run the save-analysis code on the following snippet: ```rust trait Test<'a> { type Thing: Test2; } trait Test2 { fn print(); } #[allow(unused)] fn example<T>(t: T) where T: for<'a> Test<'a> { T::Thing::print(); //~ ERROR cannot extract an associated type from a higher-ranked trait bound in this context // ^ only errors in save-analysis mode } ``` The chain is as follows: - culprit is `hir_ty_to_ty` - which calls `ast_ty_to_ty` in the `ItemCtxt` - which calls `associated_path_to_ty` - which finally fails on `projected_ty_from_poly_trait_ref` https://github.com/rust-lang/rust/blob/3de0106789468b211bcc3a25c09c0cf07119186d/src/librustc_typeck/collect.rs#L212-L224 I'm not exactly sure why `hir_ty_to_ty` fails - is it because it needs more setup from typeck to work correctly? I'm guessing the fix is okay since we just pull the already typeck'd data (we run save-analysis after all the analysis passes are complete) from the tables. With this change we can 'go to def' on all segments in the `T::Thing::print()` path.
Rollup of 15 pull requests Successful merges: - #59680 (Document the -Z flag to the rustc book) - #59711 (Add back the substring test) - #59806 (compiletest: Improve no_prefer_dynamic docs) - #59809 (Make trait_methods_not_found use a lock) - #59811 (Kill dead code dominator code.) - #59814 (Fix broken links on std::boxed doc page) - #59821 (improve unknown enum variant errors) - #59831 (Remove strange formatting in `Ordering` docs.) - #59836 (std::ops::Div examples: correct nominator to numerator) - #59857 (SGX target: fix cfg(test) build) - #59876 (Update TRPL to use mdbook 0.2) - #59880 (Remove note about transmute for float bitpatterns.) - #59889 (Update diagnostics.rs) - #59891 (Fix the link to sort_by_cached_key) - #59894 (save-analysis: Pull associated type definition using `qpath_def`) Failed merges: r? @ghost
FWIW, this fix for rust-lang/rls#1390 was requested on reddit: |
@pietroalbini @rust-lang/release should this be backported? |
@Xanewok only when/if it gets beta-accepted by the compiler team. |
I imagined this decision has always been made primarily by release/infra teams, just wanted to bring this to their attention since the backport window will close soon. Let's try with another team: @rust-lang/compiler should this be backported? This fixes save-analysis compilation for gstreamer (and also for its reverse deps). It was requested in rust-lang/rls#1390 (comment) and also on reddit, as @cuviper pointed out. |
Decisions for beta backports are made by the team responsible for the area of the codebase affected by the changes (most of the time compiler, sometimes libs or rustdoc), and the release team doesn't have a say on what gets backported. For stable backports the process for beta still applies, and in addition to that the release team has to approve the point release as a whole. |
discussed at T-compiler meeting. approved for beta-backport. |
Closes rust-lang/rls#1390
This (probably?) fixes the case where we run the save-analysis code on the following snippet:
The chain is as follows:
hir_ty_to_ty
ast_ty_to_ty
in theItemCtxt
associated_path_to_ty
projected_ty_from_poly_trait_ref
rust/src/librustc_typeck/collect.rs
Lines 212 to 224 in 3de0106
I'm not exactly sure why
hir_ty_to_ty
fails - is it because it needs more setup from typeck to work correctly? I'm guessing the fix is okay since we just pull the already typeck'd data (we run save-analysis after all the analysis passes are complete) from the tables.With this change we can 'go to def' on all segments in the
T::Thing::print()
path.