Skip to content

Commit 3c8c505

Browse files
committed
add ui test
1 parent eb1ada2 commit 3c8c505

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

src/librustc_errors/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ impl EmitterWriter {
11881188
acc + unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0)
11891189
});
11901190
let underline_start = span_start_pos.col_display + start;
1191-
let underline_end = span_start_pos.col.0 + start + sub_len;
1191+
let underline_end = span_start_pos.col_display + start + sub_len;
11921192
for p in underline_start..underline_end {
11931193
buffer.putc(row_num,
11941194
max_line_num_len + 3 + p,

src/test/ui/issue-47377-1.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main(){
12+
let b = "hello";
13+
println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369]
14+
}

src/test/ui/issue-47377-1.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0369]: binary operation `+` cannot be applied to type `&str`
2+
--> $DIR/issue-47377-1.rs:13:37
3+
|
4+
13 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369]
5+
| ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
6+
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
7+
|
8+
13 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369]
9+
| ^^^^^^^^^^^^
10+
11+
error: aborting due to previous error
12+

src/test/ui/issue-47377.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main(){
12+
let b = "hello";
13+
let _a = b + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369]
14+
}

src/test/ui/issue-47377.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0369]: binary operation `+` cannot be applied to type `&str`
2+
--> $DIR/issue-47377.rs:13:14
3+
|
4+
13 | let _a = b + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369]
5+
| ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
6+
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
7+
|
8+
13 | let _a = b.to_owned() + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369]
9+
| ^^^^^^^^^^^^
10+
11+
error: aborting due to previous error
12+

0 commit comments

Comments
 (0)