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 suggestion span error with a line containing multibyte characters #40092

Merged
merged 1 commit into from
Mar 11, 2017

Conversation

sinkuu
Copy link
Contributor

@sinkuu sinkuu commented Feb 25, 2017

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion (playground):

fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error

CodeSuggestion::splice_lines is misusing Loc.col (CharPos) as a byte offset when slicing source.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@sinkuu sinkuu changed the title Fix suggestion span error with a line containing non-ASCIIs Fix suggestion span error with a line containing multibyte characters Mar 1, 2017
@pnkfelix
Copy link
Member

pnkfelix commented Mar 9, 2017

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 9, 2017

📌 Commit 8a64cf7 has been approved by pnkfelix

arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 9, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 10, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
alexcrichton pushed a commit to arielb1/rust that referenced this pull request Mar 10, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 10, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 10, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 10, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 10, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Mar 11, 2017
…elix

Fix suggestion span error with a line containing multibyte characters

This PR fixes broken suggestions caused by multibyte characters.

e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)):

```rust
fn main() {
    let tup = (1,);
    println!("☃{}", tup[0]);
}
```

```
error: cannot index a value of type `({integer},)`
 --> <anon>:3:21
  |
3 |     println!("☃{}", tup[0]);
  |                     ^^^^^^
  |
help: to access tuple elements, use tuple indexing syntax as shown
  |     println!("☃{}"tup.00]);

error: aborting due to previous error
```

`CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
@bors bors merged commit 8a64cf7 into rust-lang:master Mar 11, 2017
@sinkuu sinkuu deleted the fix_suggestion_index branch March 11, 2017 10:29
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

Successfully merging this pull request may close these issues.

4 participants