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

fix emit_inference_failure_err ICE #98610

Merged
merged 3 commits into from
Jul 1, 2022

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jun 28, 2022

fixes #98598

this fix doesn't make me too happy, but 🤷

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

Some changes occured in need_type_info.rs

cc @lcnr

@rust-highfive
Copy link
Collaborator

r? @compiler-errors

(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 28, 2022
Comment on lines +1 to +5
error[E0282]: type annotations needed
--> $DIR/expr-struct-type-relative-gat.rs:17:9
|
LL | Self::Output::Simple {};
| ^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated type `Output`
Copy link
Contributor

Choose a reason for hiding this comment

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

We should point at Output as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what exactly do you mean with this? This should suggest Self::Output::<T> but that's part of the FIXME i've added

Copy link
Contributor

@estebank estebank Jul 1, 2022

Choose a reason for hiding this comment

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

I meant something like

error[E0282]: type annotations needed
  --> $DIR/expr-struct-type-relative-gat.rs:17:9
   |
LL |     type Output<T> = Bar<T>;
   |                 - type parameter `T` that couldn't be infered on `Output`
LL |     fn baz() {
LL |         Self::Output::Simple {};
   |         ^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated type `Output`

as a stop gap solution, but ideally all of this would look like this

error[E0282]: type annotations needed
  --> $DIR/expr-struct-type-relative-gat.rs:17:9
   |
LL |     type Output<T> = Bar<T>;
   |                 - type parameter `T` that couldn't be infered on `Output`
LL |     fn baz() {
LL |         Self::Output::Simple {};
   |         ^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated type `Output`
help: specify the type parameter on associated type `Output` 
   |
LL |         Self::Output::<T>::Simple {};
   |                     +++++

Edit: although thinking about it for a second, maybe we should suggest other forms, like adding a param to baz and passing that through, I'm not sure about how GATs will actually be used in the wild to get a sense of what the appropriate suggestion might actually be.

Comment on lines 738 to 748
// FIXME: Ideally we would also deal with type relative
// paths here, even if that is quite rare.
//
// See the `need_type_info/expr-struct-type-relative-gat.rs` test
// for an example where that would be needed.
//
// However, the `type_dependent_def_id` for `Self::Output` in an
// impl is currently the `DefId` of `Output` in the trait definition
// which makes this somewhat difficult and prevents us from just
// using `self.path_inferred_subst_iter` here.
hir::ExprKind::Struct(&hir::QPath::Resolved(_self_ty, path), _, _) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we leave the ticket open so that the DefId of Self::Output corresponds to the impl assoc type and not the trait assoc type? That seems to be the correct fix, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opened #98711

if let Some(ty) = self.opt_node_type(expr.hir_id) {
if let ty::Adt(_, substs) = ty.kind() {
return self.path_inferred_subst_iter(expr.hir_id, substs, path);
return Box::new(self.resolved_path_inferred_subst_iter(path, substs));
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the filtering above, this change isn't also needed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it isn't strictly needed, but it feels weird to call path_inferred_subst_iter if we already know that we're only dealing with resolved paths.

@compiler-errors
Copy link
Member

r? @estebank

@estebank
Copy link
Contributor

estebank commented Jul 1, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 1, 2022

📌 Commit e043821 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 Jul 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 1, 2022
…askrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#98610 (fix `emit_inference_failure_err` ICE)
 - rust-lang#98640 (Let rust-analyzer ship on stable, non-preview)
 - rust-lang#98686 (add ice test for 46511)
 - rust-lang#98727 (rustdoc: filter '_ lifetimes from ty::PolyTraitRef)
 - rust-lang#98729 (clarify that ExactSizeIterator::len returns the remaining length)
 - rust-lang#98733 (Request to be notified of MIR changes)
 - rust-lang#98734 (Update RELEASES.md)
 - rust-lang#98745 (Add a `--build-dir` flag to rustbuild)
 - rust-lang#98749 (Add macro_rules! rustdoc change to 1.62 relnotes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0d5636c into rust-lang:master Jul 1, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 1, 2022
@lcnr lcnr deleted the emit_inference_failure_err-ice branch July 1, 2022 11:21
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
Development

Successfully merging this pull request may close these issues.

range start index 1 out of range for slice of length 0
6 participants