]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/front/feature_gate.rs
Replace all ~"" with "".to_owned()
[rust.git] / src / librustc / front / feature_gate.rs
index 36f6cedb4f158fcf690107b9ac9ca4e27487974f..3ab39dd121f082aca119f359f69293b8863e4b42 100644 (file)
@@ -31,7 +31,6 @@
 use driver::session::Session;
 
 use std::cell::Cell;
-use std::vec_ng::Vec;
 
 /// This is a list of all known features since the beginning of time. This list
 /// can never shrink, it may only be expanded (in order to prevent old programs
@@ -50,6 +49,8 @@
     ("macro_registrar", Active),
     ("log_syntax", Active),
     ("trace_macros", Active),
+    ("concat_idents", Active),
+
     ("simd", Active),
     ("default_type_params", Active),
     ("quote", Active),
@@ -75,7 +76,7 @@ enum Status {
 
 /// A set of features to be used by later passes.
 pub struct Features {
-    default_type_params: Cell<bool>
+    pub default_type_params: Cell<bool>
 }
 
 impl Features {
@@ -86,16 +87,16 @@ pub fn new() -> Features {
     }
 }
 
-struct Context {
-    features: Vec<&'static str> ,
-    sess: Session,
+struct Context<'a> {
+    features: Vec<&'static str>,
+    sess: &'a Session,
 }
 
-impl Context {
+impl<'a> Context<'a> {
     fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
         if !self.has_feature(feature) {
             self.sess.span_err(span, explain);
-            self.sess.span_note(span, format!("add \\#[feature({})] to the \
+            self.sess.span_note(span, format!("add \\#![feature({})] to the \
                                                   crate attributes to enable",
                                                  feature));
         }
@@ -114,7 +115,7 @@ fn has_feature(&self, feature: &str) -> bool {
     }
 }
 
-impl Visitor<()> for Context {
+impl<'a> Visitor<()> for Context<'a> {
     fn visit_ident(&mut self, sp: Span, id: ast::Ident, _: ()) {
         if !token::get_ident(id).get().is_ascii() {
             self.gate_feature("non_ascii_idents", sp,
@@ -230,6 +231,11 @@ fn visit_mac(&mut self, macro: &ast::Mac, _: ()) {
                 stable enough for use and is subject to change");
         }
 
+        else if id == token::str_to_ident("concat_idents") {
+            self.gate_feature("concat_idents", path.span, "`concat_idents` is not \
+                stable enough for use and is subject to change");
+        }
+
         else {
             for &quote in quotes.iter() {
                 if id == token::str_to_ident(quote) {
@@ -254,8 +260,7 @@ fn visit_foreign_item(&mut self, i: &ast::ForeignItem, _: ()) {
 
     fn visit_ty(&mut self, t: &ast::Ty, _: ()) {
         match t.node {
-            ast::TyClosure(closure) if closure.onceness == ast::Once &&
-                    closure.sigil != ast::OwnedSigil => {
+            ast::TyClosure(closure, _) if closure.onceness == ast::Once => {
                 self.gate_feature("once_fns", t.span,
                                   "once functions are \
                                    experimental and likely to be removed");
@@ -293,7 +298,7 @@ fn visit_generics(&mut self, generics: &ast::Generics, _: ()) {
     }
 }
 
-pub fn check_crate(sess: Session, krate: &ast::Crate) {
+pub fn check_crate(sess: &Session, krate: &ast::Crate) {
     let mut cx = Context {
         features: Vec::new(),
         sess: sess,
@@ -334,7 +339,7 @@ pub fn check_crate(sess: Session, krate: &ast::Crate) {
                             sess.add_lint(lint::UnknownFeatures,
                                           ast::CRATE_NODE_ID,
                                           mi.span,
-                                          ~"unknown feature");
+                                          "unknown feature".to_owned());
                         }
                     }
                 }