about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-07-07 04:42:58 +0000
committerbors <bors@rust-lang.org>2019-07-07 04:42:58 +0000
commit927a3e873d92d6e85a18d6274becf2fb8d4f284c (patch)
tree762ea874f8031397e78295c8115450be23273300
parent4393768faa104b9879c601feee71eb0207dc4fe1 (diff)
parentfb0117000a89053ab8e964eb5fee1d73a5d019c1 (diff)
downloadrust-927a3e873d92d6e85a18d6274becf2fb8d4f284c.tar.gz
rust-927a3e873d92d6e85a18d6274becf2fb8d4f284c.zip
Auto merge of #62458 - Centril:rollup-j6o2sqj, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #61990 (First question mark in doctest)
 - #62379 (Add missing links in Option documentation)
 - #62438 (rustbuild: Cleanup global lint settings)
 - #62455 (name the trait in ambiguous-associated-items fully qualified suggestion)

Failed merges:

r? @ghost
-rw-r--r--src/bootstrap/bin/rustc.rs68
-rw-r--r--src/libcore/macros.rs11
-rw-r--r--src/libcore/option.rs32
-rw-r--r--src/librustc_typeck/astconv.rs4
-rw-r--r--src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr2
5 files changed, 63 insertions, 54 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index 242074fec77..a9225f2870f 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -91,17 +91,16 @@ fn main() {
     cmd.args(&args)
         .env(bootstrap::util::dylib_path_var(),
              env::join_paths(&dylib_path).unwrap());
-    let mut maybe_crate = None;
 
     // Get the name of the crate we're compiling, if any.
-    let maybe_crate_name = args.windows(2)
-        .find(|a| &*a[0] == "--crate-name")
-        .map(|crate_name| &*crate_name[1]);
+    let crate_name = args.windows(2)
+        .find(|args| args[0] == "--crate-name")
+        .and_then(|args| args[1].to_str());
 
-    if let Some(current_crate) = maybe_crate_name {
+    if let Some(crate_name) = crate_name {
         if let Some(target) = env::var_os("RUSTC_TIME") {
             if target == "all" ||
-               target.into_string().unwrap().split(",").any(|c| c.trim() == current_crate)
+               target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
             {
                 cmd.arg("-Ztime");
             }
@@ -125,6 +124,19 @@ fn main() {
         cmd.arg(format!("-Cdebuginfo={}", debuginfo_level));
     }
 
+    if env::var_os("RUSTC_DENY_WARNINGS").is_some() &&
+       env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
+        cmd.arg("-Dwarnings");
+        cmd.arg("-Drust_2018_idioms");
+        // cfg(not(bootstrap)): Remove this during the next stage 0 compiler update.
+        // `-Drustc::internal` is a new feature and `rustc_version` mis-reports the `stage`.
+        let cfg_not_bootstrap = stage != "0" && crate_name != Some("rustc_version");
+        if cfg_not_bootstrap && use_internal_lints(crate_name) {
+            cmd.arg("-Zunstable-options");
+            cmd.arg("-Drustc::internal");
+        }
+    }
+
     if let Some(target) = target {
         // The stage0 compiler has a special sysroot distinct from what we
         // actually downloaded, so we just always pass the `--sysroot` option.
@@ -167,9 +179,6 @@ fn main() {
             cmd.arg(format!("-Clinker={}", target_linker));
         }
 
-        let crate_name = maybe_crate_name.unwrap();
-        maybe_crate = Some(crate_name);
-
         // If we're compiling specifically the `panic_abort` crate then we pass
         // the `-C panic=abort` option. Note that we do not do this for any
         // other crate intentionally as this is the only crate for now that we
@@ -182,8 +191,8 @@ fn main() {
         // `compiler_builtins` are unconditionally compiled with panic=abort to
         // workaround undefined references to `rust_eh_unwind_resume` generated
         // otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
-        if crate_name == "panic_abort" ||
-           crate_name == "compiler_builtins" && stage != "0" {
+        if crate_name == Some("panic_abort") ||
+           crate_name == Some("compiler_builtins") && stage != "0" {
             cmd.arg("-C").arg("panic=abort");
         }
 
@@ -196,7 +205,7 @@ fn main() {
 
         // The compiler builtins are pretty sensitive to symbols referenced in
         // libcore and such, so we never compile them with debug assertions.
-        if crate_name == "compiler_builtins" {
+        if crate_name == Some("compiler_builtins") {
             cmd.arg("-C").arg("debug-assertions=no");
         } else {
             cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
@@ -305,22 +314,6 @@ fn main() {
         }
     }
 
-    // This is required for internal lints.
-    if let Some(crate_name) = args.windows(2).find(|a| &*a[0] == "--crate-name") {
-        let crate_name = crate_name[1].to_string_lossy();
-        if crate_name != "rustc_version"
-            && (crate_name.starts_with("rustc")
-                || crate_name.starts_with("syntax")
-                || crate_name == "arena"
-                || crate_name == "fmt_macros")
-        {
-            cmd.arg("-Zunstable-options");
-            if stage != "0" {
-                cmd.arg("-Wrustc::internal");
-            }
-        }
-    }
-
     // Force all crates compiled by this compiler to (a) be unstable and (b)
     // allow the `rustc_private` feature to link to other unstable crates
     // also in the sysroot. We also do this for host crates, since those
@@ -333,13 +326,6 @@ fn main() {
         cmd.arg("--cfg").arg("parallel_compiler");
     }
 
-    if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
-    {
-        cmd.arg("-Dwarnings");
-        cmd.arg("-Dbare_trait_objects");
-        cmd.arg("-Drust_2018_idioms");
-    }
-
     if verbose > 1 {
         eprintln!(
             "rustc command: {:?}={:?} {:?}",
@@ -362,7 +348,7 @@ fn main() {
     }
 
     if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some() {
-        if let Some(krate) = maybe_crate {
+        if let Some(crate_name) = crate_name {
             let start = Instant::now();
             let status = cmd
                 .status()
@@ -371,7 +357,7 @@ fn main() {
 
             let is_test = args.iter().any(|a| a == "--test");
             eprintln!("[RUSTC-TIMING] {} test:{} {}.{:03}",
-                      krate.to_string_lossy(),
+                      crate_name,
                       is_test,
                       dur.as_secs(),
                       dur.subsec_nanos() / 1_000_000);
@@ -390,6 +376,14 @@ fn main() {
     std::process::exit(code);
 }
 
+// Rustc crates for which internal lints are in effect.
+fn use_internal_lints(crate_name: Option<&str>) -> bool {
+    crate_name.map_or(false, |crate_name| {
+        crate_name.starts_with("rustc") || crate_name.starts_with("syntax") ||
+        ["arena", "fmt_macros"].contains(&crate_name)
+    })
+}
+
 #[cfg(unix)]
 fn exec_cmd(cmd: &mut Command) -> io::Result<i32> {
     use std::os::unix::process::CommandExt;
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 33ffd84e521..58ea0207c56 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -335,11 +335,14 @@ macro_rules! r#try {
 /// ```
 /// use std::io::Write;
 ///
-/// let mut w = Vec::new();
-/// write!(&mut w, "test").unwrap();
-/// write!(&mut w, "formatted {}", "arguments").unwrap();
+/// fn main() -> std::io::Result<()> {
+///     let mut w = Vec::new();
+///     write!(&mut w, "test")?;
+///     write!(&mut w, "formatted {}", "arguments")?;
 ///
-/// assert_eq!(w, b"testformatted arguments");
+///     assert_eq!(w, b"testformatted arguments");
+///     Ok(())
+/// }
 /// ```
 ///
 /// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index b27fd4098e1..a6bdd5a9063 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -263,7 +263,7 @@ impl<T> Option<T> {
     }
 
 
-    /// Converts from `Pin<&Option<T>>` to `Option<Pin<&T>>`
+    /// Converts from [`Pin`]`<&Option<T>>` to `Option<`[`Pin`]`<&T>>`.
     #[inline]
     #[stable(feature = "pin", since = "1.33.0")]
     pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> {
@@ -272,7 +272,7 @@ impl<T> Option<T> {
         }
     }
 
-    /// Converts from `Pin<&mut Option<T>>` to `Option<Pin<&mut T>>`
+    /// Converts from [`Pin`]`<&mut Option<T>>` to `Option<`[`Pin`]`<&mut T>>`.
     #[inline]
     #[stable(feature = "pin", since = "1.33.0")]
     pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> {
@@ -626,14 +626,14 @@ impl<T> Option<T> {
         }
     }
 
-    /// Returns `None` if the option is `None`, otherwise calls `predicate`
+    /// Returns [`None`] if the option is [`None`], otherwise calls `predicate`
     /// with the wrapped value and returns:
     ///
-    /// - `Some(t)` if `predicate` returns `true` (where `t` is the wrapped
+    /// - [`Some(t)`] if `predicate` returns `true` (where `t` is the wrapped
     ///   value), and
-    /// - `None` if `predicate` returns `false`.
+    /// - [`None`] if `predicate` returns `false`.
     ///
-    /// This function works similar to `Iterator::filter()`. You can imagine
+    /// This function works similar to [`Iterator::filter()`]. You can imagine
     /// the `Option<T>` being an iterator over one or zero elements. `filter()`
     /// lets you decide which elements to keep.
     ///
@@ -648,6 +648,10 @@ impl<T> Option<T> {
     /// assert_eq!(Some(3).filter(is_even), None);
     /// assert_eq!(Some(4).filter(is_even), Some(4));
     /// ```
+    ///
+    /// [`None`]: #variant.None
+    /// [`Some(t)`]: #variant.Some
+    /// [`Iterator::filter()`]: ../../std/iter/trait.Iterator.html#method.filter
     #[inline]
     #[stable(feature = "option_filter", since = "1.27.0")]
     pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
@@ -986,17 +990,25 @@ impl<T: Deref> Option<T> {
     /// Converts from `&Option<T>` to `Option<&T::Target>`.
     ///
     /// Leaves the original Option in-place, creating a new one with a reference
-    /// to the original one, additionally coercing the contents via `Deref`.
+    /// to the original one, additionally coercing the contents via [`Deref`].
+    ///
+    /// [`Deref`]: ../../std/ops/trait.Deref.html
     pub fn deref(&self) -> Option<&T::Target> {
         self.as_ref().map(|t| t.deref())
     }
 }
 
 impl<T, E> Option<Result<T, E>> {
-    /// Transposes an `Option` of a `Result` into a `Result` of an `Option`.
+    /// Transposes an `Option` of a [`Result`] into a [`Result`] of an `Option`.
     ///
-    /// `None` will be mapped to `Ok(None)`.
-    /// `Some(Ok(_))` and `Some(Err(_))` will be mapped to `Ok(Some(_))` and `Err(_)`.
+    /// [`None`] will be mapped to [`Ok`]`(`[`None`]`)`.
+    /// [`Some`]`(`[`Ok`]`(_))` and [`Some`]`(`[`Err`]`(_))` will be mapped to
+    /// [`Ok`]`(`[`Some`]`(_))` and [`Err`]`(_)`.
+    ///
+    /// [`None`]: #variant.None
+    /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
+    /// [`Some`]: #variant.Some
+    /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
     ///
     /// # Examples
     ///
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 7154b7958b9..d314228a232 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -1709,8 +1709,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
             err.span_suggestion(
                 span,
                 "use fully-qualified syntax",
-                format!("<{} as {}>::{}", qself_ty, "Trait", assoc_ident),
-                Applicability::HasPlaceholders,
+                format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident),
+                Applicability::MachineApplicable,
             ).emit();
         }
 
diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr
index f0dd689934f..ef025e0e146 100644
--- a/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr
+++ b/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr
@@ -2,7 +2,7 @@ error: ambiguous associated item
   --> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15
    |
 LL |     fn f() -> Self::V { 0 }
-   |               ^^^^^^^ help: use fully-qualified syntax: `<E as Trait>::V`
+   |               ^^^^^^^ help: use fully-qualified syntax: `<E as Tr>::V`
    |
    = note: #[deny(ambiguous_associated_items)] on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!