about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2020-08-20 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2020-08-21 13:17:20 +0200
commit4a00421ba4daae419d06b67bd1bb46d7930b0dc7 (patch)
treed047e2c2fce8a6171532a1671e1363227bbd4eed
parent479c23bb493e4ea801c125cfc54e70723a9aeeb5 (diff)
downloadrust-4a00421ba4daae419d06b67bd1bb46d7930b0dc7.tar.gz
rust-4a00421ba4daae419d06b67bd1bb46d7930b0dc7.zip
Make raw standard stream constructors const
-rw-r--r--library/std/src/io/stdio.rs9
-rw-r--r--library/std/src/sys/cloudabi/stdio.rs6
-rw-r--r--library/std/src/sys/hermit/stdio.rs6
-rw-r--r--library/std/src/sys/sgx/stdio.rs6
-rw-r--r--library/std/src/sys/unix/stdio.rs6
-rw-r--r--library/std/src/sys/unsupported/stdio.rs6
-rw-r--r--library/std/src/sys/vxworks/stdio.rs6
-rw-r--r--library/std/src/sys/wasi/stdio.rs6
-rw-r--r--library/std/src/sys/windows/stdio.rs6
-rw-r--r--library/std/src/sys/windows/stdio_uwp.rs6
10 files changed, 33 insertions, 30 deletions
diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs
index f91264af531..c68d5980800 100644
--- a/library/std/src/io/stdio.rs
+++ b/library/std/src/io/stdio.rs
@@ -50,7 +50,8 @@ struct StderrRaw(stdio::Stderr);
 /// handles is **not** available to raw handles returned from this function.
 ///
 /// The returned handle has no external synchronization or buffering.
-fn stdin_raw() -> StdinRaw {
+#[unstable(feature = "libstd_sys_internals", issue = "none")]
+const fn stdin_raw() -> StdinRaw {
     StdinRaw(stdio::Stdin::new())
 }
 
@@ -63,7 +64,8 @@ fn stdin_raw() -> StdinRaw {
 ///
 /// The returned handle has no external synchronization or buffering layered on
 /// top.
-fn stdout_raw() -> StdoutRaw {
+#[unstable(feature = "libstd_sys_internals", issue = "none")]
+const fn stdout_raw() -> StdoutRaw {
     StdoutRaw(stdio::Stdout::new())
 }
 
@@ -74,7 +76,8 @@ fn stdout_raw() -> StdoutRaw {
 ///
 /// The returned handle has no external synchronization or buffering layered on
 /// top.
-fn stderr_raw() -> StderrRaw {
+#[unstable(feature = "libstd_sys_internals", issue = "none")]
+const fn stderr_raw() -> StderrRaw {
     StderrRaw(stdio::Stderr::new())
 }
 
diff --git a/library/std/src/sys/cloudabi/stdio.rs b/library/std/src/sys/cloudabi/stdio.rs
index d564f4f7f40..7fec4731a46 100644
--- a/library/std/src/sys/cloudabi/stdio.rs
+++ b/library/std/src/sys/cloudabi/stdio.rs
@@ -6,7 +6,7 @@ pub struct Stdout(());
 pub struct Stderr(());
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin(())
     }
 }
@@ -18,7 +18,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout(())
     }
 }
@@ -37,7 +37,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr(())
     }
 }
diff --git a/library/std/src/sys/hermit/stdio.rs b/library/std/src/sys/hermit/stdio.rs
index 359ea13c2be..82304dd6dc2 100644
--- a/library/std/src/sys/hermit/stdio.rs
+++ b/library/std/src/sys/hermit/stdio.rs
@@ -7,7 +7,7 @@ pub struct Stdout;
 pub struct Stderr;
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin
     }
 }
@@ -28,7 +28,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout
     }
 }
@@ -69,7 +69,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr
     }
 }
