Change:
This code: () Looks pretty identical to this code: But the first one doesn't compile because I accidentally used a unicode minus sign (−) instead of a dash (-). This happened to me when I pasted a constant from Wikipedia. We already produce an error about things like this in other cases. For example with an en space: We produce the following: Maybe we could do the same for the minus sign since it is a pretty confusing error to receive?
The unicode minus sign is already on the list of similar characters: However it looks like it doesn't work in this context.

Discussion:
self.bump(); } if self.scan_digits(10, 10) == 0 { <del> self.err_span_(self.pos, self.next_pos, "expected at least one digit in exponent") </del> <ins> let mut err = self.struct_span_fatal( self.pos, self.next_pos, "expected at least one digit in exponent" ); if let Some(ch) = self.ch { // check for e.g. Unicode minus '−' (Issue #49746) if unicode_chars::check_for_substitution(self, ch, &mut err) { self.bump(); self.scan_digits(10, 10); } } err.emit(); </ins> } } }

pub fn check_for_substitution<'a>(reader: &StringReader<'a>, ch: char, <del> err: &mut DiagnosticBuilder<'a>) { </del> <ins> err: &mut DiagnosticBuilder<'a>) -> bool { </ins> UNICODE_ARRAY .iter() .find(|&&(c, _, _)| c == ch)

match ASCII_ARRAY.iter().find(|&&(c, _)| c == ascii_char) { Some(&(ascii_char, ascii_name)) => { let msg = <del> format!("unicode character '{}' ({}) looks like '{}' ({}), but it's not", </del> <ins> format!("Unicode character '{}' ({}) looks like '{}' ({}), but it is not", </ins> ch, u_name, ascii_char, ascii_name); <del> err.span_help(span, &msg); </del> <ins> err.span_suggestion(span, &msg, ascii_char.to_string()); true </ins> }, None => { let msg = format!("substitution character not found for '{}'", ch); reader.sess.span_diagnostic.span_bug_no_panic(span, &msg); <ins> false </ins> } } <del> }); </del> <ins> }).unwrap_or(false) </ins> }

fn main() { let y = 0; //~^ ERROR unknown start of token: u{37e} <del> //~^^ HELP unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it's not </del> <ins> //~^^ HELP Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not </ins> }

<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹⋅s⁻² //~^ ERROR expected at least one digit in exponent fn main() {} </ins>

<ins> error: expected at least one digit in exponent --> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:11:53 | LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹⋅s⁻² |                                                     ^ help: Unicode character '−' (Minus Sign) looks like '-' (Minus/Hyphen), but it is not | LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kg⁻¹⋅s⁻² |                                                     ^ error: aborting due to previous error </ins>