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

Mis-calculated spans #43796

Closed
aidanhs opened this issue Aug 10, 2017 · 2 comments
Closed

Mis-calculated spans #43796

aidanhs opened this issue Aug 10, 2017 · 2 comments
Labels
A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Comments

@aidanhs
Copy link
Member

aidanhs commented Aug 10, 2017

[00:33:43] ERROR:rustc_save_analysis::dump_visitor: Mis-calculated spans for path 'AsRef<U>::as_ref'. Found 1 spans, expected 2. Found spans:
[00:33:43] ERROR:rustc_save_analysis::dump_visitor:     'as_ref' in /checkout/src/libcore/convert.rs, line 355

This has been seen in a few different places, e.g.

I don't think it actually causes build failures, but it seems suspicious and something that should be fixed. I'll use logobble to dig up some more tomorrowish.

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. A-rls A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. and removed A-rls labels Aug 11, 2017
@Mark-Simulacrum
Copy link
Member

cc @nrc -- any ideas on what could be causing this?

@kennytm
Copy link
Member

kennytm commented Aug 12, 2017

The problem is that SpanUtils::spans_with_brackets (called from spans_for_path_segments) does not handle UFCS path at all. It will ignore everything between angle brackets, so input like <T as AsRef<U>>::as_ref will only produce the span for as_ref (one segment).

However, the ast::Path of this will be AsRef<U>::as_ref (two segments), thus the mismatch error.

Thanks to #40369, each PathSegment already contain the span, so we shouldn't need to use spans_for_path_segments anymore.

kennytm added a commit to kennytm/rust that referenced this issue Aug 14, 2017
Use the `span` field in PathSegment and TyParam instead.

Fix rust-lang#43796. Close rust-lang#41478.
bors added a commit that referenced this issue Aug 14, 2017
…ochenkov

Fix "Mis-calculated spans" errors from `-Z save-analysis` + refactoring

Removed the path span extraction methods from `SpanUtils`:

* spans_with_brackets
* spans_for_path_segments
* spans_for_ty_params

Use the `span` fields in `PathSegment` and `TyParam` instead.

(Note that since it processes `ast::Path` not a qualified path (`hir::QPath` / `ast::QSelf`), UFCS path will be flattened: `<Foo as a::b::c::Trait>::D::E::F::g` will be seen as `a::b::c::Trait::D::E::F::g`.)

Fix #43796. Close #41478.

r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants