Skip to content

Commit 669d477

Browse files
committed
Auto merge of #44081 - est31:master, r=eddyb
Fix a byte/char confusion issue in the error emitter Fixes #44078. Fixes #44023. The start_col member is given in chars, while the code previously assumed it was given in bytes. The more basic issue #44080 doesn't get fixed.
2 parents e7070dd + 5a71e12 commit 669d477

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

src/librustc_errors/emitter.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ impl EmitterWriter {
311311
if line.annotations.len() == 1 {
312312
if let Some(ref ann) = line.annotations.get(0) {
313313
if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
314-
if source_string[0..ann.start_col].trim() == "" {
314+
if source_string.chars()
315+
.take(ann.start_col)
316+
.all(|c| c.is_whitespace()) {
315317
let style = if ann.is_primary {
316318
Style::UnderlinePrimary
317319
} else {

src/test/ui/issue-44023.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
#![feature(non_ascii_idents)]
12+
13+
pub fn main () {}
14+
15+
fn საჭმელად_გემრიელი_სადილი ( ) -> isize {
16+
}

src/test/ui/issue-44023.stderr

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-44023.rs:15:42
3+
|
4+
15 | fn საჭმელად_გემრიელი_სადილი ( ) -> isize {
5+
| __________________________________________^
6+
16 | | }
7+
| |_^ expected isize, found ()
8+
|
9+
= note: expected type `isize`
10+
found type `()`
11+
12+
error: aborting due to previous error
13+

src/test/ui/issue-44078.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
"😊"";
13+
}

src/test/ui/issue-44078.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: unterminated double quote string
2+
--> $DIR/issue-44078.rs:12:8
3+
|
4+
12 | "😊"";
5+
| ________^
6+
13 | | }
7+
| |__^
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)