diff --git a/library/std/src/sys/sgx/stdio.rs b/library/std/src/sys/sgx/stdio.rs
index d771a39ea85..49f44f9f498 100644
--- a/library/std/src/sys/sgx/stdio.rs
+++ b/library/std/src/sys/sgx/stdio.rs
@@ -19,7 +19,7 @@ fn with_std_fd<F: FnOnce(&FileDesc) -> R, R>(fd: abi::Fd, f: F) -> R {
 }
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin(())
     }
 }
@@ -31,7 +31,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout(())
     }
 }
@@ -47,7 +47,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr(())
     }
 }
diff --git a/library/std/src/sys/unix/stdio.rs b/library/std/src/sys/unix/stdio.rs
index bbf5dd65fa5..a05fe8165cf 100644
--- a/library/std/src/sys/unix/stdio.rs
+++ b/library/std/src/sys/unix/stdio.rs
@@ -7,7 +7,7 @@ pub struct Stdout(());
 pub struct Stderr(());
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin(())
     }
 }
@@ -28,7 +28,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout(())
     }
 }
@@ -53,7 +53,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr(())
     }
 }
diff --git a/library/std/src/sys/unsupported/stdio.rs b/library/std/src/sys/unsupported/stdio.rs
index 7e60e0712dd..b5e3f5be988 100644
--- a/library/std/src/sys/unsupported/stdio.rs
+++ b/library/std/src/sys/unsupported/stdio.rs
@@ -5,7 +5,7 @@ pub struct Stdout;
 pub struct Stderr;
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin
     }
 }
@@ -17,7 +17,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout
     }
 }
@@ -33,7 +33,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr
     }
 }
diff --git a/library/std/src/sys/vxworks/stdio.rs b/library/std/src/sys/vxworks/stdio.rs
index e99d2d58346..92e9f205b4e 100644
--- a/library/std/src/sys/vxworks/stdio.rs
+++ b/library/std/src/sys/vxworks/stdio.rs
@@ -6,7 +6,7 @@ pub struct Stdout(());
 pub struct Stderr(());
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin(())
     }
 }
@@ -21,7 +21,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout(())
     }
 }
@@ -40,7 +40,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr(())
     }
 }
diff --git a/library/std/src/sys/wasi/stdio.rs b/library/std/src/sys/wasi/stdio.rs
index cc27e2ee583..23baafabf79 100644
--- a/library/std/src/sys/wasi/stdio.rs
+++ b/library/std/src/sys/wasi/stdio.rs
@@ -7,7 +7,7 @@ pub struct Stdout;
 pub struct Stderr;
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin
     }
 
@@ -33,7 +33,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout
     }
 
@@ -62,7 +62,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr
     }
 
diff --git a/library/std/src/sys/windows/stdio.rs b/library/std/src/sys/windows/stdio.rs
index b2e5458c0d2..ff214497166 100644
--- a/library/std/src/sys/windows/stdio.rs
+++ b/library/std/src/sys/windows/stdio.rs
@@ -131,7 +131,7 @@ fn write_u16s(handle: c::HANDLE, data: &[u16]) -> io::Result<usize> {
 }
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin { surrogate: 0 }
     }
 }
@@ -255,7 +255,7 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result<usize> {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout
     }
 }
@@ -271,7 +271,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr
     }
 }
diff --git a/library/std/src/sys/windows/stdio_uwp.rs b/library/std/src/sys/windows/stdio_uwp.rs
index 0016f5dcd01..872511af862 100644
--- a/library/std/src/sys/windows/stdio_uwp.rs
+++ b/library/std/src/sys/windows/stdio_uwp.rs
@@ -30,7 +30,7 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
 }
 
 impl Stdin {
-    pub fn new() -> Stdin {
+    pub const fn new() -> Stdin {
         Stdin {}
     }
 }
@@ -44,7 +44,7 @@ impl io::Read for Stdin {
 }
 
 impl Stdout {
-    pub fn new() -> Stdout {
+    pub const fn new() -> Stdout {
         Stdout
     }
 }
@@ -60,7 +60,7 @@ impl io::Write for Stdout {
 }
 
 impl Stderr {
-    pub fn new() -> Stderr {
+    pub const fn new() -> Stderr {
         Stderr
     }
 }