diff options
| author | bors <bors@rust-lang.org> | 2021-11-24 23:09:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-11-24 23:09:42 +0000 |
| commit | d2c24aabcddd1eb11af633ab6b7391ae0cd00ea2 (patch) | |
| tree | d195ee55e89dd213150f665feeb6943ee5397c90 /library | |
| parent | b426445c60b4faab6e96d2b866164d478680abf6 (diff) | |
| parent | ae9681ecfad21f218ac3524dc798aafa35088202 (diff) | |
| download | rust-d2c24aabcddd1eb11af633ab6b7391ae0cd00ea2.tar.gz rust-d2c24aabcddd1eb11af633ab6b7391ae0cd00ea2.zip | |
Auto merge of #91203 - GuillaumeGomez:rollup-kwtqvb1, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #89542 (Partially stabilize `duration_consts_2`) - #90044 (Restrict aarch64 outline atomics to glibc for now.) - #90420 (Create rustdoc_internals feature gate) - #91075 (Reduce prominence of item-infos) - #91151 (Fix test in std::process on android) - #91179 (Fix more <a> color) - #91199 (rustdoc: Add test for mixing doc comments and attrs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library')
| -rw-r--r-- | library/core/src/lib.rs | 5 | ||||
| -rw-r--r-- | library/core/src/time.rs | 41 | ||||
| -rw-r--r-- | library/core/tests/lib.rs | 2 | ||||
| -rw-r--r-- | library/std/src/lib.rs | 5 | ||||
| -rw-r--r-- | library/std/src/process/tests.rs | 64 |
5 files changed, 66 insertions, 51 deletions
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 2486999ffb5..fdb23529599 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -138,7 +138,7 @@ #![feature(const_type_id)] #![feature(const_type_name)] #![feature(const_default_impls)] -#![feature(duration_consts_2)] +#![feature(duration_consts_float)] #![feature(ptr_metadata)] #![feature(slice_ptr_get)] #![feature(str_internals)] @@ -166,7 +166,8 @@ #![feature(derive_default_enum)] #![feature(doc_cfg)] #![feature(doc_notable_trait)] -#![feature(doc_primitive)] +#![cfg_attr(bootstrap, feature(doc_primitive))] +#![cfg_attr(not(bootstrap), feature(rustdoc_internals))] #![feature(exhaustive_patterns)] #![feature(doc_cfg_hide)] #![feature(extern_types)] diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 7330c86a11a..5efa04f7e5c 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -180,8 +180,9 @@ impl Duration { /// ``` #[stable(feature = "duration", since = "1.3.0")] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] #[must_use] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_panic))] pub const fn new(secs: u64, nanos: u32) -> Duration { let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) { Some(secs) => secs, @@ -480,7 +481,8 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_panic))] pub const fn checked_add(self, rhs: Duration) -> Option<Duration> { if let Some(mut secs) = self.secs.checked_add(rhs.secs) { let mut nanos = self.nanos + rhs.nanos; @@ -515,7 +517,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] pub const fn saturating_add(self, rhs: Duration) -> Duration { match self.checked_add(rhs) { Some(res) => res, @@ -540,7 +542,8 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_panic))] pub const fn checked_sub(self, rhs: Duration) -> Option<Duration> { if let Some(mut secs) = self.secs.checked_sub(rhs.secs) { let nanos = if self.nanos >= rhs.nanos { @@ -573,7 +576,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] pub const fn saturating_sub(self, rhs: Duration) -> Duration { match self.checked_sub(rhs) { Some(res) => res, @@ -598,7 +601,8 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_panic))] pub const fn checked_mul(self, rhs: u32) -> Option<Duration> { // Multiply nanoseconds as u64, because it cannot overflow that way. let total_nanos = self.nanos as u64 * rhs as u64; @@ -629,7 +633,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] pub const fn saturating_mul(self, rhs: u32) -> Duration { match self.checked_mul(rhs) { Some(res) => res, @@ -655,7 +659,8 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] + #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_panic))] pub const fn checked_div(self, rhs: u32) -> Option<Duration> { if rhs != 0 { let secs = self.secs / (rhs as u64); @@ -683,7 +688,7 @@ impl Duration { #[stable(feature = "duration_float", since = "1.38.0")] #[must_use] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn as_secs_f64(&self) -> f64 { (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) } @@ -702,7 +707,7 @@ impl Duration { #[stable(feature = "duration_float", since = "1.38.0")] #[must_use] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn as_secs_f32(&self) -> f32 { (self.secs as f32) + (self.nanos as f32) / (NANOS_PER_SEC as f32) } @@ -723,7 +728,7 @@ impl Duration { #[stable(feature = "duration_float", since = "1.38.0")] #[must_use] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn from_secs_f64(secs: f64) -> Duration { match Duration::try_from_secs_f64(secs) { Ok(v) => v, @@ -784,7 +789,7 @@ impl Duration { #[stable(feature = "duration_float", since = "1.38.0")] #[must_use] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn from_secs_f32(secs: f32) -> Duration { match Duration::try_from_secs_f32(secs) { Ok(v) => v, @@ -846,7 +851,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn mul_f64(self, rhs: f64) -> Duration { Duration::from_secs_f64(rhs * self.as_secs_f64()) } @@ -870,7 +875,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn mul_f32(self, rhs: f32) -> Duration { Duration::from_secs_f32(rhs * self.as_secs_f32()) } @@ -893,7 +898,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn div_f64(self, rhs: f64) -> Duration { Duration::from_secs_f64(self.as_secs_f64() / rhs) } @@ -918,7 +923,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn div_f32(self, rhs: f32) -> Duration { Duration::from_secs_f32(self.as_secs_f32() / rhs) } @@ -938,7 +943,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn div_duration_f64(self, rhs: Duration) -> f64 { self.as_secs_f64() / rhs.as_secs_f64() } @@ -958,7 +963,7 @@ impl Duration { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] - #[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")] + #[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")] pub const fn div_duration_f32(self, rhs: Duration) -> f32 { self.as_secs_f32() / rhs.as_secs_f32() } diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index a56a1dbd17a..4563c2085c1 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -21,7 +21,7 @@ #![feature(core_private_diy_float)] #![feature(dec2flt)] #![feature(div_duration)] -#![feature(duration_consts_2)] +#![feature(duration_consts_float)] #![feature(duration_constants)] #![feature(exact_size_is_empty)] #![feature(extern_types)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index afd8d8edaa1..504c3b7e9f9 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -275,10 +275,11 @@ #![feature(decl_macro)] #![feature(doc_cfg)] #![feature(doc_cfg_hide)] -#![feature(doc_keyword)] +#![cfg_attr(bootstrap, feature(doc_primitive))] +#![cfg_attr(bootstrap, feature(doc_keyword))] +#![cfg_attr(not(bootstrap), feature(rustdoc_internals))] #![feature(doc_masked)] #![feature(doc_notable_trait)] -#![feature(doc_primitive)] #![feature(dropck_eyepatch)] #![feature(duration_checked_float)] #![feature(duration_constants)] diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index 094d2efbdd5..67b747e4107 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -4,15 +4,23 @@ use super::{Command, Output, Stdio}; use crate::io::ErrorKind; use crate::str; -// FIXME(#10380) these tests should not all be ignored on android. +#[cfg(target_os = "android")] +fn shell_cmd() -> Command { + Command::new("/system/bin/sh") +} + +#[cfg(not(target_os = "android"))] +fn shell_cmd() -> Command { + Command::new("/bin/sh") +} #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn smoke() { let p = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "exit 0"]).spawn() } else { - Command::new("true").spawn() + shell_cmd().arg("-c").arg("true").spawn() }; assert!(p.is_ok()); let mut p = p.unwrap(); @@ -29,12 +37,12 @@ fn smoke_failure() { } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn exit_reported_right() { let p = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "exit 1"]).spawn() } else { - Command::new("false").spawn() + shell_cmd().arg("-c").arg("false").spawn() }; assert!(p.is_ok()); let mut p = p.unwrap(); @@ -44,12 +52,11 @@ fn exit_reported_right() { #[test] #[cfg(unix)] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn signal_reported_right() { use crate::os::unix::process::ExitStatusExt; - let mut p = - Command::new("/bin/sh").arg("-c").arg("read a").stdin(Stdio::piped()).spawn().unwrap(); + let mut p = shell_cmd().arg("-c").arg("read a").stdin(Stdio::piped()).spawn().unwrap(); p.kill().unwrap(); match p.wait().unwrap().signal() { Some(9) => {} @@ -69,31 +76,31 @@ pub fn run_output(mut cmd: Command) -> String { } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn stdout_works() { if cfg!(target_os = "windows") { let mut cmd = Command::new("cmd"); cmd.args(&["/C", "echo foobar"]).stdout(Stdio::piped()); assert_eq!(run_output(cmd), "foobar\r\n"); } else { - let mut cmd = Command::new("echo"); - cmd.arg("foobar").stdout(Stdio::piped()); + let mut cmd = shell_cmd(); + cmd.arg("-c").arg("echo foobar").stdout(Stdio::piped()); assert_eq!(run_output(cmd), "foobar\n"); } } #[test] -#[cfg_attr(any(windows, target_os = "android", target_os = "vxworks"), ignore)] +#[cfg_attr(any(windows, target_os = "vxworks"), ignore)] fn set_current_dir_works() { - let mut cmd = Command::new("/bin/sh"); + let mut cmd = shell_cmd(); cmd.arg("-c").arg("pwd").current_dir("/").stdout(Stdio::piped()); assert_eq!(run_output(cmd), "/\n"); } #[test] -#[cfg_attr(any(windows, target_os = "android", target_os = "vxworks"), ignore)] +#[cfg_attr(any(windows, target_os = "vxworks"), ignore)] fn stdin_works() { - let mut p = Command::new("/bin/sh") + let mut p = shell_cmd() .arg("-c") .arg("read line; echo $line") .stdin(Stdio::piped()) @@ -109,19 +116,19 @@ fn stdin_works() { } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn test_process_status() { let mut status = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "exit 1"]).status().unwrap() } else { - Command::new("false").status().unwrap() + shell_cmd().arg("-c").arg("false").status().unwrap() }; assert!(status.code() == Some(1)); status = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "exit 0"]).status().unwrap() } else { - Command::new("true").status().unwrap() + shell_cmd().arg("-c").arg("true").status().unwrap() }; assert!(status.success()); } @@ -135,12 +142,12 @@ fn test_process_output_fail_to_start() { } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn test_process_output_output() { let Output { status, stdout, stderr } = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "echo hello"]).output().unwrap() } else { - Command::new("echo").arg("hello").output().unwrap() + shell_cmd().arg("-c").arg("echo hello").output().unwrap() }; let output_str = str::from_utf8(&stdout).unwrap(); @@ -150,7 +157,7 @@ fn test_process_output_output() { } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn test_process_output_error() { let Output { status, stdout, stderr } = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "mkdir ."]).output().unwrap() @@ -158,41 +165,42 @@ fn test_process_output_error() { Command::new("mkdir").arg("./").output().unwrap() }; - assert!(status.code() == Some(1)); + assert!(status.code().is_some()); + assert!(status.code() != Some(0)); assert_eq!(stdout, Vec::new()); assert!(!stderr.is_empty()); } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn test_finish_once() { let mut prog = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "exit 1"]).spawn().unwrap() } else { - Command::new("false").spawn().unwrap() + shell_cmd().arg("-c").arg("false").spawn().unwrap() }; assert!(prog.wait().unwrap().code() == Some(1)); } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn test_finish_twice() { let mut prog = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "exit 1"]).spawn().unwrap() } else { - Command::new("false").spawn().unwrap() + shell_cmd().arg("-c").arg("false").spawn().unwrap() }; assert!(prog.wait().unwrap().code() == Some(1)); assert!(prog.wait().unwrap().code() == Some(1)); } #[test] -#[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] +#[cfg_attr(any(target_os = "vxworks"), ignore)] fn test_wait_with_output_once() { let prog = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "echo hello"]).stdout(Stdio::piped()).spawn().unwrap() } else { - Command::new("echo").arg("hello").stdout(Stdio::piped()).spawn().unwrap() + shell_cmd().arg("-c").arg("echo hello").stdout(Stdio::piped()).spawn().unwrap() }; let Output { status, stdout, stderr } = prog.wait_with_output().unwrap(); |
