diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-11-22 23:25:14 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-11-23 08:18:50 +1100 |
| commit | ab2a99f69918f3e0bb6eb22f4523be07ac0222da (patch) | |
| tree | c59f71b83bb2d85b2c6a3a0088a34e16612f2e75 /src | |
| parent | efe9d744f986e762fe4d309298be38723ef260fb (diff) | |
| download | rust-ab2a99f69918f3e0bb6eb22f4523be07ac0222da.tar.gz rust-ab2a99f69918f3e0bb6eb22f4523be07ac0222da.zip | |
Put non-ascii identifiers behind a feature gate.
cf. https://mail.mozilla.org/pipermail/rust-dev/2013-November/006920.html
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/front/feature_gate.rs | 11 | ||||
| -rw-r--r-- | src/test/compile-fail/gated-non-ascii-idents.rs | 47 | ||||
| -rw-r--r-- | src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs | 3 | ||||
| -rw-r--r-- | src/test/run-pass/utf8_idents.rs | 4 |
4 files changed, 65 insertions, 0 deletions
diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index c4337abb740..8fedd1d92be 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -23,6 +23,7 @@ use syntax::attr::AttrMetaMethods; use syntax::codemap::Span; use syntax::visit; use syntax::visit::Visitor; +use syntax::parse::token; use driver::session::Session; @@ -36,6 +37,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("once_fns", Active), ("asm", Active), ("managed_boxes", Active), + ("non_ascii_idents", Active), // These are used to test this portion of the compiler, they don't actually // mean anything @@ -76,6 +78,15 @@ impl Context { } impl Visitor<()> for Context { + fn visit_ident(&mut self, sp: Span, id: ast::Ident, _: ()) { + let s = token::ident_to_str(&id); + + if !s.is_ascii() { + self.gate_feature("non_ascii_idents", sp, + "non-ascii idents are not fully supported."); + } + } + fn visit_view_item(&mut self, i: &ast::view_item, _: ()) { match i.node { ast::view_item_use(ref paths) => { diff --git a/src/test/compile-fail/gated-non-ascii-idents.rs b/src/test/compile-fail/gated-non-ascii-idents.rs new file mode 100644 index 00000000000..9522a523eb3 --- /dev/null +++ b/src/test/compile-fail/gated-non-ascii-idents.rs @@ -0,0 +1,47 @@ +// Copyright 2013 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. + +// xfail-fast feature doesn't work. + +#[feature(struct_variant)]; + +extern mod bäz; //~ ERROR non-ascii idents + +use föö::bar; //~ ERROR non-ascii idents + +mod föö { //~ ERROR non-ascii idents + pub fn bar() {} +} + +fn bär( //~ ERROR non-ascii idents + bäz: int //~ ERROR non-ascii idents + ) { + let _ö: int; //~ ERROR non-ascii idents + + match (1, 2) { + (_ä, _) => {} //~ ERROR non-ascii idents + } +} + +struct Föö { //~ ERROR non-ascii idents + föö: int //~ ERROR non-ascii idents +} + +enum Bär { //~ ERROR non-ascii idents + Bäz { //~ ERROR non-ascii idents + qüx: int //~ ERROR non-ascii idents + } +} + +extern { + fn qüx(); //~ ERROR non-ascii idents +} + +fn main() {} diff --git a/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs b/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs index e3a0c8417d0..527a1303b82 100644 --- a/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs +++ b/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs @@ -8,8 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-fast feature doesn't work. + #[forbid(non_camel_case_types)]; #[forbid(non_uppercase_statics)]; +#[feature(non_ascii_idents)]; // Some scripts (e.g. hiragana) don't have a concept of // upper/lowercase diff --git a/src/test/run-pass/utf8_idents.rs b/src/test/run-pass/utf8_idents.rs index 3bc29ea13e3..91b9c1c4e1e 100644 --- a/src/test/run-pass/utf8_idents.rs +++ b/src/test/run-pass/utf8_idents.rs @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-fast feature doesn't work. + +#[feature(non_ascii_idents)]; + use std::num; pub fn main() { |
