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

unresolved import span is wrong #33464

Closed
oli-obk opened this issue May 6, 2016 · 0 comments
Closed

unresolved import span is wrong #33464

oli-obk opened this issue May 6, 2016 · 0 comments

Comments

@oli-obk
Copy link
Contributor

oli-obk commented May 6, 2016

an arbitrary import of the shape

use abc::{a, bbbbbbbbbbb, cccccccc};

will give the following errors and spans:

<anon>:1:11: 1:14 error: unresolved import `abc::a`. Maybe a missing `extern crate abc`? [E0432]
<anon>:1 use abc::{a, bbbbbbbbbbb, cccccccc};
                   ^~~
<anon>:1:11: 1:14 help: see the detailed explanation for E0432
<anon>:1:14: 1:17 error: unresolved import `abc::bbbbbbbbbbb`. Maybe a missing `extern crate abc`? [E0432]
<anon>:1 use abc::{a, bbbbbbbbbbb, cccccccc};
                      ^~~
<anon>:1:14: 1:17 help: see the detailed explanation for E0432
<anon>:1:27: 1:30 error: unresolved import `abc::cccccccc`. Maybe a missing `extern crate abc`? [E0432]
<anon>:1 use abc::{a, bbbbbbbbbbb, cccccccc};
                                   ^~~

The span is always as long as the crate, but starts at the imported element

This can also be used to create an unprintable span:

http://is.gd/83hpg7

birkenfeld added a commit to birkenfeld/rust that referenced this issue May 10, 2016
This span modification is probably leftover from a time when
import spans were assigned differently.

With this change, error spans for the following are properly reported:

```
use abc::one_el;
use abc::{a, bbb, cccccc};
use a_very_long_name::{el, el2};
```

before (spans only):
```
x.rs:3 use abc::one_el;
           ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~
(internal compiler error: unprintable span)
(internal compiler error: unprintable span)
```

after:
```
x.rs:3 use abc::one_el;
           ^~~~~~~~~~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~~~~
x.rs:5 use a_very_long_name::{el, el2};
                              ^~
x.rs:5 use a_very_long_name::{el, el2};
                                  ^~~
```

Fixes: rust-lang#33464
bors added a commit that referenced this issue May 10, 2016
resolve: do not modify span of non-importable name

This span modification is probably leftover from a time when import spans were assigned differently.

With this change, error spans for the following are properly reported:

```
use abc::one_el;
use abc::{a, bbb, cccccc};
use a_very_long_name::{el, el2};
```

before (spans only):
```
x.rs:3 use abc::one_el;
           ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~
(internal compiler error: unprintable span)
(internal compiler error: unprintable span)
```

after:
```
x.rs:3 use abc::one_el;
           ^~~~~~~~~~~
x.rs:4 use abc::{a, bbb, cccccc};
                 ^
x.rs:4 use abc::{a, bbb, cccccc};
                    ^~~
x.rs:4 use abc::{a, bbb, cccccc};
                         ^~~~~~
x.rs:5 use a_very_long_name::{el, el2};
                              ^~
x.rs:5 use a_very_long_name::{el, el2};
                                  ^~~
```

Fixes: #33464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant