Disallow forbidden usage of non-ascii identifiers.

This commit is contained in:
Charles Lew 2020-05-16 14:09:01 +08:00
parent 163445ac80
commit de24ddac0a
10 changed files with 128 additions and 2 deletions

View file

@ -0,0 +1 @@
pub trait Foo {}

View file

@ -0,0 +1,6 @@
#![feature(non_ascii_idents)]
mod řųśť; //~ trying to load file for
//~^ file not found for
fn main() {}

View file

@ -0,0 +1,20 @@
error[E0583]: file not found for module `řųśť`
--> $DIR/mod_file_nonascii_forbidden.rs:3:1
|
LL | mod řųśť;
| ^^^^^^^^^
|
= help: to create the module `řųśť`, create file "$DIR/řųśť.rs"
error[E0754]: trying to load file for module `řųśť` with non ascii identifer name
--> $DIR/mod_file_nonascii_forbidden.rs:3:5
|
LL | mod řųśť;
| ^^^^
|
= help: consider using `#[path]` attribute to specify filesystem path
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0583, E0754.
For more information about an error, try `rustc --explain E0583`.

View file

@ -0,0 +1,7 @@
// check-pass
#![feature(non_ascii_idents)]
#[path="auxiliary/mod_file_nonascii_with_path_allowed-aux.rs"]
mod řųśť;
fn main() {}

View file

@ -0,0 +1,8 @@
// check-pass
#![feature(non_ascii_idents)]
mod řųśť {
const IS_GREAT: bool = true;
}
fn main() {}

View file

@ -0,0 +1,6 @@
#![feature(non_ascii_idents)]
#[no_mangle]
pub fn řųśť() {} //~ `#[no_mangle]` requires ASCII identifier
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0754]: `#[no_mangle]` requires ASCII identifier
--> $DIR/no_mangle_nonascii_forbidden.rs:4:1
|
LL | pub fn řųśť() {}
| ^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0754`.