-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Beta regression in span printing with tabs involved #47377
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Interesting. Im new to code work so following you guys has been extremely
helpful thanks
…On Jan 12, 2018 4:44 AM, "est31" ***@***.***> wrote:
This code (containing tabs) gives an error (playground
<https://play.rust-lang.org/?gist=7fbea34512455179a57ca244b297ba26&version=nightly>
):
let b = "hello";
let _a = b + ", World!";
The error works fine on stable:
|
3 | let _a = b + ", World!";
| ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
|
3 | let _a = b.to_owned() + ", World!";
| ^^^^^^^^^^^^
But is mispositioned on rustc 1.25.0-nightly (73ac5d6
<73ac5d6>
2018-01-11) as well as on rustc 1.24.0-beta.2 (a19122c
<a19122c>
2018-01-10):
|
3 | let _a = b + ", World!";
| ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
|
3 | let _a = b.to_owned() + ", World!";
| ^^^^^^^^^^^^
cc @estebank <https://github.com/estebank>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#47377>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AhXLZpW96E-kEteWrOLXG8iE-oM4vZhDks5tJylzgaJpZM4RcCkz>
.
|
Yeah, the issue also exists when emojis are involved (no tabs): let b = "hello";
println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; Gives:
The emoji manifestation of the issue is no beta regression, seems to exist on stable as well. |
I've created #47380 for the emoji/unicode issue. |
It seems to me that the issue only manifests itself in suggestions, and that is handled separately from the main diagnostics. Mentoring instructions:
|
Will pick this up |
fix mispositioned span This fixes rust-lang#47377 The output now looks like this ``` error[E0369]: binary operation `+` cannot be applied to type `&str` --> h.rs:3:11 | 3 | let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | 3 | let _a = b.to_owned() + ", World!"; | ^^^^^^^^^ error: aborting due to previous error ``` For the case when emojis are involved, it gives the new output for proper indentation. But for an indentation as follows, ``` fn main() { let b = "hello"; let _a = b + ", World!"; } ``` it still mispositions the span ``` 3 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings | 3 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; | ^^^^^^^ error: aborting due to previous erro ``` cc @estebank @est31
fix mispositioned span This fixes rust-lang#47377 The output now looks like this ``` error[E0369]: binary operation `+` cannot be applied to type `&str` --> h.rs:3:11 | 3 | let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | 3 | let _a = b.to_owned() + ", World!"; | ^^^^^^^^^ error: aborting due to previous error ``` For the case when emojis are involved, it gives the new output for proper indentation. But for an indentation as follows, ``` fn main() { let b = "hello"; let _a = b + ", World!"; } ``` it still mispositions the span ``` 3 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings | 3 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; | ^^^^^^^ error: aborting due to previous erro ``` cc @estebank @est31
This code (containing tabs) gives an error (playground):
The error works fine on stable:
But is mispositioned on rustc 1.25.0-nightly (73ac5d6 2018-01-11) as well as on rustc 1.24.0-beta.2 (a19122c 2018-01-10):
cc @estebank
The text was updated successfully, but these errors were encountered: