about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-01-26 18:14:46 +0000
committerbors <bors@rust-lang.org>2019-01-26 18:14:46 +0000
commit20c2cba61dc83e612d25ed496025171caa3db30f (patch)
treef6294c9e220acd5733dfe7b39541f4e2640c7187 /src
parent46a43dc1e987156c4c03a8c92c8ba7b21363982b (diff)
parent97833ee506d2b69c46bad4aad07aab89c7f03516 (diff)
downloadrust-20c2cba61dc83e612d25ed496025171caa3db30f.tar.gz
rust-20c2cba61dc83e612d25ed496025171caa3db30f.zip
Auto merge of #57918 - Centril:rollup, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #57407 (Stabilize extern_crate_self)
 - #57703 (Make MutexGuard's Debug implementation more useful.)
 - #57764 (Fix some minor warnings)
 - #57825 (un-deprecate mem::zeroed)
 - #57827 (Ignore aarch64 in simd-intrinsic-generic-reduction)
 - #57908 (resolve: Fix span arithmetics in the import conflict error)
 - #57913 (Change crate-visibility-modifier issue number in The Unstable Book)

Failed merges:

r? @ghost
Diffstat (limited to 'src')
-rw-r--r--src/doc/unstable-book/src/language-features/crate-visibility-modifier.md4
-rw-r--r--src/libcore/mem.rs1
-rw-r--r--src/libfmt_macros/lib.rs1
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs6
-rw-r--r--src/librustc_resolve/lib.rs91
-rw-r--r--src/libstd/sync/mutex.rs4
-rw-r--r--src/libsyntax/feature_gate.rs5
-rw-r--r--src/libtest/lib.rs2
-rw-r--r--src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs1
-rw-r--r--src/test/ui/feature-gates/feature-gate-extern_crate_self.rs3
-rw-r--r--src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr11
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs (renamed from src/test/ui/imports/extern-crate-self-fail.rs)2
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr (renamed from src/test/ui/imports/extern-crate-self-fail.stderr)4
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs16
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs12
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs16
-rw-r--r--src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs (renamed from src/test/ui/imports/extern-crate-self-pass.rs)2
-rw-r--r--src/test/ui/issues/issue-56411.rs17
-rw-r--r--src/test/ui/issues/issue-56411.stderr31
-rw-r--r--src/test/ui/issues/issue_56411_aux.rs5
-rw-r--r--src/tools/linkchecker/main.rs6
21 files changed, 156 insertions, 84 deletions
diff --git a/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md b/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md
index 11b3ee8edf0..b59859dd348 100644
--- a/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md
+++ b/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md
@@ -1,8 +1,8 @@
 # `crate_visibility_modifier`
 
-The tracking issue for this feature is: [#45388]
+The tracking issue for this feature is: [#53120]
 
-[#45388]: https://github.com/rust-lang/rust/issues/45388
+[#53120]: https://github.com/rust-lang/rust/issues/53120
 
 -----
 
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 8fcbb73d9ce..9e100d0a58d 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -489,7 +489,6 @@ pub const fn needs_drop<T>() -> bool {
 /// assert_eq!(0, x);
 /// ```
 #[inline]
-#[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::zeroed` instead")]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub unsafe fn zeroed<T>() -> T {
     #[cfg(not(stage0))]
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs
index da440cdd72f..4f516f18bbf 100644
--- a/src/libfmt_macros/lib.rs
+++ b/src/libfmt_macros/lib.rs
@@ -11,6 +11,7 @@
        test(attr(deny(warnings))))]
 
 #![feature(nll)]
+#![feature(rustc_private)]
 
 pub use self::Piece::*;
 pub use self::Position::*;
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 3db73800d64..31f8ce26225 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -32,7 +32,7 @@ use syntax::ext::base::{MacroKind, SyntaxExtension};
 use syntax::ext::base::Determinacy::Undetermined;
 use syntax::ext::hygiene::Mark;
 use syntax::ext::tt::macro_rules;
-use syntax::feature_gate::{is_builtin_attr, emit_feature_err, GateIssue};
+use syntax::feature_gate::is_builtin_attr;
 use syntax::parse::token::{self, Token};
 use syntax::std_inject::injected_crate_name;
 use syntax::symbol::keywords;
@@ -356,10 +356,6 @@ impl<'a> Resolver<'a> {
                         .emit();
                     return;
                 } else if orig_name == Some(keywords::SelfLower.name()) {
-                    if !self.session.features_untracked().extern_crate_self {
-                        emit_feature_err(&self.session.parse_sess, "extern_crate_self", item.span,
-                                         GateIssue::Language, "`extern crate self` is unstable");
-                    }
                     self.graph_root
                 } else {
                     let crate_id = self.crate_loader.process_extern_crate(item, &self.definitions);
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 4c9347afa61..873ace90172 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -5134,60 +5134,59 @@ impl<'a> Resolver<'a> {
         );
 
         // See https://github.com/rust-lang/rust/issues/32354
-        if old_binding.is_import() || new_binding.is_import() {
-            let binding = if new_binding.is_import() && !new_binding.span.is_dummy() {
-                new_binding
+        let directive = match (&new_binding.kind, &old_binding.kind) {
+            (NameBindingKind::Import { directive, .. }, _) if !new_binding.span.is_dummy() =>
+                Some((directive, new_binding.span)),
+            (_, NameBindingKind::Import { directive, .. }) if !old_binding.span.is_dummy() =>
+                Some((directive, old_binding.span)),
+            _ => None,
+        };
+        if let Some((directive, binding_span)) = directive {
+            let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
+                format!("Other{}", name)
             } else {
-                old_binding
+                format!("other_{}", name)
             };
 
-            let cm = self.session.source_map();
-            let rename_msg = "you can use `as` to change the binding name of the import";
-
-            if let (
-                Ok(snippet),
-                NameBindingKind::Import { directive, ..},
-                _dummy @ false,
-            ) = (
-                cm.span_to_snippet(binding.span),
-                binding.kind.clone(),
-                binding.span.is_dummy(),
-            ) {
-                let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
-                    format!("Other{}", name)
-                } else {
-                    format!("other_{}", name)
-                };
+            let mut suggestion = None;
+            match directive.subclass {
+                ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } =>
+                    suggestion = Some(format!("self as {}", suggested_name)),
+                ImportDirectiveSubclass::SingleImport { source, .. } => {
+                    if let Some(pos) = source.span.hi().0.checked_sub(binding_span.lo().0)
+                                                         .map(|pos| pos as usize) {
+                        if let Ok(snippet) = self.session.source_map()
+                                                         .span_to_snippet(binding_span) {
+                            if pos <= snippet.len() {
+                                suggestion = Some(format!(
+                                    "{} as {}{}",
+                                    &snippet[..pos],
+                                    suggested_name,
+                                    if snippet.ends_with(";") { ";" } else { "" }
+                                ))
+                            }
+                        }
+                    }
+                }
+                ImportDirectiveSubclass::ExternCrate { source, target, .. } =>
+                    suggestion = Some(format!(
+                        "extern crate {} as {};",
+                        source.unwrap_or(target.name),
+                        suggested_name,
+                    )),
+                _ => unreachable!(),
+            }
 
+            let rename_msg = "you can use `as` to change the binding name of the import";
+            if let Some(suggestion) = suggestion {
                 err.span_suggestion_with_applicability(
-                    binding.span,
-                    &rename_msg,
-                    match directive.subclass {
-                        ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } =>
-                            format!("self as {}", suggested_name),
-                        ImportDirectiveSubclass::SingleImport { source, .. } =>
-                            format!(
-                                "{} as {}{}",
-                                &snippet[..((source.span.hi().0 - binding.span.lo().0) as usize)],
-                                suggested_name,
-                                if snippet.ends_with(";") {
-                                    ";"
-                                } else {
-                                    ""
-                                }
-                            ),
-                        ImportDirectiveSubclass::ExternCrate { source, target, .. } =>
-                            format!(
-                                "extern crate {} as {};",
-                                source.unwrap_or(target.name),
-                                suggested_name,
-                            ),
-                        _ => unreachable!(),
-                    },
+                    binding_span,
+                    rename_msg,
+                    suggestion,
                     Applicability::MaybeIncorrect,
                 );
             } else {
-                err.span_label(binding.span, rename_msg);
+                err.span_label(binding_span, rename_msg);
             }
         }
 
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs
index 856bb260424..59829db23cb 100644
--- a/src/libstd/sync/mutex.rs
+++ b/src/libstd/sync/mutex.rs
@@ -450,9 +450,7 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        f.debug_struct("MutexGuard")
-            .field("lock", &self.__lock)
-            .finish()
+        fmt::Debug::fmt(&**self, f)
     }
 }
 
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index d74a0d5623a..28209248246 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -453,9 +453,6 @@ declare_features! (
     // Adds `reason` and `expect` lint attributes.
     (active, lint_reasons, "1.31.0", Some(54503), None),
 
-    // `extern crate self as foo;` puts local crate root into extern prelude under name `foo`.
-    (active, extern_crate_self, "1.31.0", Some(56409), None),
-
     // Allows paths to enum variants on type aliases.
     (active, type_alias_enum_variants, "1.31.0", Some(49683), None),
 
@@ -689,6 +686,8 @@ declare_features! (
     (accepted, uniform_paths, "1.32.0", Some(53130), None),
     // Allows `cfg(target_vendor = "...")`.
     (accepted, cfg_target_vendor, "1.33.0", Some(29718), None),
+    // `extern crate self as foo;` puts local crate root into extern prelude under name `foo`.
+    (accepted, extern_crate_self, "1.34.0", Some(56409), None),
 );
 
 // If you change this, please modify `src/doc/unstable-book` as well. You must
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 2cc80ddea2d..fc03e685b6f 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -25,7 +25,7 @@
 #![feature(asm)]
 #![cfg_attr(stage0, feature(cfg_target_vendor))]
 #![feature(fnbox)]
-#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
+#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))]
 #![feature(nll)]
 #![feature(set_stdio)]
 #![feature(panic_unwind)]
diff --git a/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs b/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs
index b39f54a5efb..e3faa7c625c 100644
--- a/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs
+++ b/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs
@@ -2,6 +2,7 @@
 #![allow(non_camel_case_types)]
 
 // ignore-emscripten
+// ignore-aarch64 FIXME: https://github.com/rust-lang/rust/issues/54510
 
 // Test that the simd_reduce_{op} intrinsics produce the correct results.
 
diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_self.rs b/src/test/ui/feature-gates/feature-gate-extern_crate_self.rs
deleted file mode 100644
index 2161932c2f6..00000000000
--- a/src/test/ui/feature-gates/feature-gate-extern_crate_self.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-extern crate self as foo; //~ ERROR `extern crate self` is unstable
-
-fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr b/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr
deleted file mode 100644
index 530015b2cb7..00000000000
--- a/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0658]: `extern crate self` is unstable (see issue #56409)
-  --> $DIR/feature-gate-extern_crate_self.rs:1:1
-   |
-LL | extern crate self as foo; //~ ERROR `extern crate self` is unstable
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(extern_crate_self)] to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/imports/extern-crate-self-fail.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs
index eab7b7032aa..defa0e294bd 100644
--- a/src/test/ui/imports/extern-crate-self-fail.rs
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs
@@ -1,5 +1,3 @@
-#![feature(extern_crate_self)]
-
 extern crate self; //~ ERROR `extern crate self;` requires renaming
 
 #[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self`
diff --git a/src/test/ui/imports/extern-crate-self-fail.stderr b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr
index 0ca0d89eaf0..b47d10343f6 100644
--- a/src/test/ui/imports/extern-crate-self-fail.stderr
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr
@@ -1,11 +1,11 @@
 error: `extern crate self;` requires renaming
-  --> $DIR/extern-crate-self-fail.rs:3:1
+  --> $DIR/extern-crate-self-fail.rs:1:1
    |
 LL | extern crate self; //~ ERROR `extern crate self;` requires renaming
    | ^^^^^^^^^^^^^^^^^^ help: try: `extern crate self as name;`
 
 error: `macro_use` is not supported on `extern crate self`
-  --> $DIR/extern-crate-self-fail.rs:5:1
+  --> $DIR/extern-crate-self-fail.rs:3:1
    |
 LL | #[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self`
    | ^^^^^^^^^^^^
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs
new file mode 100644
index 00000000000..79683522888
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-alias.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+// Test that a macro can correctly expand the alias
+// in an `extern crate self as ALIAS` item.
+
+fn the_answer() -> usize { 42 }
+
+macro_rules! alias_self {
+    ($alias:ident) => { extern crate self as $alias; }
+}
+
+alias_self!(the_alias);
+
+fn main() {
+    assert_eq!(the_alias::the_answer(), 42);
+}
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs
new file mode 100644
index 00000000000..9c9397999ff
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs
@@ -0,0 +1,12 @@
+// compile-pass
+
+// Test that `extern crate self;` is accepted
+// syntactically as an item for use in a macro.
+
+macro_rules! accept_item { ($x:item) => {} }
+
+accept_item! {
+    extern crate self;
+}
+
+fn main() {}
diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs
new file mode 100644
index 00000000000..009a92e8776
--- /dev/null
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-macro-self.rs
@@ -0,0 +1,16 @@
+// run-pass
+
+// Test that a macro can correctly expand `self` in
+// an `extern crate self as ALIAS` item.
+
+fn the_answer() -> usize { 42 }
+
+macro_rules! extern_something {
+    ($alias:ident) => { extern crate $alias as the_alias; }
+}
+
+extern_something!(self);
+
+fn main() {
+    assert_eq!(the_alias::the_answer(), 42);
+}
diff --git a/src/test/ui/imports/extern-crate-self-pass.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs
index bf255bb6b81..6f6343a6148 100644
--- a/src/test/ui/imports/extern-crate-self-pass.rs
+++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-pass.rs
@@ -1,7 +1,5 @@
 // compile-pass
 
-#![feature(extern_crate_self)]
-
 extern crate self as foo;
 
 struct S;
diff --git a/src/test/ui/issues/issue-56411.rs b/src/test/ui/issues/issue-56411.rs
new file mode 100644
index 00000000000..3561c21cc7e
--- /dev/null
+++ b/src/test/ui/issues/issue-56411.rs
@@ -0,0 +1,17 @@
+macro_rules! import {
+    ( $($name:ident),* ) => {
+        $(
+            mod $name;
+            pub use self::$name;
+            //~^ ERROR the name `issue_56411_aux` is defined multiple times
+            //~| ERROR `issue_56411_aux` is private, and cannot be re-exported
+
+        )*
+    }
+}
+
+import!(issue_56411_aux);
+
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/src/test/ui/issues/issue-56411.stderr b/src/test/ui/issues/issue-56411.stderr
new file mode 100644
index 00000000000..dd05852c091
--- /dev/null
+++ b/src/test/ui/issues/issue-56411.stderr
@@ -0,0 +1,31 @@
+error[E0255]: the name `issue_56411_aux` is defined multiple times
+  --> $DIR/issue-56411.rs:5:21
+   |
+LL |             mod $name;
+   |             ---------- previous definition of the module `issue_56411_aux` here
+LL |             pub use self::$name;
+   |                     ^^^^^^^^^^^
+   |                     |
+   |                     `issue_56411_aux` reimported here
+   |                     you can use `as` to change the binding name of the import
+...
+LL | import!(issue_56411_aux);
+   | ------------------------- in this macro invocation
+   |
+   = note: `issue_56411_aux` must be defined only once in the type namespace of this module
+
+error[E0365]: `issue_56411_aux` is private, and cannot be re-exported
+  --> $DIR/issue-56411.rs:5:21
+   |
+LL |             pub use self::$name;
+   |                     ^^^^^^^^^^^ re-export of private `issue_56411_aux`
+...
+LL | import!(issue_56411_aux);
+   | ------------------------- in this macro invocation
+   |
+   = note: consider declaring type or module `issue_56411_aux` with `pub`
+
+error: aborting due to 2 previous errors
+
+Some errors occurred: E0255, E0365.
+For more information about an error, try `rustc --explain E0255`.
diff --git a/src/test/ui/issues/issue_56411_aux.rs b/src/test/ui/issues/issue_56411_aux.rs
new file mode 100644
index 00000000000..bd689e913ab
--- /dev/null
+++ b/src/test/ui/issues/issue_56411_aux.rs
@@ -0,0 +1,5 @@
+// compile-pass
+
+struct T {}
+
+fn main() {}
diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs
index 59662be349d..2cf0fcfd34c 100644
--- a/src/tools/linkchecker/main.rs
+++ b/src/tools/linkchecker/main.rs
@@ -78,7 +78,7 @@ impl FileEntry {
     fn parse_ids(&mut self, file: &Path, contents: &str, errors: &mut bool) {
         if self.ids.is_empty() {
             with_attrs_in_source(contents, " id", |fragment, i, _| {
-                let frag = fragment.trim_left_matches("#").to_owned();
+                let frag = fragment.trim_start_matches("#").to_owned();
                 let encoded = small_url_encode(&frag);
                 if !self.ids.insert(frag) {
                     *errors = true;
@@ -343,7 +343,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
                 Some(i) => i,
                 None => continue,
             };
-            if rest[..pos_equals].trim_left_matches(" ") != "" {
+            if rest[..pos_equals].trim_start_matches(" ") != "" {
                 continue;
             }
 
@@ -355,7 +355,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(contents: &str, attr: &str,
             };
             let quote_delim = rest.as_bytes()[pos_quote] as char;
 
-            if rest[..pos_quote].trim_left_matches(" ") != "" {
+            if rest[..pos_quote].trim_start_matches(" ") != "" {
                 continue;
             }
             let rest = &rest[pos_quote + 1..];