diff options
| author | Esteban Kuber <esteban@kuber.com.ar> | 2021-08-29 08:34:23 +0000 |
|---|---|---|
| committer | Esteban Kuber <esteban@kuber.com.ar> | 2021-11-23 20:35:07 +0000 |
| commit | 5a68abb0943e687cc6c8165376b4ed6deda17db3 (patch) | |
| tree | d3fb75d0d5d4be7be5e4e1cf665c94da12ed647b /compiler/rustc_interface | |
| parent | 311fa1f14dd8ffbbe83b229a94b17f7f1ecaf33b (diff) | |
| download | rust-5a68abb0943e687cc6c8165376b4ed6deda17db3.tar.gz rust-5a68abb0943e687cc6c8165376b4ed6deda17db3.zip | |
Tokenize emoji as if they were valid indentifiers
In the lexer, consider emojis to be valid identifiers and reject them later to avoid knock down parse errors.
Diffstat (limited to 'compiler/rustc_interface')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index b073ee9682f..7286209040c 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -35,7 +35,7 @@ use rustc_session::output::{filename_for_input, filename_for_metadata}; use rustc_session::search_paths::PathKind; use rustc_session::{Limit, Session}; use rustc_span::symbol::{sym, Ident, Symbol}; -use rustc_span::FileName; +use rustc_span::{FileName, MultiSpan}; use rustc_trait_selection::traits; use rustc_typeck as typeck; use tempfile::Builder as TempFileBuilder; @@ -450,6 +450,16 @@ pub fn configure_and_expand( }); } + // Gate identifiers containing invalid Unicode codepoints that were recovered during lexing. + sess.parse_sess.bad_unicode_identifiers.with_lock(|identifiers| { + for (ident, spans) in identifiers.drain() { + sess.diagnostic().span_err( + MultiSpan::from(spans), + &format!("identifiers cannot contain emojis: `{}`", ident), + ); + } + }); + Ok(krate) } |
