about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/lint/builtin.rs21
-rw-r--r--src/librustc_lint/builtin.rs16
-rw-r--r--src/librustc_lint/lib.rs2
-rw-r--r--src/librustc_resolve/lib.rs5
-rw-r--r--src/librustc_resolve/resolve_imports.rs3
-rw-r--r--src/libsyntax/edition.rs4
-rw-r--r--src/libsyntax/feature_gate.rs12
-rw-r--r--src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs2
-rw-r--r--src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs2
-rw-r--r--src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs2
-rw-r--r--src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs1
-rw-r--r--src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile4
-rw-r--r--src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs1
-rw-r--r--src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs2
14 files changed, 53 insertions, 24 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index 109edffcde3..175b44991fd 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -14,7 +14,7 @@
 //! compiler code, rather than using their own custom pass. Those
 //! lints are all available in `rustc_lint::builtin`.
 
-use errors::DiagnosticBuilder;
+use errors::{Applicability, DiagnosticBuilder};
 use lint::{LintPass, LateLintPass, LintArray};
 use session::Session;
 use syntax::codemap::Span;
@@ -341,15 +341,16 @@ impl BuiltinLintDiagnostics {
         match self {
             BuiltinLintDiagnostics::Normal => (),
             BuiltinLintDiagnostics::BareTraitObject(span, is_global) => {
-                let sugg = match sess.codemap().span_to_snippet(span) {
-                    Ok(ref s) if is_global => format!("dyn ({})", s),
-                    Ok(s) => format!("dyn {}", s),
-                    Err(_) => format!("dyn <type>")
+                let (sugg, app) = match sess.codemap().span_to_snippet(span) {
+                    Ok(ref s) if is_global => (format!("dyn ({})", s),
+                                               Applicability::MachineApplicable),
+                    Ok(s) => (format!("dyn {}", s), Applicability::MachineApplicable),
+                    Err(_) => (format!("dyn <type>"), Applicability::HasPlaceholders)
                 };
-                db.span_suggestion(span, "use `dyn`", sugg);
+                db.span_suggestion_with_applicability(span, "use `dyn`", sugg, app);
             }
             BuiltinLintDiagnostics::AbsPathWithModule(span) => {
-                let sugg = match sess.codemap().span_to_snippet(span) {
+                let (sugg, app) = match sess.codemap().span_to_snippet(span) {
                     Ok(ref s) => {
                         // FIXME(Manishearth) ideally the emitting code
                         // can tell us whether or not this is global
@@ -359,11 +360,11 @@ impl BuiltinLintDiagnostics {
                             "::"
                         };
 
-                        format!("crate{}{}", opt_colon, s)
+                        (format!("crate{}{}", opt_colon, s), Applicability::MachineApplicable)
                     }
-                    Err(_) => format!("crate::<path>")
+                    Err(_) => (format!("crate::<path>"), Applicability::HasPlaceholders)
                 };
-                db.span_suggestion(span, "use `crate`", sugg);
+                db.span_suggestion_with_applicability(span, "use `crate`", sugg, app);
             }
         }
     }
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index f06062fa4ac..817abe2ceeb 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -46,7 +46,7 @@ use syntax::attr;
 use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes};
 use syntax_pos::{BytePos, Span, SyntaxContext};
 use syntax::symbol::keywords;
-use syntax::errors::DiagnosticBuilder;
+use syntax::errors::{Applicability, DiagnosticBuilder};
 
 use rustc::hir::{self, PatKind};
 use rustc::hir::intravisit::FnKind;
@@ -1300,7 +1300,19 @@ impl UnreachablePub {
             } else {
                 "pub(crate)"
             }.to_owned();
-            err.span_suggestion(pub_span, "consider restricting its visibility", replacement);
+            let app = if span.ctxt().outer().expn_info().is_none() {
+                // even if macros aren't involved the suggestion
+                // may be incorrect -- the user may have mistakenly
+                // hidden it behind a private module and this lint is
+                // a helpful way to catch that. However, we're trying
+                // not to change the nature of the code with this lint
+                // so it's marked as machine applicable.
+                Applicability::MachineApplicable
+            } else {
+                Applicability::MaybeIncorrect
+            };
+            err.span_suggestion_with_applicability(pub_span, "consider restricting its visibility",
+                                                   replacement, app);
             if exportable {
                 err.help("or consider exporting it for use by other crates");
             }
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index 4f6d23dce6d..074fa914f37 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -178,7 +178,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
                     UNUSED_PARENS);
 
     add_lint_group!(sess,
-                    "rust_2018_idioms",
+                    "rust_2018_migration",
                     BARE_TRAIT_OBJECT,
                     UNREACHABLE_PUB);
 
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index d4b212a15d8..0f931d4374e 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -3277,9 +3277,8 @@ impl<'a> Resolver<'a> {
                     let prev_name = path[0].name;
                     if prev_name == keywords::Extern.name() ||
                        prev_name == keywords::CrateRoot.name() &&
-                       // Note: When this feature stabilizes, this should
-                       // be gated on sess.rust_2018()
-                       self.session.features_untracked().extern_absolute_paths {
+                       self.session.features_untracked().extern_absolute_paths &&
+                       self.session.rust_2018() {
                         // `::extern_crate::a::b`
                         let crate_id = self.crate_loader.process_path_extern(name, ident.span);
                         let crate_root =
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
index 17aa510b565..6a5a31a885f 100644
--- a/src/librustc_resolve/resolve_imports.rs
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -646,7 +646,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
         if module_path.len() == 1 && (module_path[0].name == keywords::CrateRoot.name() ||
                                       module_path[0].name == keywords::Extern.name()) {
             let is_extern = module_path[0].name == keywords::Extern.name() ||
-                            self.session.features_untracked().extern_absolute_paths;
+                            (self.session.features_untracked().extern_absolute_paths &&
+                             self.session.rust_2018());
             match directive.subclass {
                 GlobImport { .. } if is_extern => {
                     return Some((directive.span,
diff --git a/src/libsyntax/edition.rs b/src/libsyntax/edition.rs
index 3fc1c279f5a..7341941c242 100644
--- a/src/libsyntax/edition.rs
+++ b/src/libsyntax/edition.rs
@@ -50,8 +50,8 @@ impl fmt::Display for Edition {
 impl Edition {
     pub fn lint_name(&self) -> &'static str {
         match *self {
-            Edition::Edition2015 => "edition_2015",
-            Edition::Edition2018 => "edition_2018",
+            Edition::Edition2015 => "rust_2015_breakage",
+            Edition::Edition2018 => "rust_2018_breakage",
         }
     }
 
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index d8db76a95ff..5155408ba63 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -300,7 +300,7 @@ declare_features! (
     (active, abi_unadjusted, "1.16.0", None, None),
 
     // Procedural macros 2.0.
-    (active, proc_macro, "1.16.0", Some(38356), None),
+    (active, proc_macro, "1.16.0", Some(38356), Some(Edition::Edition2018)),
 
     // Declarative macros 2.0 (`macro`).
     (active, decl_macro, "1.17.0", Some(39412), None),
@@ -324,7 +324,7 @@ declare_features! (
 
 
     // Allows the `catch {...}` expression
-    (active, catch_expr, "1.17.0", Some(31436), None),
+    (active, catch_expr, "1.17.0", Some(31436), Some(Edition::Edition2018)),
 
     // Used to preserve symbols (see llvm.used)
     (active, used, "1.18.0", Some(40289), None),
@@ -1848,6 +1848,14 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
 
     let mut feature_checker = FeatureChecker::default();
 
+    for &(.., f_edition, set) in ACTIVE_FEATURES.iter() {
+        if let Some(f_edition) = f_edition {
+            if f_edition <= crate_edition {
+                set(&mut features, DUMMY_SP);
+            }
+        }
+    }
+
     for attr in krate_attrs {
         if !attr.check_name("feature") {
             continue
diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs
index 14d5d9caa31..fcf4714ba96 100644
--- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs
+++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: --edition=2018 -Zunstable-options
+
 #![feature(extern_absolute_paths)]
 
 use xcrate::S; //~ ERROR can't find crate for `xcrate`
diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs
index defd103f9e4..c256c5592c2 100644
--- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs
+++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: --edition=2018 -Zunstable-options
+
 #![feature(extern_absolute_paths)]
 
 fn main() {
diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs
index be1708e2b57..837dc617b3a 100644
--- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs
+++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-flags: --edition=2018 -Zunstable-options
+
 #![feature(extern_absolute_paths)]
 
 use ycrate; //~ ERROR can't find crate for `ycrate`
diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs
index e44465750d1..9b7baa00163 100644
--- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs
+++ b/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:xcrate.rs
+// compile-flags: --edition=2018 -Zunstable-options
 
 #![feature(crate_in_paths)]
 #![feature(extern_absolute_paths)]
diff --git a/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile b/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
index a132668ec7c..6a67b5862a8 100644
--- a/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
+++ b/src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
@@ -1,9 +1,9 @@
 -include ../tools.mk
 
 all: extern_absolute_paths.rs extern_in_paths.rs krate2
-	$(RUSTC) extern_absolute_paths.rs -Zsave-analysis
+	$(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018
 	cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
-	$(RUSTC) extern_in_paths.rs -Zsave-analysis
+	$(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018
 	cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py
 
 krate2: krate2.rs
diff --git a/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs b/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs
index 0fa125a3e50..bbe066481a8 100644
--- a/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs
+++ b/src/test/run-pass/rfc-2126-extern-absolute-paths/basic.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // aux-build:xcrate.rs
+// compile-flags: --edition=2018 -Zunstable-options
 
 #![feature(extern_absolute_paths)]
 
diff --git a/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs b/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs
index 796f652d6b5..ead462cf0d2 100644
--- a/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs
+++ b/src/test/run-pass/rfc-2126-extern-absolute-paths/test.rs
@@ -12,7 +12,7 @@
 //
 // Regression test for #47075.
 
-// compile-flags: --test
+// compile-flags: --test --edition=2018 -Zunstable-options
 
 #![feature(extern_absolute_paths)]