Skip to content
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

some additional need_type_info.rs cleanup #97703

Merged
merged 5 commits into from
Jun 11, 2022
Merged

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jun 3, 2022

also fixes #97698, fixes #97806

cc @estebank

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 3, 2022
@rust-highfive
Copy link
Collaborator

Some changes occured in need_type_info.rs

cc @lcnr

@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 3, 2022
Comment on lines +858 to +865
Res::Def(DefKind::TyAlias, _) => {
// FIXME: Ideally we should support this. For that
// we have to map back from the self type to the
// type alias though. That's difficult.
//
// See the `need_type_info/type-alias.rs` test for
// some examples.
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oli-obk you might want to chime in here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GuillaumeGomez is working on it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving slowly but surely! (you can take a look at my work in progress there: https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:rustc-middle-ty-alias?expand=1)

Comment on lines +866 to +869
_ => warn!(
"unexpected path: def={:?} substs={:?} path={:?}",
def, substs, path,
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is turning this into a warn instead of bug intended?

Copy link
Contributor Author

@lcnr lcnr Jun 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, don't want to ICE here and getting it wrong only worsens diagnostics.

feels safer than using a bug!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using delay_span_bug instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delay_span_bug won't ever trigger, considering that we're always emitting an error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does protect against a subsequent refactor making us hit this codepath without an error being emitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the FindInferSourceVisitor should not be relevant to whether we emit an error. I do not think this is an issue. Or at least I think the guard for that shouldn't be at this point. We currently guard against it by fn emit_inference_failure_err returning a DiagnosticBuilder<'tcx, ErrorGuaranteed>.

Comment on lines 231 to 235
/// Returns the substs corresponding to the generic parameters
/// of this item, excluding `Self`.
pub fn own_substs_no_defaults(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it clear in the naming and docs that this is only meant for use in diagnostics code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment, don't want to make these method names even more unwieldy 😅

@wesleywiser
Copy link
Member

r? @estebank

lcnr added 4 commits June 8, 2022 10:11
it feels arbitrary to have `Ty` and `Const` directly
in that module and to not have `GenericArg` and
`GenericArgKind` there. Writing `ty::GenericArg`
can also feel clearer than importing it. Using
`ty::subst::GenericArg` however is ugly.
})
.count();
let generic_args =
&generics.own_substs(substs)[generics.own_counts().lifetimes..][..num_args];
Copy link
Contributor Author

@lcnr lcnr Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that caused the ICE in #97698 (comment). Writing big PRs sure is difficult 😅

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 10, 2022

📌 Commit d6b28f3 has been approved by estebank

@bors 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 Jun 10, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 11, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#96868 (Stabilize explicit_generic_args_with_impl_trait)
 - rust-lang#97703 (some additional `need_type_info.rs` cleanup)
 - rust-lang#97812 (Suggest to swap a struct and a trait in trait impls)
 - rust-lang#97958 (ExitStatus docs fixups)
 - rust-lang#97967 (Mention `infer::Trace` methods on `infer::At` methods' docs)
 - rust-lang#97972 (Update #[doc(html_playground_url)] documentation to mention what the request will be)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 59c2ff5 into rust-lang:master Jun 11, 2022
@rustbot rustbot added this to the 1.63.0 milestone Jun 11, 2022
@lcnr lcnr deleted the post-89862 branch June 11, 2022 15:00
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants