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

Spans for errors in try operator expressions are not great #42234

Closed
nrc opened this issue May 26, 2017 · 3 comments · Fixed by #48028
Closed

Spans for errors in try operator expressions are not great #42234

nrc opened this issue May 26, 2017 · 3 comments · Fixed by #48028
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-HIR Area: The high-level intermediate representation (HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nrc
Copy link
Member

nrc commented May 26, 2017

E.g.,

error: the type of this value must be known in this context
   --> src/librustc_save_analysis/sig.rs:281:39
    |
281 |             let generics: Signature = generics.make(offset + text.len(), id, scx)?;
    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

the expression with unknown type is the variable use generics, but the error highlight covers the entire sub-expression of expr?. I assume this is due to us doing something sub-optimal with the spans here in the HIR lowering.

@nrc nrc added A-diagnostics Area: Messages for errors, warnings, and lints A-HIR Area: The high-level intermediate representation (HIR) labels May 26, 2017
@aturon aturon added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 7, 2017
@aturon
Copy link
Member

aturon commented Jun 7, 2017

@nrc is worried that similar issues are arising with other desugarings, i.e. that this might be an across-the-board regression. Worth investigating.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jun 8, 2017

Standalone example:

fn foo() -> Result<(), ()> {
    let x = None;
    Ok(x.unwrap().make()?)
}

fn main() { }

gives

rustc 1.17.0 (56124baa9 2017-04-24)
error: the type of this value must be known in this context
 --> <anon>:3:8
  |
3 |     Ok(x.unwrap().make()?)
  |        ^^^^^^^^^^^^^^^^^

error: aborting due to previous error

@nikomatsakis
Copy link
Contributor

triage: P-medium

Doesn't seem like a "stop everything" sort of problem, but would be good to figure it out. However, it does not appear to be a regression: e.g., the above test case behaves the same in 1.16.0 as well.

@rust-highfive rust-highfive added P-medium Medium priority and removed I-nominated labels Jun 8, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
zackmdavis added a commit to zackmdavis/rust that referenced this issue Feb 6, 2018
Previously, when the type of a method receiver could not be determined,
the error message would, potentially confusingly, highlight the span of
the entire method call.

Resolves rust-lang#36598, resolves rust-lang#42234.
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 7, 2018
…own_type, r=estebank

correct E0619 span re method call receivers whose type must be known

Previously, when the type of a method receiver could not be determined,
the error message would, potentially confusingly, highlight the span of
the entire method call.

![unknown_receiver_type](https://user-images.githubusercontent.com/1076988/35838930-a595b17c-0aa2-11e8-9364-6b8e2329f051.png)

Resolves rust-lang#36598, resolves rust-lang#42234.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-HIR Area: The high-level intermediate representation (HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants