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
This commit is contained in:
commit
927a3e873d
@ -91,17 +91,16 @@ fn main() {
|
|||||||
cmd.args(&args)
|
cmd.args(&args)
|
||||||
.env(bootstrap::util::dylib_path_var(),
|
.env(bootstrap::util::dylib_path_var(),
|
||||||
env::join_paths(&dylib_path).unwrap());
|
env::join_paths(&dylib_path).unwrap());
|
||||||
let mut maybe_crate = None;
|
|
||||||
|
|
||||||
// Get the name of the crate we're compiling, if any.
|
// Get the name of the crate we're compiling, if any.
|
||||||
let maybe_crate_name = args.windows(2)
|
let crate_name = args.windows(2)
|
||||||
.find(|a| &*a[0] == "--crate-name")
|
.find(|args| args[0] == "--crate-name")
|
||||||
.map(|crate_name| &*crate_name[1]);
|
.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 let Some(target) = env::var_os("RUSTC_TIME") {
|
||||||
if target == "all" ||
|
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");
|
cmd.arg("-Ztime");
|
||||||
}
|
}
|
||||||
@ -125,6 +124,19 @@ fn main() {
|
|||||||
cmd.arg(format!("-Cdebuginfo={}", debuginfo_level));
|
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 {
|
if let Some(target) = target {
|
||||||
// The stage0 compiler has a special sysroot distinct from what we
|
// The stage0 compiler has a special sysroot distinct from what we
|
||||||
// actually downloaded, so we just always pass the `--sysroot` option.
|
// actually downloaded, so we just always pass the `--sysroot` option.
|
||||||
@ -167,9 +179,6 @@ fn main() {
|
|||||||
cmd.arg(format!("-Clinker={}", target_linker));
|
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
|
// 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
|
// 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
|
// 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
|
// `compiler_builtins` are unconditionally compiled with panic=abort to
|
||||||
// workaround undefined references to `rust_eh_unwind_resume` generated
|
// workaround undefined references to `rust_eh_unwind_resume` generated
|
||||||
// otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
|
// otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
|
||||||
if crate_name == "panic_abort" ||
|
if crate_name == Some("panic_abort") ||
|
||||||
crate_name == "compiler_builtins" && stage != "0" {
|
crate_name == Some("compiler_builtins") && stage != "0" {
|
||||||
cmd.arg("-C").arg("panic=abort");
|
cmd.arg("-C").arg("panic=abort");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +205,7 @@ fn main() {
|
|||||||
|
|
||||||
// The compiler builtins are pretty sensitive to symbols referenced in
|
// The compiler builtins are pretty sensitive to symbols referenced in
|
||||||
// libcore and such, so we never compile them with debug assertions.
|
// 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");
|
cmd.arg("-C").arg("debug-assertions=no");
|
||||||
} else {
|
} else {
|
||||||
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
|
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)
|
// Force all crates compiled by this compiler to (a) be unstable and (b)
|
||||||
// allow the `rustc_private` feature to link to other unstable crates
|
// allow the `rustc_private` feature to link to other unstable crates
|
||||||
// also in the sysroot. We also do this for host crates, since those
|
// 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");
|
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 {
|
if verbose > 1 {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"rustc command: {:?}={:?} {:?}",
|
"rustc command: {:?}={:?} {:?}",
|
||||||
@ -362,7 +348,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if env::var_os("RUSTC_PRINT_STEP_TIMINGS").is_some() {
|
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 start = Instant::now();
|
||||||
let status = cmd
|
let status = cmd
|
||||||
.status()
|
.status()
|
||||||
@ -371,7 +357,7 @@ fn main() {
|
|||||||
|
|
||||||
let is_test = args.iter().any(|a| a == "--test");
|
let is_test = args.iter().any(|a| a == "--test");
|
||||||
eprintln!("[RUSTC-TIMING] {} test:{} {}.{:03}",
|
eprintln!("[RUSTC-TIMING] {} test:{} {}.{:03}",
|
||||||
krate.to_string_lossy(),
|
crate_name,
|
||||||
is_test,
|
is_test,
|
||||||
dur.as_secs(),
|
dur.as_secs(),
|
||||||
dur.subsec_nanos() / 1_000_000);
|
dur.subsec_nanos() / 1_000_000);
|
||||||
@ -390,6 +376,14 @@ fn main() {
|
|||||||
std::process::exit(code);
|
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)]
|
#[cfg(unix)]
|
||||||
fn exec_cmd(cmd: &mut Command) -> io::Result<i32> {
|
fn exec_cmd(cmd: &mut Command) -> io::Result<i32> {
|
||||||
use std::os::unix::process::CommandExt;
|
use std::os::unix::process::CommandExt;
|
||||||
|
@ -335,11 +335,14 @@ macro_rules! r#try {
|
|||||||
/// ```
|
/// ```
|
||||||
/// use std::io::Write;
|
/// use std::io::Write;
|
||||||
///
|
///
|
||||||
|
/// fn main() -> std::io::Result<()> {
|
||||||
/// let mut w = Vec::new();
|
/// let mut w = Vec::new();
|
||||||
/// write!(&mut w, "test").unwrap();
|
/// write!(&mut w, "test")?;
|
||||||
/// write!(&mut w, "formatted {}", "arguments").unwrap();
|
/// 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
|
/// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
|
||||||
|
@ -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]
|
#[inline]
|
||||||
#[stable(feature = "pin", since = "1.33.0")]
|
#[stable(feature = "pin", since = "1.33.0")]
|
||||||
pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> {
|
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]
|
#[inline]
|
||||||
#[stable(feature = "pin", since = "1.33.0")]
|
#[stable(feature = "pin", since = "1.33.0")]
|
||||||
pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> {
|
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:
|
/// 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
|
/// 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()`
|
/// the `Option<T>` being an iterator over one or zero elements. `filter()`
|
||||||
/// lets you decide which elements to keep.
|
/// 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(3).filter(is_even), None);
|
||||||
/// assert_eq!(Some(4).filter(is_even), Some(4));
|
/// 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]
|
#[inline]
|
||||||
#[stable(feature = "option_filter", since = "1.27.0")]
|
#[stable(feature = "option_filter", since = "1.27.0")]
|
||||||
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
|
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>`.
|
/// Converts from `&Option<T>` to `Option<&T::Target>`.
|
||||||
///
|
///
|
||||||
/// Leaves the original Option in-place, creating a new one with a reference
|
/// 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> {
|
pub fn deref(&self) -> Option<&T::Target> {
|
||||||
self.as_ref().map(|t| t.deref())
|
self.as_ref().map(|t| t.deref())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, E> Option<Result<T, E>> {
|
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)`.
|
/// [`None`] will be mapped to [`Ok`]`(`[`None`]`)`.
|
||||||
/// `Some(Ok(_))` and `Some(Err(_))` will be mapped to `Ok(Some(_))` and `Err(_)`.
|
/// [`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
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -1709,8 +1709,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"use fully-qualified syntax",
|
"use fully-qualified syntax",
|
||||||
format!("<{} as {}>::{}", qself_ty, "Trait", assoc_ident),
|
format!("<{} as {}>::{}", qself_ty, tcx.item_name(trait_did), assoc_ident),
|
||||||
Applicability::HasPlaceholders,
|
Applicability::MachineApplicable,
|
||||||
).emit();
|
).emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ error: ambiguous associated item
|
|||||||
--> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15
|
--> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15
|
||||||
|
|
|
|
||||||
LL | fn f() -> Self::V { 0 }
|
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
|
= 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!
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user