Skip to content

Commit 7dec8a4

Browse files
committed
Fix test
1 parent 6437295 commit 7dec8a4

5 files changed

+15
-11
lines changed

src/libsyntax/parse/lexer/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,12 @@ impl<'a> StringReader<'a> {
10811081
);
10821082
if let Some(ch) = self.ch {
10831083
// check for e.g. Unicode minus '−' (Issue #49746)
1084-
unicode_chars::check_for_substitution(self, ch, &mut err);
1084+
if unicode_chars::check_for_substitution(self, ch, &mut err) {
1085+
self.bump();
1086+
self.scan_digits(10, 10);
1087+
}
10851088
}
10861089
err.emit();
1087-
FatalError.raise();
10881090
}
10891091
}
10901092
}

src/libsyntax/parse/lexer/unicode_chars.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ const ASCII_ARRAY: &'static [(char, &'static str)] = &[
335335

336336
pub fn check_for_substitution<'a>(reader: &StringReader<'a>,
337337
ch: char,
338-
err: &mut DiagnosticBuilder<'a>) {
338+
err: &mut DiagnosticBuilder<'a>) -> bool {
339339
UNICODE_ARRAY
340340
.iter()
341341
.find(|&&(c, _, _)| c == ch)
@@ -347,11 +347,13 @@ pub fn check_for_substitution<'a>(reader: &StringReader<'a>,
347347
format!("Unicode character '{}' ({}) looks like '{}' ({}), but it is not",
348348
ch, u_name, ascii_char, ascii_name);
349349
err.span_suggestion(span, &msg, ascii_char.to_string());
350+
true
350351
},
351352
None => {
352353
let msg = format!("substitution character not found for '{}'", ch);
353354
reader.sess.span_diagnostic.span_bug_no_panic(span, &msg);
355+
false
354356
}
355357
}
356-
});
358+
}).unwrap_or(false)
357359
}

src/test/parse-fail/unicode-chars.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
fn main() {
1414
let y = 0;
1515
//~^ ERROR unknown start of token: \u{37e}
16-
//~^^ HELP unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it's not
16+
//~^^ HELP Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not
1717
}

src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
const UNIVERSAL_GRAVITATIONAL_CONSTANT = 6.674e−11; // m³⋅kg⁻¹⋅s⁻²
11+
const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹⋅s⁻²
1212
//~^ ERROR expected at least one digit in exponent
1313

1414
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: expected at least one digit in exponent
2-
--> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:11:48
2+
--> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:11:53
33
|
4-
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT = 6.674e−11; // m³⋅kg⁻¹⋅s⁻²
5-
| ^
4+
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹⋅s⁻²
5+
| ^
66
help: Unicode character '−' (Minus Sign) looks like '-' (Minus/Hyphen), but it is not
77
|
8-
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT = 6.674e-11; // m³⋅kg⁻¹⋅s⁻²
9-
| ^
8+
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kg⁻¹⋅s⁻²
9+
| ^
1010

1111
error: aborting due to previous error
1212

0 commit comments

Comments
 (0)