authorbors <bors@rust-lang.org> 2025-03-13 10:27:30 UTC
committerbors <bors@rust-lang.org> 2025-03-13 10:27:30 UTC
loga2aba0578ba440130d2ee213fc9dfdaa7095bdb5
tree58d1d86e73a6dab6d4eefb07876db427ce9834af
parent961351c76c812e3aeb65bfb542742500a6436aed
parent3bfce83cb2e880a7f2a601326a56a57abaf6bd8c

Auto merge of #138448 - matthiaskrgr:rollup-3onhkse, r=matthiaskrgr

Rollup of 8 pull requests Successful merges: - #126856 (remove deprecated tool `rls`) - #133981 (rustdoc-json: Refractor and document Id's) - #136842 (Add libstd support for Trusty targets) - #137355 (Implement `read_buf` and vectored read/write for SGX stdio) - #138162 (Update the standard library to Rust 2024) - #138273 (metadata: Ignore sysroot when doing the manual native lib search in rustc) - #138346 (naked functions: on windows emit `.endef` without the symbol name) - #138370 (Simulate OOM for the `try_oom_error` test) r? `@ghost` `@rustbot` modify labels: rollup

74 files changed, 560 insertions(+), 406 deletions(-)

Cargo.lock-7
...@@ -3045,13 +3045,6 @@ dependencies = [...@@ -3045,13 +3045,6 @@ dependencies = [
3045 "serde",3045 "serde",
3046]3046]
30473047
3048[[package]]
3049name = "rls"
3050version = "2.0.0"
3051dependencies = [
3052 "serde_json",
3053]
3054
3055[[package]]3048[[package]]
3056name = "run_make_support"3049name = "run_make_support"
3057version = "0.2.0"3050version = "0.2.0"
Cargo.toml-1
...@@ -24,7 +24,6 @@ members = [...@@ -24,7 +24,6 @@ members = [
24 "src/tools/remote-test-server",24 "src/tools/remote-test-server",
25 "src/tools/rust-installer",25 "src/tools/rust-installer",
26 "src/tools/rustdoc",26 "src/tools/rustdoc",
27 "src/tools/rls",
28 "src/tools/rustfmt",27 "src/tools/rustfmt",
29 "src/tools/miri",28 "src/tools/miri",
30 "src/tools/miri/cargo-miri",29 "src/tools/miri/cargo-miri",
compiler/rustc_codegen_ssa/src/back/link.rs+12-14
...@@ -22,7 +22,9 @@ use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};...@@ -22,7 +22,9 @@ use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
22use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};22use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
23use rustc_macros::LintDiagnostic;23use rustc_macros::LintDiagnostic;
24use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};24use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};
25use rustc_metadata::{find_native_static_library, walk_native_lib_search_dirs};25use rustc_metadata::{
26 NativeLibSearchFallback, find_native_static_library, walk_native_lib_search_dirs,
27};
26use rustc_middle::bug;28use rustc_middle::bug;
27use rustc_middle::lint::lint_level;29use rustc_middle::lint::lint_level;
28use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;30use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
...@@ -2129,19 +2131,15 @@ fn add_library_search_dirs(...@@ -2129,19 +2131,15 @@ fn add_library_search_dirs(
2129 return;2131 return;
2130 }2132 }
21312133
2132 walk_native_lib_search_dirs(2134 let fallback = Some(NativeLibSearchFallback { self_contained_components, apple_sdk_root });
2133 sess,2135 walk_native_lib_search_dirs(sess, fallback, |dir, is_framework| {
2134 self_contained_components,2136 if is_framework {
2135 apple_sdk_root,2137 cmd.framework_path(dir);
2136 |dir, is_framework| {2138 } else {
2137 if is_framework {2139 cmd.include_path(&fix_windows_verbatim_for_gcc(dir));
2138 cmd.framework_path(dir);2140 }
2139 } else {2141 ControlFlow::<()>::Continue(())
2140 cmd.include_path(&fix_windows_verbatim_for_gcc(dir));2142 });
2141 }
2142 ControlFlow::<()>::Continue(())
2143 },
2144 );
2145}2143}
21462144
2147/// Add options making relocation sections in the produced ELF files read-only2145/// Add options making relocation sections in the produced ELF files read-only
compiler/rustc_codegen_ssa/src/mir/naked_asm.rs+1-1
...@@ -245,7 +245,7 @@ fn prefix_and_suffix<'tcx>(...@@ -245,7 +245,7 @@ fn prefix_and_suffix<'tcx>(
245 writeln!(begin, ".def {asm_name}").unwrap();245 writeln!(begin, ".def {asm_name}").unwrap();
246 writeln!(begin, ".scl 2").unwrap();246 writeln!(begin, ".scl 2").unwrap();
247 writeln!(begin, ".type 32").unwrap();247 writeln!(begin, ".type 32").unwrap();
248 writeln!(begin, ".endef {asm_name}").unwrap();248 writeln!(begin, ".endef").unwrap();
249 writeln!(begin, "{asm_name}:").unwrap();249 writeln!(begin, "{asm_name}:").unwrap();
250250
251 writeln!(end).unwrap();251 writeln!(end).unwrap();
compiler/rustc_metadata/src/lib.rs+2-2
...@@ -35,8 +35,8 @@ pub mod locator;...@@ -35,8 +35,8 @@ pub mod locator;
35pub use creader::{DylibError, load_symbol_from_dylib};35pub use creader::{DylibError, load_symbol_from_dylib};
36pub use fs::{METADATA_FILENAME, emit_wrapper_file};36pub use fs::{METADATA_FILENAME, emit_wrapper_file};
37pub use native_libs::{37pub use native_libs::{
38 find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library,38 NativeLibSearchFallback, find_native_static_library, try_find_native_dynamic_library,
39 walk_native_lib_search_dirs,39 try_find_native_static_library, walk_native_lib_search_dirs,
40};40};
41pub use rmeta::{EncodedMetadata, METADATA_HEADER, encode_metadata, rendered_const};41pub use rmeta::{EncodedMetadata, METADATA_HEADER, encode_metadata, rendered_const};
4242
compiler/rustc_metadata/src/native_libs.rs+32-31
...@@ -21,10 +21,17 @@ use rustc_target::spec::{BinaryFormat, LinkSelfContainedComponents};...@@ -21,10 +21,17 @@ use rustc_target::spec::{BinaryFormat, LinkSelfContainedComponents};
2121
22use crate::{errors, fluent_generated};22use crate::{errors, fluent_generated};
2323
24/// The fallback directories are passed to linker, but not used when rustc does the search,
25/// because in the latter case the set of fallback directories cannot always be determined
26/// consistently at the moment.
27pub struct NativeLibSearchFallback<'a> {
28 pub self_contained_components: LinkSelfContainedComponents,
29 pub apple_sdk_root: Option<&'a Path>,
30}
31
24pub fn walk_native_lib_search_dirs<R>(32pub fn walk_native_lib_search_dirs<R>(
25 sess: &Session,33 sess: &Session,
26 self_contained_components: LinkSelfContainedComponents,34 fallback: Option<NativeLibSearchFallback<'_>>,
27 apple_sdk_root: Option<&Path>,
28 mut f: impl FnMut(&Path, bool /*is_framework*/) -> ControlFlow<R>,35 mut f: impl FnMut(&Path, bool /*is_framework*/) -> ControlFlow<R>,
29) -> ControlFlow<R> {36) -> ControlFlow<R> {
30 // Library search paths explicitly supplied by user (`-L` on the command line).37 // Library search paths explicitly supplied by user (`-L` on the command line).
...@@ -38,6 +45,11 @@ pub fn walk_native_lib_search_dirs<R>(...@@ -38,6 +45,11 @@ pub fn walk_native_lib_search_dirs<R>(
38 }45 }
39 }46 }
4047
48 let Some(NativeLibSearchFallback { self_contained_components, apple_sdk_root }) = fallback
49 else {
50 return ControlFlow::Continue(());
51 };
52
41 // The toolchain ships some native library components and self-contained linking was enabled.53 // The toolchain ships some native library components and self-contained linking was enabled.
42 // Add the self-contained library directory to search paths.54 // Add the self-contained library directory to search paths.
43 if self_contained_components.intersects(55 if self_contained_components.intersects(
...@@ -93,23 +105,17 @@ pub fn try_find_native_static_library(...@@ -93,23 +105,17 @@ pub fn try_find_native_static_library(
93 if os == unix { vec![os] } else { vec![os, unix] }105 if os == unix { vec![os] } else { vec![os, unix] }
94 };106 };
95107
96 // FIXME: Account for self-contained linking settings and Apple SDK.108 walk_native_lib_search_dirs(sess, None, |dir, is_framework| {
97 walk_native_lib_search_dirs(109 if !is_framework {
98 sess,110 for (prefix, suffix) in &formats {
99 LinkSelfContainedComponents::empty(),111 let test = dir.join(format!("{prefix}{name}{suffix}"));
100 None,112 if test.exists() {
101 |dir, is_framework| {113 return ControlFlow::Break(test);
102 if !is_framework {
103 for (prefix, suffix) in &formats {
104 let test = dir.join(format!("{prefix}{name}{suffix}"));
105 if test.exists() {
106 return ControlFlow::Break(test);
107 }
108 }114 }
109 }115 }
110 ControlFlow::Continue(())116 }
111 },117 ControlFlow::Continue(())
112 )118 })
113 .break_value()119 .break_value()
114}120}
115121
...@@ -132,22 +138,17 @@ pub fn try_find_native_dynamic_library(...@@ -132,22 +138,17 @@ pub fn try_find_native_dynamic_library(
132 vec![os, meson, mingw]138 vec![os, meson, mingw]
133 };139 };
134140
135 walk_native_lib_search_dirs(141 walk_native_lib_search_dirs(sess, None, |dir, is_framework| {
136 sess,142 if !is_framework {
137 LinkSelfContainedComponents::empty(),143 for (prefix, suffix) in &formats {
138 None,144 let test = dir.join(format!("{prefix}{name}{suffix}"));
139 |dir, is_framework| {145 if test.exists() {
140 if !is_framework {146 return ControlFlow::Break(test);
141 for (prefix, suffix) in &formats {
142 let test = dir.join(format!("{prefix}{name}{suffix}"));
143 if test.exists() {
144 return ControlFlow::Break(test);
145 }
146 }147 }
147 }148 }
148 ControlFlow::Continue(())149 }
149 },150 ControlFlow::Continue(())
150 )151 })
151 .break_value()152 .break_value()
152}153}
153154
library/alloc/Cargo.toml+1-1
...@@ -8,7 +8,7 @@ repository = "https://github.com/rust-lang/rust.git"...@@ -8,7 +8,7 @@ repository = "https://github.com/rust-lang/rust.git"
8description = "The Rust core allocation and collections library"8description = "The Rust core allocation and collections library"
9autotests = false9autotests = false
10autobenches = false10autobenches = false
11edition = "2021"11edition = "2024"
1212
13[lib]13[lib]
14test = false14test = false
library/core/Cargo.toml+1-1
...@@ -9,7 +9,7 @@ autobenches = false...@@ -9,7 +9,7 @@ autobenches = false
9# If you update this, be sure to update it in a bunch of other places too!9# If you update this, be sure to update it in a bunch of other places too!
10# As of 2024, it was src/tools/opt-dist, the core-no-fp-fmt-parse test and10# As of 2024, it was src/tools/opt-dist, the core-no-fp-fmt-parse test and
11# the version of the prelude imported in core/lib.rs.11# the version of the prelude imported in core/lib.rs.
12edition = "2021"12edition = "2024"
1313
14[lib]14[lib]
15test = false15test = false
library/core/src/lib.rs+1-1
...@@ -226,7 +226,7 @@ extern crate self as core;...@@ -226,7 +226,7 @@ extern crate self as core;
226226
227#[prelude_import]227#[prelude_import]
228#[allow(unused)]228#[allow(unused)]
229use prelude::rust_2021::*;229use prelude::rust_2024::*;
230230
231#[cfg(not(test))] // See #65860231#[cfg(not(test))] // See #65860
232#[macro_use]232#[macro_use]
library/panic_abort/Cargo.toml+1-1
...@@ -4,7 +4,7 @@ version = "0.0.0"...@@ -4,7 +4,7 @@ version = "0.0.0"
4license = "MIT OR Apache-2.0"4license = "MIT OR Apache-2.0"
5repository = "https://github.com/rust-lang/rust.git"5repository = "https://github.com/rust-lang/rust.git"
6description = "Implementation of Rust panics via process aborts"6description = "Implementation of Rust panics via process aborts"
7edition = "2021"7edition = "2024"
88
9[lib]9[lib]
10test = false10test = false
library/panic_unwind/Cargo.toml+1-1
...@@ -4,7 +4,7 @@ version = "0.0.0"...@@ -4,7 +4,7 @@ version = "0.0.0"
4license = "MIT OR Apache-2.0"4license = "MIT OR Apache-2.0"
5repository = "https://github.com/rust-lang/rust.git"5repository = "https://github.com/rust-lang/rust.git"
6description = "Implementation of Rust panics via stack unwinding"6description = "Implementation of Rust panics via stack unwinding"
7edition = "2021"7edition = "2024"
88
9[lib]9[lib]
10test = false10test = false
library/proc_macro/Cargo.toml+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1[package]1[package]
2name = "proc_macro"2name = "proc_macro"
3version = "0.0.0"3version = "0.0.0"
4edition = "2021"4edition = "2024"
55
6[dependencies]6[dependencies]
7std = { path = "../std" }7std = { path = "../std" }
library/profiler_builtins/Cargo.toml+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1[package]1[package]
2name = "profiler_builtins"2name = "profiler_builtins"
3version = "0.0.0"3version = "0.0.0"
4edition = "2021"4edition = "2024"
55
6[lib]6[lib]
7test = false7test = false
library/rustc-std-workspace-alloc/Cargo.toml+1-1
...@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'...@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
5description = """5description = """
6Hack for the compiler's own build system6Hack for the compiler's own build system
7"""7"""
8edition = "2021"8edition = "2024"
99
10[lib]10[lib]
11path = "lib.rs"11path = "lib.rs"
library/rustc-std-workspace-core/Cargo.toml+1-1
...@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'...@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
5description = """5description = """
6Hack for the compiler's own build system6Hack for the compiler's own build system
7"""7"""
8edition = "2021"8edition = "2024"
99
10[lib]10[lib]
11path = "lib.rs"11path = "lib.rs"
library/rustc-std-workspace-std/Cargo.toml+1-1
...@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'...@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
5description = """5description = """
6Hack for the compiler's own build system6Hack for the compiler's own build system
7"""7"""
8edition = "2021"8edition = "2024"
99
10[lib]10[lib]
11path = "lib.rs"11path = "lib.rs"
library/std/Cargo.toml+1-1
...@@ -6,7 +6,7 @@ version = "0.0.0"...@@ -6,7 +6,7 @@ version = "0.0.0"
6license = "MIT OR Apache-2.0"6license = "MIT OR Apache-2.0"
7repository = "https://github.com/rust-lang/rust.git"7repository = "https://github.com/rust-lang/rust.git"
8description = "The Rust Standard Library"8description = "The Rust Standard Library"
9edition = "2021"9edition = "2024"
10autobenches = false10autobenches = false
1111
12[lib]12[lib]
library/std/build.rs+1
...@@ -42,6 +42,7 @@ fn main() {...@@ -42,6 +42,7 @@ fn main() {
42 || target_os == "fuchsia"42 || target_os == "fuchsia"
43 || (target_vendor == "fortanix" && target_env == "sgx")43 || (target_vendor == "fortanix" && target_env == "sgx")
44 || target_os == "hermit"44 || target_os == "hermit"
45 || target_os == "trusty"
45 || target_os == "l4re"46 || target_os == "l4re"
46 || target_os == "redox"47 || target_os == "redox"
47 || target_os == "haiku"48 || target_os == "haiku"
library/std/src/fs.rs+2-1
...@@ -14,7 +14,8 @@...@@ -14,7 +14,8 @@
14 target_os = "emscripten",14 target_os = "emscripten",
15 target_os = "wasi",15 target_os = "wasi",
16 target_env = "sgx",16 target_env = "sgx",
17 target_os = "xous"17 target_os = "xous",
18 target_os = "trusty",
18 ))19 ))
19))]20))]
20mod tests;21mod tests;
library/std/src/io/tests.rs+10-6
...@@ -811,13 +811,17 @@ fn read_to_end_error() {...@@ -811,13 +811,17 @@ fn read_to_end_error() {
811}811}
812812
813#[test]813#[test]
814// Miri does not support signalling OOM
815#[cfg_attr(miri, ignore)]
816// 64-bit only to be sure the allocator will fail fast on an impossible to satisfy size
817#[cfg(target_pointer_width = "64")]
818fn try_oom_error() {814fn try_oom_error() {
819 let mut v = Vec::<u8>::new();815 use alloc::alloc::Layout;
820 let reserve_err = v.try_reserve(isize::MAX as usize - 1).unwrap_err();816 use alloc::collections::{TryReserveError, TryReserveErrorKind};
817
818 // We simulate a `Vec::try_reserve` error rather than attempting a huge size for real. This way
819 // we're not subject to the whims of optimization that might skip the actual allocation, and it
820 // also works for 32-bit targets and miri that might not OOM at all.
821 let layout = Layout::new::<u8>();
822 let kind = TryReserveErrorKind::AllocError { layout, non_exhaustive: () };
823 let reserve_err = TryReserveError::from(kind);
824
821 let io_err = io::Error::from(reserve_err);825 let io_err = io::Error::from(reserve_err);
822 assert_eq!(io::ErrorKind::OutOfMemory, io_err.kind());826 assert_eq!(io::ErrorKind::OutOfMemory, io_err.kind());
823}827}
library/std/src/keyword_docs.rs+1-1
...@@ -1064,7 +1064,7 @@ mod move_keyword {}...@@ -1064,7 +1064,7 @@ mod move_keyword {}
1064/// ```rust,compile_fail,E05021064/// ```rust,compile_fail,E0502
1065/// let mut v = vec![0, 1];1065/// let mut v = vec![0, 1];
1066/// let mut_ref_v = &mut v;1066/// let mut_ref_v = &mut v;
1067/// ##[allow(unused)]1067/// # #[allow(unused)]
1068/// let ref_v = &v;1068/// let ref_v = &v;
1069/// mut_ref_v.push(2);1069/// mut_ref_v.push(2);
1070/// ```1070/// ```
library/std/src/net/tcp.rs+2-1
...@@ -5,7 +5,8 @@...@@ -5,7 +5,8 @@
5 not(any(5 not(any(
6 target_os = "emscripten",6 target_os = "emscripten",
7 all(target_os = "wasi", target_env = "p1"),7 all(target_os = "wasi", target_env = "p1"),
8 target_os = "xous"8 target_os = "xous",
9 target_os = "trusty",
9 ))10 ))
10))]11))]
11mod tests;12mod tests;
library/std/src/net/udp.rs+2-1
...@@ -4,7 +4,8 @@...@@ -4,7 +4,8 @@
4 target_os = "emscripten",4 target_os = "emscripten",
5 all(target_os = "wasi", target_env = "p1"),5 all(target_os = "wasi", target_env = "p1"),
6 target_env = "sgx",6 target_env = "sgx",
7 target_os = "xous"7 target_os = "xous",
8 target_os = "trusty",
8 ))9 ))
9))]10))]
10mod tests;11mod tests;
library/std/src/os/fd/mod.rs+1
...@@ -13,6 +13,7 @@ mod raw;...@@ -13,6 +13,7 @@ mod raw;
13mod owned;13mod owned;
1414
15// Implementations for `AsRawFd` etc. for network types.15// Implementations for `AsRawFd` etc. for network types.
16#[cfg(not(target_os = "trusty"))]
16mod net;17mod net;
1718
18#[cfg(test)]19#[cfg(test)]
library/std/src/os/fd/owned.rs+24-4
...@@ -4,12 +4,20 @@...@@ -4,12 +4,20 @@
4#![deny(unsafe_op_in_unsafe_fn)]4#![deny(unsafe_op_in_unsafe_fn)]
55
6use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd};6use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
7#[cfg(not(target_os = "trusty"))]
8use crate::fs;
7use crate::marker::PhantomData;9use crate::marker::PhantomData;
8use crate::mem::ManuallyDrop;10use crate::mem::ManuallyDrop;
9#[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit")))]11#[cfg(not(any(
12 target_arch = "wasm32",
13 target_env = "sgx",
14 target_os = "hermit",
15 target_os = "trusty"
16)))]
10use crate::sys::cvt;17use crate::sys::cvt;
18#[cfg(not(target_os = "trusty"))]
11use crate::sys_common::{AsInner, FromInner, IntoInner};19use crate::sys_common::{AsInner, FromInner, IntoInner};
12use crate::{fmt, fs, io};20use crate::{fmt, io};
1321
14type ValidRawFd = core::num::niche_types::NotAllOnes<RawFd>;22type ValidRawFd = core::num::niche_types::NotAllOnes<RawFd>;
1523
...@@ -87,7 +95,7 @@ impl OwnedFd {...@@ -87,7 +95,7 @@ impl OwnedFd {
87impl BorrowedFd<'_> {95impl BorrowedFd<'_> {
88 /// Creates a new `OwnedFd` instance that shares the same underlying file96 /// Creates a new `OwnedFd` instance that shares the same underlying file
89 /// description as the existing `BorrowedFd` instance.97 /// description as the existing `BorrowedFd` instance.
90 #[cfg(not(any(target_arch = "wasm32", target_os = "hermit")))]98 #[cfg(not(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty")))]
91 #[stable(feature = "io_safety", since = "1.63.0")]99 #[stable(feature = "io_safety", since = "1.63.0")]
92 pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {100 pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
93 // We want to atomically duplicate this file descriptor and set the101 // We want to atomically duplicate this file descriptor and set the
...@@ -110,7 +118,7 @@ impl BorrowedFd<'_> {...@@ -110,7 +118,7 @@ impl BorrowedFd<'_> {
110118
111 /// Creates a new `OwnedFd` instance that shares the same underlying file119 /// Creates a new `OwnedFd` instance that shares the same underlying file
112 /// description as the existing `BorrowedFd` instance.120 /// description as the existing `BorrowedFd` instance.
113 #[cfg(any(target_arch = "wasm32", target_os = "hermit"))]121 #[cfg(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty"))]
114 #[stable(feature = "io_safety", since = "1.63.0")]122 #[stable(feature = "io_safety", since = "1.63.0")]
115 pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {123 pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
116 Err(crate::io::Error::UNSUPPORTED_PLATFORM)124 Err(crate::io::Error::UNSUPPORTED_PLATFORM)
...@@ -280,6 +288,7 @@ impl AsFd for OwnedFd {...@@ -280,6 +288,7 @@ impl AsFd for OwnedFd {
280}288}
281289
282#[stable(feature = "io_safety", since = "1.63.0")]290#[stable(feature = "io_safety", since = "1.63.0")]
291#[cfg(not(target_os = "trusty"))]
283impl AsFd for fs::File {292impl AsFd for fs::File {
284 #[inline]293 #[inline]
285 fn as_fd(&self) -> BorrowedFd<'_> {294 fn as_fd(&self) -> BorrowedFd<'_> {
...@@ -288,6 +297,7 @@ impl AsFd for fs::File {...@@ -288,6 +297,7 @@ impl AsFd for fs::File {
288}297}
289298
290#[stable(feature = "io_safety", since = "1.63.0")]299#[stable(feature = "io_safety", since = "1.63.0")]
300#[cfg(not(target_os = "trusty"))]
291impl From<fs::File> for OwnedFd {301impl From<fs::File> for OwnedFd {
292 /// Takes ownership of a [`File`](fs::File)'s underlying file descriptor.302 /// Takes ownership of a [`File`](fs::File)'s underlying file descriptor.
293 #[inline]303 #[inline]
...@@ -297,6 +307,7 @@ impl From<fs::File> for OwnedFd {...@@ -297,6 +307,7 @@ impl From<fs::File> for OwnedFd {
297}307}
298308
299#[stable(feature = "io_safety", since = "1.63.0")]309#[stable(feature = "io_safety", since = "1.63.0")]
310#[cfg(not(target_os = "trusty"))]
300impl From<OwnedFd> for fs::File {311impl From<OwnedFd> for fs::File {
301 /// Returns a [`File`](fs::File) that takes ownership of the given312 /// Returns a [`File`](fs::File) that takes ownership of the given
302 /// file descriptor.313 /// file descriptor.
...@@ -307,6 +318,7 @@ impl From<OwnedFd> for fs::File {...@@ -307,6 +318,7 @@ impl From<OwnedFd> for fs::File {
307}318}
308319
309#[stable(feature = "io_safety", since = "1.63.0")]320#[stable(feature = "io_safety", since = "1.63.0")]
321#[cfg(not(target_os = "trusty"))]
310impl AsFd for crate::net::TcpStream {322impl AsFd for crate::net::TcpStream {
311 #[inline]323 #[inline]
312 fn as_fd(&self) -> BorrowedFd<'_> {324 fn as_fd(&self) -> BorrowedFd<'_> {
...@@ -315,6 +327,7 @@ impl AsFd for crate::net::TcpStream {...@@ -315,6 +327,7 @@ impl AsFd for crate::net::TcpStream {
315}327}
316328
317#[stable(feature = "io_safety", since = "1.63.0")]329#[stable(feature = "io_safety", since = "1.63.0")]
330#[cfg(not(target_os = "trusty"))]
318impl From<crate::net::TcpStream> for OwnedFd {331impl From<crate::net::TcpStream> for OwnedFd {
319 /// Takes ownership of a [`TcpStream`](crate::net::TcpStream)'s socket file descriptor.332 /// Takes ownership of a [`TcpStream`](crate::net::TcpStream)'s socket file descriptor.
320 #[inline]333 #[inline]
...@@ -324,6 +337,7 @@ impl From<crate::net::TcpStream> for OwnedFd {...@@ -324,6 +337,7 @@ impl From<crate::net::TcpStream> for OwnedFd {
324}337}
325338
326#[stable(feature = "io_safety", since = "1.63.0")]339#[stable(feature = "io_safety", since = "1.63.0")]
340#[cfg(not(target_os = "trusty"))]
327impl From<OwnedFd> for crate::net::TcpStream {341impl From<OwnedFd> for crate::net::TcpStream {
328 #[inline]342 #[inline]
329 fn from(owned_fd: OwnedFd) -> Self {343 fn from(owned_fd: OwnedFd) -> Self {
...@@ -334,6 +348,7 @@ impl From<OwnedFd> for crate::net::TcpStream {...@@ -334,6 +348,7 @@ impl From<OwnedFd> for crate::net::TcpStream {
334}348}
335349
336#[stable(feature = "io_safety", since = "1.63.0")]350#[stable(feature = "io_safety", since = "1.63.0")]
351#[cfg(not(target_os = "trusty"))]
337impl AsFd for crate::net::TcpListener {352impl AsFd for crate::net::TcpListener {
338 #[inline]353 #[inline]
339 fn as_fd(&self) -> BorrowedFd<'_> {354 fn as_fd(&self) -> BorrowedFd<'_> {
...@@ -342,6 +357,7 @@ impl AsFd for crate::net::TcpListener {...@@ -342,6 +357,7 @@ impl AsFd for crate::net::TcpListener {
342}357}
343358
344#[stable(feature = "io_safety", since = "1.63.0")]359#[stable(feature = "io_safety", since = "1.63.0")]
360#[cfg(not(target_os = "trusty"))]
345impl From<crate::net::TcpListener> for OwnedFd {361impl From<crate::net::TcpListener> for OwnedFd {
346 /// Takes ownership of a [`TcpListener`](crate::net::TcpListener)'s socket file descriptor.362 /// Takes ownership of a [`TcpListener`](crate::net::TcpListener)'s socket file descriptor.
347 #[inline]363 #[inline]
...@@ -351,6 +367,7 @@ impl From<crate::net::TcpListener> for OwnedFd {...@@ -351,6 +367,7 @@ impl From<crate::net::TcpListener> for OwnedFd {
351}367}
352368
353#[stable(feature = "io_safety", since = "1.63.0")]369#[stable(feature = "io_safety", since = "1.63.0")]
370#[cfg(not(target_os = "trusty"))]
354impl From<OwnedFd> for crate::net::TcpListener {371impl From<OwnedFd> for crate::net::TcpListener {
355 #[inline]372 #[inline]
356 fn from(owned_fd: OwnedFd) -> Self {373 fn from(owned_fd: OwnedFd) -> Self {
...@@ -361,6 +378,7 @@ impl From<OwnedFd> for crate::net::TcpListener {...@@ -361,6 +378,7 @@ impl From<OwnedFd> for crate::net::TcpListener {
361}378}
362379
363#[stable(feature = "io_safety", since = "1.63.0")]380#[stable(feature = "io_safety", since = "1.63.0")]
381#[cfg(not(target_os = "trusty"))]
364impl AsFd for crate::net::UdpSocket {382impl AsFd for crate::net::UdpSocket {
365 #[inline]383 #[inline]
366 fn as_fd(&self) -> BorrowedFd<'_> {384 fn as_fd(&self) -> BorrowedFd<'_> {
...@@ -369,6 +387,7 @@ impl AsFd for crate::net::UdpSocket {...@@ -369,6 +387,7 @@ impl AsFd for crate::net::UdpSocket {
369}387}
370388
371#[stable(feature = "io_safety", since = "1.63.0")]389#[stable(feature = "io_safety", since = "1.63.0")]
390#[cfg(not(target_os = "trusty"))]
372impl From<crate::net::UdpSocket> for OwnedFd {391impl From<crate::net::UdpSocket> for OwnedFd {
373 /// Takes ownership of a [`UdpSocket`](crate::net::UdpSocket)'s file descriptor.392 /// Takes ownership of a [`UdpSocket`](crate::net::UdpSocket)'s file descriptor.
374 #[inline]393 #[inline]
...@@ -378,6 +397,7 @@ impl From<crate::net::UdpSocket> for OwnedFd {...@@ -378,6 +397,7 @@ impl From<crate::net::UdpSocket> for OwnedFd {
378}397}
379398
380#[stable(feature = "io_safety", since = "1.63.0")]399#[stable(feature = "io_safety", since = "1.63.0")]
400#[cfg(not(target_os = "trusty"))]
381impl From<OwnedFd> for crate::net::UdpSocket {401impl From<OwnedFd> for crate::net::UdpSocket {
382 #[inline]402 #[inline]
383 fn from(owned_fd: OwnedFd) -> Self {403 fn from(owned_fd: OwnedFd) -> Self {
library/std/src/os/fd/raw.rs+9-1
...@@ -5,6 +5,9 @@...@@ -5,6 +5,9 @@
5#[cfg(target_os = "hermit")]5#[cfg(target_os = "hermit")]
6use hermit_abi as libc;6use hermit_abi as libc;
77
8#[cfg(not(target_os = "trusty"))]
9use crate::fs;
10use crate::io;
8#[cfg(target_os = "hermit")]11#[cfg(target_os = "hermit")]
9use crate::os::hermit::io::OwnedFd;12use crate::os::hermit::io::OwnedFd;
10#[cfg(not(target_os = "hermit"))]13#[cfg(not(target_os = "hermit"))]
...@@ -15,8 +18,8 @@ use crate::os::unix::io::AsFd;...@@ -15,8 +18,8 @@ use crate::os::unix::io::AsFd;
15use crate::os::unix::io::OwnedFd;18use crate::os::unix::io::OwnedFd;
16#[cfg(target_os = "wasi")]19#[cfg(target_os = "wasi")]
17use crate::os::wasi::io::OwnedFd;20use crate::os::wasi::io::OwnedFd;
21#[cfg(not(target_os = "trusty"))]
18use crate::sys_common::{AsInner, IntoInner};22use crate::sys_common::{AsInner, IntoInner};
19use crate::{fs, io};
2023
21/// Raw file descriptors.24/// Raw file descriptors.
22#[stable(feature = "rust1", since = "1.0.0")]25#[stable(feature = "rust1", since = "1.0.0")]
...@@ -161,6 +164,7 @@ impl FromRawFd for RawFd {...@@ -161,6 +164,7 @@ impl FromRawFd for RawFd {
161}164}
162165
163#[stable(feature = "rust1", since = "1.0.0")]166#[stable(feature = "rust1", since = "1.0.0")]
167#[cfg(not(target_os = "trusty"))]
164impl AsRawFd for fs::File {168impl AsRawFd for fs::File {
165 #[inline]169 #[inline]
166 fn as_raw_fd(&self) -> RawFd {170 fn as_raw_fd(&self) -> RawFd {
...@@ -168,6 +172,7 @@ impl AsRawFd for fs::File {...@@ -168,6 +172,7 @@ impl AsRawFd for fs::File {
168 }172 }
169}173}
170#[stable(feature = "from_raw_os", since = "1.1.0")]174#[stable(feature = "from_raw_os", since = "1.1.0")]
175#[cfg(not(target_os = "trusty"))]
171impl FromRawFd for fs::File {176impl FromRawFd for fs::File {
172 #[inline]177 #[inline]
173 unsafe fn from_raw_fd(fd: RawFd) -> fs::File {178 unsafe fn from_raw_fd(fd: RawFd) -> fs::File {
...@@ -175,6 +180,7 @@ impl FromRawFd for fs::File {...@@ -175,6 +180,7 @@ impl FromRawFd for fs::File {
175 }180 }
176}181}
177#[stable(feature = "into_raw_os", since = "1.4.0")]182#[stable(feature = "into_raw_os", since = "1.4.0")]
183#[cfg(not(target_os = "trusty"))]
178impl IntoRawFd for fs::File {184impl IntoRawFd for fs::File {
179 #[inline]185 #[inline]
180 fn into_raw_fd(self) -> RawFd {186 fn into_raw_fd(self) -> RawFd {
...@@ -183,6 +189,7 @@ impl IntoRawFd for fs::File {...@@ -183,6 +189,7 @@ impl IntoRawFd for fs::File {
183}189}
184190
185#[stable(feature = "asraw_stdio", since = "1.21.0")]191#[stable(feature = "asraw_stdio", since = "1.21.0")]
192#[cfg(not(target_os = "trusty"))]
186impl AsRawFd for io::Stdin {193impl AsRawFd for io::Stdin {
187 #[inline]194 #[inline]
188 fn as_raw_fd(&self) -> RawFd {195 fn as_raw_fd(&self) -> RawFd {
...@@ -207,6 +214,7 @@ impl AsRawFd for io::Stderr {...@@ -207,6 +214,7 @@ impl AsRawFd for io::Stderr {
207}214}
208215
209#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]216#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
217#[cfg(not(target_os = "trusty"))]
210impl<'a> AsRawFd for io::StdinLock<'a> {218impl<'a> AsRawFd for io::StdinLock<'a> {
211 #[inline]219 #[inline]
212 fn as_raw_fd(&self) -> RawFd {220 fn as_raw_fd(&self) -> RawFd {
library/std/src/os/mod.rs+3-1
...@@ -169,6 +169,8 @@ pub mod rtems;...@@ -169,6 +169,8 @@ pub mod rtems;
169pub mod solaris;169pub mod solaris;
170#[cfg(target_os = "solid_asp3")]170#[cfg(target_os = "solid_asp3")]
171pub mod solid;171pub mod solid;
172#[cfg(target_os = "trusty")]
173pub mod trusty;
172#[cfg(target_os = "uefi")]174#[cfg(target_os = "uefi")]
173pub mod uefi;175pub mod uefi;
174#[cfg(target_os = "vita")]176#[cfg(target_os = "vita")]
...@@ -178,7 +180,7 @@ pub mod vxworks;...@@ -178,7 +180,7 @@ pub mod vxworks;
178#[cfg(target_os = "xous")]180#[cfg(target_os = "xous")]
179pub mod xous;181pub mod xous;
180182
181#[cfg(any(unix, target_os = "hermit", target_os = "wasi", doc))]183#[cfg(any(unix, target_os = "hermit", target_os = "trusty", target_os = "wasi", doc))]
182pub mod fd;184pub mod fd;
183185
184#[cfg(any(target_os = "linux", target_os = "android", doc))]186#[cfg(any(target_os = "linux", target_os = "android", doc))]
library/std/src/os/trusty/io/mod.rs created+4
...@@ -0,0 +1,4 @@
1#![stable(feature = "os_fd", since = "1.66.0")]
2
3#[stable(feature = "os_fd", since = "1.66.0")]
4pub use crate::os::fd::*;
library/std/src/os/trusty/mod.rs created+3
...@@ -0,0 +1,3 @@
1#![stable(feature = "rust1", since = "1.0.0")]
2
3pub mod io;
library/std/src/os/windows/process.rs+1-1
...@@ -531,7 +531,7 @@ impl<'a> ProcThreadAttributeListBuilder<'a> {...@@ -531,7 +531,7 @@ impl<'a> ProcThreadAttributeListBuilder<'a> {
531 /// pub Y: i16,531 /// pub Y: i16,
532 /// }532 /// }
533 ///533 ///
534 /// extern "system" {534 /// unsafe extern "system" {
535 /// fn CreatePipe(535 /// fn CreatePipe(
536 /// hreadpipe: *mut HANDLE,536 /// hreadpipe: *mut HANDLE,
537 /// hwritepipe: *mut HANDLE,537 /// hwritepipe: *mut HANDLE,
library/std/src/process.rs+2-1
...@@ -154,7 +154,8 @@...@@ -154,7 +154,8 @@
154 target_os = "emscripten",154 target_os = "emscripten",
155 target_os = "wasi",155 target_os = "wasi",
156 target_env = "sgx",156 target_env = "sgx",
157 target_os = "xous"157 target_os = "xous",
158 target_os = "trusty",
158 ))159 ))
159))]160))]
160mod tests;161mod tests;
library/std/src/sys/alloc/mod.rs+1
...@@ -72,6 +72,7 @@ cfg_if::cfg_if! {...@@ -72,6 +72,7 @@ cfg_if::cfg_if! {
72 target_family = "unix",72 target_family = "unix",
73 target_os = "wasi",73 target_os = "wasi",
74 target_os = "teeos",74 target_os = "teeos",
75 target_os = "trusty",
75 ))] {76 ))] {
76 mod unix;77 mod unix;
77 } else if #[cfg(target_os = "windows")] {78 } else if #[cfg(target_os = "windows")] {
library/std/src/sys/pal/mod.rs+3
...@@ -37,6 +37,9 @@ cfg_if::cfg_if! {...@@ -37,6 +37,9 @@ cfg_if::cfg_if! {
37 } else if #[cfg(target_os = "hermit")] {37 } else if #[cfg(target_os = "hermit")] {
38 mod hermit;38 mod hermit;
39 pub use self::hermit::*;39 pub use self::hermit::*;
40 } else if #[cfg(target_os = "trusty")] {
41 mod trusty;
42 pub use self::trusty::*;
40 } else if #[cfg(all(target_os = "wasi", target_env = "p2"))] {43 } else if #[cfg(all(target_os = "wasi", target_env = "p2"))] {
41 mod wasip2;44 mod wasip2;
42 pub use self::wasip2::*;45 pub use self::wasip2::*;
library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs+48-16
...@@ -6,7 +6,7 @@ use super::super::mem::{is_enclave_range, is_user_range};...@@ -6,7 +6,7 @@ use super::super::mem::{is_enclave_range, is_user_range};
6use crate::arch::asm;6use crate::arch::asm;
7use crate::cell::UnsafeCell;7use crate::cell::UnsafeCell;
8use crate::convert::TryInto;8use crate::convert::TryInto;
9use crate::mem::{self, ManuallyDrop};9use crate::mem::{self, ManuallyDrop, MaybeUninit};
10use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut};10use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut};
11use crate::pin::PinCoerceUnsized;11use crate::pin::PinCoerceUnsized;
12use crate::ptr::{self, NonNull};12use crate::ptr::{self, NonNull};
...@@ -209,6 +209,45 @@ impl<T: ?Sized> NewUserRef<NonNull<T>> for NonNull<UserRef<T>> {...@@ -209,6 +209,45 @@ impl<T: ?Sized> NewUserRef<NonNull<T>> for NonNull<UserRef<T>> {
209 }209 }
210}210}
211211
212/// A type which can a destination for safely copying from userspace.
213///
214/// # Safety
215///
216/// Requires that `T` and `Self` have identical layouts.
217#[unstable(feature = "sgx_platform", issue = "56975")]
218pub unsafe trait UserSafeCopyDestination<T: ?Sized> {
219 /// Returns a pointer for writing to the value.
220 fn as_mut_ptr(&mut self) -> *mut T;
221}
222
223#[unstable(feature = "sgx_platform", issue = "56975")]
224unsafe impl<T> UserSafeCopyDestination<T> for T {
225 fn as_mut_ptr(&mut self) -> *mut T {
226 self as _
227 }
228}
229
230#[unstable(feature = "sgx_platform", issue = "56975")]
231unsafe impl<T> UserSafeCopyDestination<[T]> for [T] {
232 fn as_mut_ptr(&mut self) -> *mut [T] {
233 self as _
234 }
235}
236
237#[unstable(feature = "sgx_platform", issue = "56975")]
238unsafe impl<T> UserSafeCopyDestination<T> for MaybeUninit<T> {
239 fn as_mut_ptr(&mut self) -> *mut T {
240 self as *mut Self as _
241 }
242}
243
244#[unstable(feature = "sgx_platform", issue = "56975")]
245unsafe impl<T> UserSafeCopyDestination<[T]> for [MaybeUninit<T>] {
246 fn as_mut_ptr(&mut self) -> *mut [T] {
247 self as *mut Self as _
248 }
249}
250
212#[unstable(feature = "sgx_platform", issue = "56975")]251#[unstable(feature = "sgx_platform", issue = "56975")]
213impl<T: ?Sized> User<T>252impl<T: ?Sized> User<T>
214where253where
...@@ -544,12 +583,12 @@ where...@@ -544,12 +583,12 @@ where
544 /// # Panics583 /// # Panics
545 /// This function panics if the destination doesn't have the same size as584 /// This function panics if the destination doesn't have the same size as
546 /// the source. This can happen for dynamically-sized types such as slices.585 /// the source. This can happen for dynamically-sized types such as slices.
547 pub fn copy_to_enclave(&self, dest: &mut T) {586 pub fn copy_to_enclave<U: ?Sized + UserSafeCopyDestination<T>>(&self, dest: &mut U) {
548 unsafe {587 unsafe {
549 assert_eq!(size_of_val(dest), size_of_val(&*self.0.get()));588 assert_eq!(size_of_val(dest), size_of_val(&*self.0.get()));
550 copy_from_userspace(589 copy_from_userspace(
551 self.0.get() as *const T as *const u8,590 self.0.get() as *const T as *const u8,
552 dest as *mut T as *mut u8,591 dest.as_mut_ptr() as *mut u8,
553 size_of_val(dest),592 size_of_val(dest),
554 );593 );
555 }594 }
...@@ -639,25 +678,18 @@ where...@@ -639,25 +678,18 @@ where
639 unsafe { (*self.0.get()).len() }678 unsafe { (*self.0.get()).len() }
640 }679 }
641680
642 /// Copies the value from user memory and place it into `dest`. Afterwards,681 /// Copies the value from user memory and appends it to `dest`.
643 /// `dest` will contain exactly `self.len()` elements.682 pub fn append_to_enclave_vec(&self, dest: &mut Vec<T>) {
644 ///683 dest.reserve(self.len());
645 /// # Panics684 self.copy_to_enclave(&mut dest.spare_capacity_mut()[..self.len()]);
646 /// This function panics if the destination doesn't have the same size as
647 /// the source. This can happen for dynamically-sized types such as slices.
648 pub fn copy_to_enclave_vec(&self, dest: &mut Vec<T>) {
649 if let Some(missing) = self.len().checked_sub(dest.capacity()) {
650 dest.reserve(missing)
651 }
652 // SAFETY: We reserve enough space above.685 // SAFETY: We reserve enough space above.
653 unsafe { dest.set_len(self.len()) };686 unsafe { dest.set_len(dest.len() + self.len()) };
654 self.copy_to_enclave(&mut dest[..]);
655 }687 }
656688
657 /// Copies the value from user memory into a vector in enclave memory.689 /// Copies the value from user memory into a vector in enclave memory.
658 pub fn to_enclave(&self) -> Vec<T> {690 pub fn to_enclave(&self) -> Vec<T> {
659 let mut ret = Vec::with_capacity(self.len());691 let mut ret = Vec::with_capacity(self.len());
660 self.copy_to_enclave_vec(&mut ret);692 self.append_to_enclave_vec(&mut ret);
661 ret693 ret
662 }694 }
663695
library/std/src/sys/pal/sgx/abi/usercalls/mod.rs+16-1
...@@ -1,5 +1,7 @@...@@ -1,5 +1,7 @@
1use crate::cmp;1use crate::cmp;
2use crate::io::{Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult};2use crate::io::{
3 BorrowedCursor, Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult,
4};
3use crate::random::{DefaultRandomSource, Random};5use crate::random::{DefaultRandomSource, Random};
4use crate::time::{Duration, Instant};6use crate::time::{Duration, Instant};
57
...@@ -36,6 +38,19 @@ pub fn read(fd: Fd, bufs: &mut [IoSliceMut<'_>]) -> IoResult<usize> {...@@ -36,6 +38,19 @@ pub fn read(fd: Fd, bufs: &mut [IoSliceMut<'_>]) -> IoResult<usize> {
36 }38 }
37}39}
3840
41/// Usercall `read` with an uninitialized buffer. See the ABI documentation for
42/// more information.
43#[unstable(feature = "sgx_platform", issue = "56975")]
44pub fn read_buf(fd: Fd, mut buf: BorrowedCursor<'_>) -> IoResult<()> {
45 unsafe {
46 let mut userbuf = alloc::User::<[u8]>::uninitialized(buf.capacity());
47 let len = raw::read(fd, userbuf.as_mut_ptr().cast(), userbuf.len()).from_sgx_result()?;
48 userbuf[..len].copy_to_enclave(&mut buf.as_mut()[..len]);
49 buf.advance_unchecked(len);
50 Ok(())
51 }
52}
53
39/// Usercall `read_alloc`. See the ABI documentation for more information.54/// Usercall `read_alloc`. See the ABI documentation for more information.
40#[unstable(feature = "sgx_platform", issue = "56975")]55#[unstable(feature = "sgx_platform", issue = "56975")]
41pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> {56pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> {
library/std/src/sys/pal/sgx/fd.rs+1-1
...@@ -29,7 +29,7 @@ impl FileDesc {...@@ -29,7 +29,7 @@ impl FileDesc {
29 }29 }
3030
31 pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> {31 pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> {
32 crate::io::default_read_buf(|b| self.read(b), buf)32 usercalls::read_buf(self.fd, buf)
33 }33 }
3434
35 pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {35 pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
library/std/src/sys/pal/trusty/mod.rs created+21
...@@ -0,0 +1,21 @@
1//! System bindings for the Trusty OS.
2
3#[path = "../unsupported/args.rs"]
4pub mod args;
5#[path = "../unsupported/common.rs"]
6#[deny(unsafe_op_in_unsafe_fn)]
7mod common;
8#[path = "../unsupported/env.rs"]
9pub mod env;
10#[path = "../unsupported/os.rs"]
11pub mod os;
12#[path = "../unsupported/pipe.rs"]
13pub mod pipe;
14#[path = "../unsupported/process.rs"]
15pub mod process;
16#[path = "../unsupported/thread.rs"]
17pub mod thread;
18#[path = "../unsupported/time.rs"]
19pub mod time;
20
21pub use common::*;
library/std/src/sys/random/mod.rs+3
...@@ -60,6 +60,9 @@ cfg_if::cfg_if! {...@@ -60,6 +60,9 @@ cfg_if::cfg_if! {
60 } else if #[cfg(target_os = "teeos")] {60 } else if #[cfg(target_os = "teeos")] {
61 mod teeos;61 mod teeos;
62 pub use teeos::fill_bytes;62 pub use teeos::fill_bytes;
63 } else if #[cfg(target_os = "trusty")] {
64 mod trusty;
65 pub use trusty::fill_bytes;
63 } else if #[cfg(target_os = "uefi")] {66 } else if #[cfg(target_os = "uefi")] {
64 mod uefi;67 mod uefi;
65 pub use uefi::fill_bytes;68 pub use uefi::fill_bytes;
library/std/src/sys/random/trusty.rs created+7
...@@ -0,0 +1,7 @@
1extern "C" {
2 fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t);
3}
4
5pub fn fill_bytes(bytes: &mut [u8]) {
6 unsafe { trusty_rng_secure_rand(bytes.as_mut_ptr().cast(), bytes.len()) }
7}
library/std/src/sys/stdio/mod.rs+3
...@@ -19,6 +19,9 @@ cfg_if::cfg_if! {...@@ -19,6 +19,9 @@ cfg_if::cfg_if! {
19 } else if #[cfg(target_os = "teeos")] {19 } else if #[cfg(target_os = "teeos")] {
20 mod teeos;20 mod teeos;
21 pub use teeos::*;21 pub use teeos::*;
22 } else if #[cfg(target_os = "trusty")] {
23 mod trusty;
24 pub use trusty::*;
22 } else if #[cfg(target_os = "uefi")] {25 } else if #[cfg(target_os = "uefi")] {
23 mod uefi;26 mod uefi;
24 pub use uefi::*;27 pub use uefi::*;
library/std/src/sys/stdio/sgx.rs+32-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1use fortanix_sgx_abi as abi;1use fortanix_sgx_abi as abi;
22
3use crate::io;3use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
4use crate::sys::fd::FileDesc;4use crate::sys::fd::FileDesc;
55
6pub struct Stdin(());6pub struct Stdin(());
...@@ -24,6 +24,19 @@ impl io::Read for Stdin {...@@ -24,6 +24,19 @@ impl io::Read for Stdin {
24 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {24 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
25 with_std_fd(abi::FD_STDIN, |fd| fd.read(buf))25 with_std_fd(abi::FD_STDIN, |fd| fd.read(buf))
26 }26 }
27
28 fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> {
29 with_std_fd(abi::FD_STDIN, |fd| fd.read_buf(buf))
30 }
31
32 fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
33 with_std_fd(abi::FD_STDIN, |fd| fd.read_vectored(bufs))
34 }
35
36 #[inline]
37 fn is_read_vectored(&self) -> bool {
38 true
39 }
27}40}
2841
29impl Stdout {42impl Stdout {
...@@ -40,6 +53,15 @@ impl io::Write for Stdout {...@@ -40,6 +53,15 @@ impl io::Write for Stdout {
40 fn flush(&mut self) -> io::Result<()> {53 fn flush(&mut self) -> io::Result<()> {
41 with_std_fd(abi::FD_STDOUT, |fd| fd.flush())54 with_std_fd(abi::FD_STDOUT, |fd| fd.flush())
42 }55 }
56
57 fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
58 with_std_fd(abi::FD_STDOUT, |fd| fd.write_vectored(bufs))
59 }
60
61 #[inline]
62 fn is_write_vectored(&self) -> bool {
63 true
64 }
43}65}
4466
45impl Stderr {67impl Stderr {
...@@ -56,6 +78,15 @@ impl io::Write for Stderr {...@@ -56,6 +78,15 @@ impl io::Write for Stderr {
56 fn flush(&mut self) -> io::Result<()> {78 fn flush(&mut self) -> io::Result<()> {
57 with_std_fd(abi::FD_STDERR, |fd| fd.flush())79 with_std_fd(abi::FD_STDERR, |fd| fd.flush())
58 }80 }
81
82 fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
83 with_std_fd(abi::FD_STDERR, |fd| fd.write_vectored(bufs))
84 }
85
86 #[inline]
87 fn is_write_vectored(&self) -> bool {
88 true
89 }
59}90}
6091
61pub const STDIN_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE;92pub const STDIN_BUF_SIZE: usize = crate::sys::io::DEFAULT_BUF_SIZE;
library/std/src/sys/stdio/trusty.rs created+81
...@@ -0,0 +1,81 @@
1use crate::io;
2
3pub struct Stdin;
4pub struct Stdout;
5pub struct Stderr;
6
7impl Stdin {
8 pub const fn new() -> Stdin {
9 Stdin
10 }
11}
12
13impl io::Read for Stdin {
14 fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
15 Ok(0)
16 }
17}
18
19impl Stdout {
20 pub const fn new() -> Stdout {
21 Stdout
22 }
23}
24
25impl io::Write for Stdout {
26 fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
27 _write(libc::STDOUT_FILENO, buf)
28 }
29
30 fn flush(&mut self) -> io::Result<()> {
31 Ok(())
32 }
33}
34
35impl Stderr {
36 pub const fn new() -> Stderr {
37 Stderr
38 }
39}
40
41impl io::Write for Stderr {
42 fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
43 _write(libc::STDERR_FILENO, buf)
44 }
45
46 fn flush(&mut self) -> io::Result<()> {
47 Ok(())
48 }
49}
50
51pub const STDIN_BUF_SIZE: usize = 0;
52
53pub fn is_ebadf(_err: &io::Error) -> bool {
54 true
55}
56
57pub fn panic_output() -> Option<impl io::Write> {
58 Some(Stderr)
59}
60
61fn _write(fd: i32, message: &[u8]) -> io::Result<usize> {
62 let mut iov = libc::iovec { iov_base: message.as_ptr() as *mut _, iov_len: message.len() };
63 loop {
64 // SAFETY: syscall, safe arguments.
65 let ret = unsafe { libc::writev(fd, &iov, 1) };
66 if ret < 0 {
67 return Err(io::Error::last_os_error());
68 }
69 let ret = ret as usize;
70 if ret > iov.iov_len {
71 return Err(io::Error::last_os_error());
72 }
73 if ret == iov.iov_len {
74 return Ok(message.len());
75 }
76 // SAFETY: ret has been checked to be less than the length of
77 // the buffer
78 iov.iov_base = unsafe { iov.iov_base.add(ret) };
79 iov.iov_len -= ret;
80 }
81}
library/std/src/sys/thread_local/mod.rs+2
...@@ -28,6 +28,7 @@ cfg_if::cfg_if! {...@@ -28,6 +28,7 @@ cfg_if::cfg_if! {
28 all(target_family = "wasm", not(target_feature = "atomics")),28 all(target_family = "wasm", not(target_feature = "atomics")),
29 target_os = "uefi",29 target_os = "uefi",
30 target_os = "zkvm",30 target_os = "zkvm",
31 target_os = "trusty",
31 ))] {32 ))] {
32 mod statik;33 mod statik;
33 pub use statik::{EagerStorage, LazyStorage, thread_local_inner};34 pub use statik::{EagerStorage, LazyStorage, thread_local_inner};
...@@ -91,6 +92,7 @@ pub(crate) mod guard {...@@ -91,6 +92,7 @@ pub(crate) mod guard {
91 )),92 )),
92 target_os = "uefi",93 target_os = "uefi",
93 target_os = "zkvm",94 target_os = "zkvm",
95 target_os = "trusty",
94 ))] {96 ))] {
95 pub(crate) fn enable() {97 pub(crate) fn enable() {
96 // FIXME: Right now there is no concept of "thread exit" on98 // FIXME: Right now there is no concept of "thread exit" on
library/sysroot/Cargo.toml+1-1
...@@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]...@@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]
3[package]3[package]
4name = "sysroot"4name = "sysroot"
5version = "0.0.0"5version = "0.0.0"
6edition = "2021"6edition = "2024"
77
8# this is a dummy crate to ensure that all required crates appear in the sysroot8# this is a dummy crate to ensure that all required crates appear in the sysroot
9[dependencies]9[dependencies]
library/test/Cargo.toml+1-1
...@@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]...@@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]
3[package]3[package]
4name = "test"4name = "test"
5version = "0.0.0"5version = "0.0.0"
6edition = "2021"6edition = "2024"
77
8[dependencies]8[dependencies]
9getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] }9getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] }
library/unwind/Cargo.toml+1-1
...@@ -3,7 +3,7 @@ name = "unwind"...@@ -3,7 +3,7 @@ name = "unwind"
3version = "0.0.0"3version = "0.0.0"
4license = "MIT OR Apache-2.0"4license = "MIT OR Apache-2.0"
5repository = "https://github.com/rust-lang/rust.git"5repository = "https://github.com/rust-lang/rust.git"
6edition = "2021"6edition = "2024"
7include = [7include = [
8 '/libunwind/*',8 '/libunwind/*',
9]9]
library/windows_targets/Cargo.toml+1-1
...@@ -2,7 +2,7 @@...@@ -2,7 +2,7 @@
2name = "windows-targets"2name = "windows-targets"
3description = "A drop-in replacement for the real windows-targets crate for use in std only."3description = "A drop-in replacement for the real windows-targets crate for use in std only."
4version = "0.0.0"4version = "0.0.0"
5edition = "2021"5edition = "2024"
66
7[features]7[features]
8# Enable using raw-dylib for Windows imports.8# Enable using raw-dylib for Windows imports.
library/windows_targets/src/lib.rs+2-2
...@@ -12,7 +12,7 @@ pub macro link {...@@ -12,7 +12,7 @@ pub macro link {
12 ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (12 ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
13 #[cfg_attr(not(target_arch = "x86"), link(name = $library, kind = "raw-dylib", modifiers = "+verbatim"))]13 #[cfg_attr(not(target_arch = "x86"), link(name = $library, kind = "raw-dylib", modifiers = "+verbatim"))]
14 #[cfg_attr(target_arch = "x86", link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated"))]14 #[cfg_attr(target_arch = "x86", link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated"))]
15 extern $abi {15 unsafe extern $abi {
16 $(#[link_name=$link_name])?16 $(#[link_name=$link_name])?
17 pub fn $($function)*;17 pub fn $($function)*;
18 }18 }
...@@ -26,7 +26,7 @@ pub macro link {...@@ -26,7 +26,7 @@ pub macro link {
26 // libraries below by using an empty extern block. This works because extern blocks are not26 // libraries below by using an empty extern block. This works because extern blocks are not
27 // connected to the library given in the #[link] attribute.27 // connected to the library given in the #[link] attribute.
28 #[link(name = "kernel32")]28 #[link(name = "kernel32")]
29 extern $abi {29 unsafe extern $abi {
30 $(#[link_name=$link_name])?30 $(#[link_name=$link_name])?
31 pub fn $($function)*;31 pub fn $($function)*;
32 }32 }
src/bootstrap/src/core/build_steps/check.rs-1
...@@ -454,7 +454,6 @@ tool_check_step!(Rustdoc { path: "src/tools/rustdoc", alt_path: "src/librustdoc"...@@ -454,7 +454,6 @@ tool_check_step!(Rustdoc { path: "src/tools/rustdoc", alt_path: "src/librustdoc"
454tool_check_step!(Clippy { path: "src/tools/clippy" });454tool_check_step!(Clippy { path: "src/tools/clippy" });
455tool_check_step!(Miri { path: "src/tools/miri" });455tool_check_step!(Miri { path: "src/tools/miri" });
456tool_check_step!(CargoMiri { path: "src/tools/miri/cargo-miri" });456tool_check_step!(CargoMiri { path: "src/tools/miri/cargo-miri" });
457tool_check_step!(Rls { path: "src/tools/rls" });
458tool_check_step!(Rustfmt { path: "src/tools/rustfmt" });457tool_check_step!(Rustfmt { path: "src/tools/rustfmt" });
459tool_check_step!(MiroptTestTools { path: "src/tools/miropt-test-tools" });458tool_check_step!(MiroptTestTools { path: "src/tools/miropt-test-tools" });
460tool_check_step!(TestFloatParse { path: "src/etc/test-float-parse" });459tool_check_step!(TestFloatParse { path: "src/etc/test-float-parse" });
src/bootstrap/src/core/build_steps/clippy.rs-1
...@@ -346,7 +346,6 @@ lint_any!(...@@ -346,7 +346,6 @@ lint_any!(
346 OptDist, "src/tools/opt-dist", "opt-dist";346 OptDist, "src/tools/opt-dist", "opt-dist";
347 RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";347 RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
348 RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";348 RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
349 Rls, "src/tools/rls", "rls";
350 RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";349 RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";
351 Rustdoc, "src/librustdoc", "clippy";350 Rustdoc, "src/librustdoc", "clippy";
352 Rustfmt, "src/tools/rustfmt", "rustfmt";351 Rustfmt, "src/tools/rustfmt", "rustfmt";
src/bootstrap/src/core/build_steps/dist.rs-43
...@@ -1157,48 +1157,6 @@ impl Step for Cargo {...@@ -1157,48 +1157,6 @@ impl Step for Cargo {
1157 }1157 }
1158}1158}
11591159
1160#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1161pub struct Rls {
1162 pub compiler: Compiler,
1163 pub target: TargetSelection,
1164}
1165
1166impl Step for Rls {
1167 type Output = Option<GeneratedTarball>;
1168 const ONLY_HOSTS: bool = true;
1169 const DEFAULT: bool = true;
1170
1171 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1172 let default = should_build_extended_tool(run.builder, "rls");
1173 run.alias("rls").default_condition(default)
1174 }
1175
1176 fn make_run(run: RunConfig<'_>) {
1177 run.builder.ensure(Rls {
1178 compiler: run.builder.compiler_for(
1179 run.builder.top_stage,
1180 run.builder.config.build,
1181 run.target,
1182 ),
1183 target: run.target,
1184 });
1185 }
1186
1187 fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
1188 let compiler = self.compiler;
1189 let target = self.target;
1190
1191 let rls = builder.ensure(tool::Rls { compiler, target });
1192
1193 let mut tarball = Tarball::new(builder, "rls", &target.triple);
1194 tarball.set_overlay(OverlayKind::Rls);
1195 tarball.is_preview(true);
1196 tarball.add_file(rls.tool_path, "bin", 0o755);
1197 tarball.add_legal_and_readme_to("share/doc/rls");
1198 Some(tarball.generate())
1199 }
1200}
1201
1202#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]1160#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
1203pub struct RustAnalyzer {1161pub struct RustAnalyzer {
1204 pub compiler: Compiler,1162 pub compiler: Compiler,
...@@ -1528,7 +1486,6 @@ impl Step for Extended {...@@ -1528,7 +1486,6 @@ impl Step for Extended {
1528 add_component!("rust-json-docs" => JsonDocs { host: target });1486 add_component!("rust-json-docs" => JsonDocs { host: target });
1529 add_component!("cargo" => Cargo { compiler, target });1487 add_component!("cargo" => Cargo { compiler, target });
1530 add_component!("rustfmt" => Rustfmt { compiler, target });1488 add_component!("rustfmt" => Rustfmt { compiler, target });
1531 add_component!("rls" => Rls { compiler, target });
1532 add_component!("rust-analyzer" => RustAnalyzer { compiler, target });1489 add_component!("rust-analyzer" => RustAnalyzer { compiler, target });
1533 add_component!("llvm-components" => LlvmTools { target });1490 add_component!("llvm-components" => LlvmTools { target });
1534 add_component!("clippy" => Clippy { compiler, target });1491 add_component!("clippy" => Clippy { compiler, target });
src/bootstrap/src/core/build_steps/setup.rs+1-3
...@@ -85,9 +85,7 @@ impl FromStr for Profile {...@@ -85,9 +85,7 @@ impl FromStr for Profile {
85 "lib" | "library" => Ok(Profile::Library),85 "lib" | "library" => Ok(Profile::Library),
86 "compiler" => Ok(Profile::Compiler),86 "compiler" => Ok(Profile::Compiler),
87 "maintainer" | "dist" | "user" => Ok(Profile::Dist),87 "maintainer" | "dist" | "user" => Ok(Profile::Dist),
88 "tools" | "tool" | "rustdoc" | "clippy" | "miri" | "rustfmt" | "rls" => {88 "tools" | "tool" | "rustdoc" | "clippy" | "miri" | "rustfmt" => Ok(Profile::Tools),
89 Ok(Profile::Tools)
90 }
91 "none" => Ok(Profile::None),89 "none" => Ok(Profile::None),
92 "llvm" | "codegen" => Err("the \"llvm\" and \"codegen\" profiles have been removed,\90 "llvm" | "codegen" => Err("the \"llvm\" and \"codegen\" profiles have been removed,\
93 use \"compiler\" instead which has the same functionality"91 use \"compiler\" instead which has the same functionality"
src/bootstrap/src/core/build_steps/tool.rs-2
...@@ -228,7 +228,6 @@ pub fn prepare_tool_cargo(...@@ -228,7 +228,6 @@ pub fn prepare_tool_cargo(
228 let mut features = extra_features.to_vec();228 let mut features = extra_features.to_vec();
229 if builder.build.config.cargo_native_static {229 if builder.build.config.cargo_native_static {
230 if path.ends_with("cargo")230 if path.ends_with("cargo")
231 || path.ends_with("rls")
232 || path.ends_with("clippy")231 || path.ends_with("clippy")
233 || path.ends_with("miri")232 || path.ends_with("miri")
234 || path.ends_with("rustfmt")233 || path.ends_with("rustfmt")
...@@ -1231,7 +1230,6 @@ tool_extended!(CargoMiri {...@@ -1231,7 +1230,6 @@ tool_extended!(CargoMiri {
1231 stable: false,1230 stable: false,
1232 add_bins_to_sysroot: ["cargo-miri"]1231 add_bins_to_sysroot: ["cargo-miri"]
1233});1232});
1234tool_extended!(Rls { path: "src/tools/rls", tool_name: "rls", stable: true });
1235tool_extended!(Rustfmt {1233tool_extended!(Rustfmt {
1236 path: "src/tools/rustfmt",1234 path: "src/tools/rustfmt",
1237 tool_name: "rustfmt",1235 tool_name: "rustfmt",
src/bootstrap/src/core/builder/mod.rs-4
...@@ -895,7 +895,6 @@ impl<'a> Builder<'a> {...@@ -895,7 +895,6 @@ impl<'a> Builder<'a> {
895 tool::RemoteTestClient,895 tool::RemoteTestClient,
896 tool::RustInstaller,896 tool::RustInstaller,
897 tool::Cargo,897 tool::Cargo,
898 tool::Rls,
899 tool::RustAnalyzer,898 tool::RustAnalyzer,
900 tool::RustAnalyzerProcMacroSrv,899 tool::RustAnalyzerProcMacroSrv,
901 tool::Rustdoc,900 tool::Rustdoc,
...@@ -938,7 +937,6 @@ impl<'a> Builder<'a> {...@@ -938,7 +937,6 @@ impl<'a> Builder<'a> {
938 clippy::OptDist,937 clippy::OptDist,
939 clippy::RemoteTestClient,938 clippy::RemoteTestClient,
940 clippy::RemoteTestServer,939 clippy::RemoteTestServer,
941 clippy::Rls,
942 clippy::RustAnalyzer,940 clippy::RustAnalyzer,
943 clippy::Rustdoc,941 clippy::Rustdoc,
944 clippy::Rustfmt,942 clippy::Rustfmt,
...@@ -956,7 +954,6 @@ impl<'a> Builder<'a> {...@@ -956,7 +954,6 @@ impl<'a> Builder<'a> {
956 check::Miri,954 check::Miri,
957 check::CargoMiri,955 check::CargoMiri,
958 check::MiroptTestTools,956 check::MiroptTestTools,
959 check::Rls,
960 check::Rustfmt,957 check::Rustfmt,
961 check::RustAnalyzer,958 check::RustAnalyzer,
962 check::TestFloatParse,959 check::TestFloatParse,
...@@ -1071,7 +1068,6 @@ impl<'a> Builder<'a> {...@@ -1071,7 +1068,6 @@ impl<'a> Builder<'a> {
1071 dist::Analysis,1068 dist::Analysis,
1072 dist::Src,1069 dist::Src,
1073 dist::Cargo,1070 dist::Cargo,
1074 dist::Rls,
1075 dist::RustAnalyzer,1071 dist::RustAnalyzer,
1076 dist::Rustfmt,1072 dist::Rustfmt,
1077 dist::Clippy,1073 dist::Clippy,
src/bootstrap/src/lib.rs+1-1
...@@ -253,7 +253,7 @@ pub enum Mode {...@@ -253,7 +253,7 @@ pub enum Mode {
253 /// Build a tool which uses the locally built rustc and the target std,253 /// Build a tool which uses the locally built rustc and the target std,
254 /// placing the output in the "stageN-tools" directory. This is used for254 /// placing the output in the "stageN-tools" directory. This is used for
255 /// anything that needs a fully functional rustc, such as rustdoc, clippy,255 /// anything that needs a fully functional rustc, such as rustdoc, clippy,
256 /// cargo, rls, rustfmt, miri, etc.256 /// cargo, rustfmt, miri, etc.
257 ToolRustc,257 ToolRustc,
258}258}
259259
src/bootstrap/src/utils/change_tracker.rs+5
...@@ -375,4 +375,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[...@@ -375,4 +375,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
375 severity: ChangeSeverity::Info,375 severity: ChangeSeverity::Info,
376 summary: "There is now a new `gcc` config section that can be used to download GCC from CI using `gcc.download-ci-gcc = true`",376 summary: "There is now a new `gcc` config section that can be used to download GCC from CI using `gcc.download-ci-gcc = true`",
377 },377 },
378 ChangeInfo {
379 change_id: 126856,
380 severity: ChangeSeverity::Warning,
381 summary: "Removed `src/tools/rls` tool as it was deprecated long time ago.",
382 },
378];383];
src/bootstrap/src/utils/tarball.rs-3
...@@ -22,7 +22,6 @@ pub(crate) enum OverlayKind {...@@ -22,7 +22,6 @@ pub(crate) enum OverlayKind {
22 Clippy,22 Clippy,
23 Miri,23 Miri,
24 Rustfmt,24 Rustfmt,
25 Rls,
26 RustAnalyzer,25 RustAnalyzer,
27 RustcCodegenCranelift,26 RustcCodegenCranelift,
28 LlvmBitcodeLinker,27 LlvmBitcodeLinker,
...@@ -56,7 +55,6 @@ impl OverlayKind {...@@ -56,7 +55,6 @@ impl OverlayKind {
56 "src/tools/rustfmt/LICENSE-APACHE",55 "src/tools/rustfmt/LICENSE-APACHE",
57 "src/tools/rustfmt/LICENSE-MIT",56 "src/tools/rustfmt/LICENSE-MIT",
58 ],57 ],
59 OverlayKind::Rls => &["src/tools/rls/README.md", "LICENSE-APACHE", "LICENSE-MIT"],
60 OverlayKind::RustAnalyzer => &[58 OverlayKind::RustAnalyzer => &[
61 "src/tools/rust-analyzer/README.md",59 "src/tools/rust-analyzer/README.md",
62 "src/tools/rust-analyzer/LICENSE-APACHE",60 "src/tools/rust-analyzer/LICENSE-APACHE",
...@@ -90,7 +88,6 @@ impl OverlayKind {...@@ -90,7 +88,6 @@ impl OverlayKind {
90 OverlayKind::Rustfmt => {88 OverlayKind::Rustfmt => {
91 builder.rustfmt_info.version(builder, &builder.release_num("rustfmt"))89 builder.rustfmt_info.version(builder, &builder.release_num("rustfmt"))
92 }90 }
93 OverlayKind::Rls => builder.release(&builder.release_num("rls")),
94 OverlayKind::RustAnalyzer => builder91 OverlayKind::RustAnalyzer => builder
95 .rust_analyzer_info92 .rust_analyzer_info
96 .version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")),93 .version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")),
src/doc/rustc/src/platform-support.md+3-3
...@@ -265,7 +265,7 @@ target | std | host | notes...@@ -265,7 +265,7 @@ target | std | host | notes
265[`aarch64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | ARM64 OpenBSD265[`aarch64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | ARM64 OpenBSD
266[`aarch64-unknown-redox`](platform-support/redox.md) | ✓ | | ARM64 Redox OS266[`aarch64-unknown-redox`](platform-support/redox.md) | ✓ | | ARM64 Redox OS
267[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |267[`aarch64-unknown-teeos`](platform-support/aarch64-unknown-teeos.md) | ? | | ARM64 TEEOS |
268[`aarch64-unknown-trusty`](platform-support/trusty.md) | ? | |268[`aarch64-unknown-trusty`](platform-support/trusty.md) | ✓ | |
269[`aarch64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |269[`aarch64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
270[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS270[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS
271`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)271`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)
...@@ -290,7 +290,7 @@ target | std | host | notes...@@ -290,7 +290,7 @@ target | std | host | notes
290[`armv7-unknown-linux-uclibceabi`](platform-support/armv7-unknown-linux-uclibceabi.md) | ✓ | ✓ | Armv7-A Linux with uClibc, softfloat290[`armv7-unknown-linux-uclibceabi`](platform-support/armv7-unknown-linux-uclibceabi.md) | ✓ | ✓ | Armv7-A Linux with uClibc, softfloat
291[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | Armv7-A Linux with uClibc, hardfloat291[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | Armv7-A Linux with uClibc, hardfloat
292[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv7-A NetBSD w/hard-float292[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv7-A NetBSD w/hard-float
293[`armv7-unknown-trusty`](platform-support/trusty.md) | ? | |293[`armv7-unknown-trusty`](platform-support/trusty.md) | ✓ | |
294[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | ✓ | | Armv7-A for VxWorks294[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | ✓ | | Armv7-A for VxWorks
295[`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3295[`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3
296[`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat296[`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat
...@@ -419,7 +419,7 @@ target | std | host | notes...@@ -419,7 +419,7 @@ target | std | host | notes
419`x86_64-unknown-l4re-uclibc` | ? | |419`x86_64-unknown-l4re-uclibc` | ? | |
420[`x86_64-unknown-linux-none`](platform-support/x86_64-unknown-linux-none.md) | * | | 64-bit Linux with no libc420[`x86_64-unknown-linux-none`](platform-support/x86_64-unknown-linux-none.md) | * | | 64-bit Linux with no libc
421[`x86_64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 64-bit OpenBSD421[`x86_64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 64-bit OpenBSD
422[`x86_64-unknown-trusty`](platform-support/trusty.md) | ? | |422[`x86_64-unknown-trusty`](platform-support/trusty.md) | ✓ | |
423`x86_64-uwp-windows-gnu` | ✓ | |423`x86_64-uwp-windows-gnu` | ✓ | |
424[`x86_64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |424[`x86_64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | |
425[`x86_64-win7-windows-gnu`](platform-support/win7-windows-gnu.md) | ✓ | | 64-bit Windows 7 support425[`x86_64-win7-windows-gnu`](platform-support/win7-windows-gnu.md) | ✓ | | 64-bit Windows 7 support
src/doc/rustc/src/platform-support/trusty.md+4-2
...@@ -16,8 +16,10 @@ Environment (TEE) for Android....@@ -16,8 +16,10 @@ Environment (TEE) for Android.
1616
17These targets are cross-compiled. They have no special requirements for the host.17These targets are cross-compiled. They have no special requirements for the host.
1818
19Support for the standard library is work-in-progress. It is expected that19Trusty targets have partial support for the standard library: `alloc` is fully
20they will support alloc with the default allocator, and partially support std.20supported and `std` has limited support that excludes things like filesystem
21access, network I/O, and spawning processes/threads. File descriptors are
22supported for the purpose of IPC.
2123
22Trusty uses the ELF file format.24Trusty uses the ELF file format.
2325
src/librustdoc/json/conversions.rs+2-64
...@@ -7,14 +7,13 @@...@@ -7,14 +7,13 @@
7use rustc_abi::ExternAbi;7use rustc_abi::ExternAbi;
8use rustc_ast::ast;8use rustc_ast::ast;
9use rustc_attr_parsing::DeprecatedSince;9use rustc_attr_parsing::DeprecatedSince;
10use rustc_hir::def::{CtorKind, DefKind};10use rustc_hir::def::CtorKind;
11use rustc_hir::def_id::DefId;11use rustc_hir::def_id::DefId;
12use rustc_metadata::rendered_const;12use rustc_metadata::rendered_const;
13use rustc_middle::{bug, ty};13use rustc_middle::{bug, ty};
14use rustc_span::{Pos, Symbol, sym};14use rustc_span::{Pos, Symbol};
15use rustdoc_json_types::*;15use rustdoc_json_types::*;
1616
17use super::FullItemId;
18use crate::clean::{self, ItemId};17use crate::clean::{self, ItemId};
19use crate::formats::FormatRenderer;18use crate::formats::FormatRenderer;
20use crate::formats::item_type::ItemType;19use crate::formats::item_type::ItemType;
...@@ -108,67 +107,6 @@ impl JsonRenderer<'_> {...@@ -108,67 +107,6 @@ impl JsonRenderer<'_> {
108 }107 }
109 }108 }
110109
111 pub(crate) fn id_from_item_default(&self, item_id: ItemId) -> Id {
112 self.id_from_item_inner(item_id, None, None)
113 }
114
115 pub(crate) fn id_from_item_inner(
116 &self,
117 item_id: ItemId,
118 name: Option<Symbol>,
119 extra: Option<Id>,
120 ) -> Id {
121 let make_part = |def_id: DefId, name: Option<Symbol>, extra: Option<Id>| {
122 let name = match name {
123 Some(name) => Some(name),
124 None => {
125 // We need this workaround because primitive types' DefId actually refers to
126 // their parent module, which isn't present in the output JSON items. So
127 // instead, we directly get the primitive symbol
128 if matches!(self.tcx.def_kind(def_id), DefKind::Mod)
129 && let Some(prim) = self
130 .tcx
131 .get_attrs(def_id, sym::rustc_doc_primitive)
132 .find_map(|attr| attr.value_str())
133 {
134 Some(prim)
135 } else {
136 self.tcx.opt_item_name(def_id)
137 }
138 }
139 };
140
141 FullItemId { def_id, name, extra }
142 };
143
144 let key = match item_id {
145 ItemId::DefId(did) => (make_part(did, name, extra), None),
146 ItemId::Blanket { for_, impl_id } => {
147 (make_part(impl_id, None, None), Some(make_part(for_, name, extra)))
148 }
149 ItemId::Auto { for_, trait_ } => {
150 (make_part(trait_, None, None), Some(make_part(for_, name, extra)))
151 }
152 };
153
154 let mut interner = self.id_interner.borrow_mut();
155 let len = interner.len();
156 *interner
157 .entry(key)
158 .or_insert_with(|| Id(len.try_into().expect("too many items in a crate")))
159 }
160
161 pub(crate) fn id_from_item(&self, item: &clean::Item) -> Id {
162 match item.kind {
163 clean::ItemKind::ImportItem(ref import) => {
164 let extra =
165 import.source.did.map(ItemId::from).map(|i| self.id_from_item_default(i));
166 self.id_from_item_inner(item.item_id, item.name, extra)
167 }
168 _ => self.id_from_item_inner(item.item_id, item.name, None),
169 }
170 }
171
172 fn ids(&self, items: impl IntoIterator<Item = clean::Item>) -> Vec<Id> {110 fn ids(&self, items: impl IntoIterator<Item = clean::Item>) -> Vec<Id> {
173 items111 items
174 .into_iter()112 .into_iter()
src/librustdoc/json/ids.rs created+122
...@@ -0,0 +1,122 @@
1//! Id handling for rustdoc-json.
2//!
3//! Manages the creation of [`rustdoc_json_types::Id`] and the
4//! fact that these don't correspond exactly to [`DefId`], because
5//! [`rustdoc_json_types::Item`] doesn't correspond exactly to what
6//! other phases think of as an "item".
7
8use rustc_data_structures::fx::FxHashMap;
9use rustc_hir::def::DefKind;
10use rustc_hir::def_id::DefId;
11use rustc_span::{Symbol, sym};
12use rustdoc_json_types as types;
13
14use super::JsonRenderer;
15use crate::clean;
16
17pub(super) type IdInterner = FxHashMap<FullItemId, types::Id>;
18
19#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
20/// An uninterned id.
21///
22/// Each one corresponds to exactly one of both:
23/// 1. [`rustdoc_json_types::Item`].
24/// 2. [`rustdoc_json_types::Id`] transitively (as each `Item` has an `Id`).
25///
26/// It's *broadly* equivalent to a [`DefId`], but needs slightly more information
27/// to fully disambiguate items, because sometimes we choose to split a single HIR
28/// item into multiple JSON items, or have items with no corresponding HIR item.
29pub(super) struct FullItemId {
30 /// The "main" id of the item.
31 ///
32 /// In most cases this uniquely identifies the item, the other fields are just
33 /// used for edge-cases.
34 def_id: DefId,
35
36 /// An extra [`DefId`], which we need for:
37 ///
38 /// 1. Auto-trait impls synthesized by rustdoc.
39 /// 2. Blanket impls synthesized by rustdoc.
40 /// 3. Splitting of reexports of multiple items.
41 ///
42 /// E.g:
43 ///
44 /// ```rust
45 /// mod module {
46 /// pub struct Foo {} // Exists in type namespace
47 /// pub fn Foo(){} // Exists in value namespace
48 /// }
49 ///
50 /// pub use module::Foo; // Imports both items
51 /// ```
52 ///
53 /// In HIR, the `pub use` is just 1 item, but in rustdoc-json it's 2, so
54 /// we need to disambiguate.
55 extra_id: Option<DefId>,
56
57 /// Needed for `#[rustc_doc_primitive]` modules.
58 ///
59 /// For these, 1 [`DefId`] is used for both the primitive and the fake-module
60 /// that holds its docs.
61 ///
62 /// N.B. This only matters when documenting the standard library with
63 /// `--document-private-items`. Maybe we should delete that module, and
64 /// remove this.
65 name: Option<Symbol>,
66}
67
68impl JsonRenderer<'_> {
69 pub(crate) fn id_from_item_default(&self, item_id: clean::ItemId) -> types::Id {
70 self.id_from_item_inner(item_id, None, None)
71 }
72
73 fn id_from_item_inner(
74 &self,
75 item_id: clean::ItemId,
76 name: Option<Symbol>,
77 imported_id: Option<DefId>,
78 ) -> types::Id {
79 let (def_id, extra_id) = match item_id {
80 clean::ItemId::DefId(did) => (did, imported_id),
81 clean::ItemId::Blanket { for_, impl_id } => (for_, Some(impl_id)),
82 clean::ItemId::Auto { for_, trait_ } => (for_, Some(trait_)),
83 };
84
85 let name = match name {
86 Some(name) => Some(name),
87 None => {
88 // We need this workaround because primitive types' DefId actually refers to
89 // their parent module, which isn't present in the output JSON items. So
90 // instead, we directly get the primitive symbol
91 if matches!(self.tcx.def_kind(def_id), DefKind::Mod)
92 && let Some(prim) = self
93 .tcx
94 .get_attrs(def_id, sym::rustc_doc_primitive)
95 .find_map(|attr| attr.value_str())
96 {
97 Some(prim)
98 } else {
99 self.tcx.opt_item_name(def_id)
100 }
101 }
102 };
103
104 let key = FullItemId { def_id, extra_id, name };
105
106 let mut interner = self.id_interner.borrow_mut();
107 let len = interner.len();
108 *interner
109 .entry(key)
110 .or_insert_with(|| types::Id(len.try_into().expect("too many items in a crate")))
111 }
112
113 pub(crate) fn id_from_item(&self, item: &clean::Item) -> types::Id {
114 match item.kind {
115 clean::ItemKind::ImportItem(ref import) => {
116 let imported_id = import.source.did;
117 self.id_from_item_inner(item.item_id, item.name, imported_id)
118 }
119 _ => self.id_from_item_inner(item.item_id, item.name, None),
120 }
121 }
122}
src/librustdoc/json/mod.rs+2-10
...@@ -5,6 +5,7 @@...@@ -5,6 +5,7 @@
5//! docs for usage and details.5//! docs for usage and details.
66
7mod conversions;7mod conversions;
8mod ids;
8mod import_finder;9mod import_finder;
910
10use std::cell::RefCell;11use std::cell::RefCell;
...@@ -16,7 +17,6 @@ use std::rc::Rc;...@@ -16,7 +17,6 @@ use std::rc::Rc;
16use rustc_hir::def_id::{DefId, DefIdSet};17use rustc_hir::def_id::{DefId, DefIdSet};
17use rustc_middle::ty::TyCtxt;18use rustc_middle::ty::TyCtxt;
18use rustc_session::Session;19use rustc_session::Session;
19use rustc_span::Symbol;
20use rustc_span::def_id::LOCAL_CRATE;20use rustc_span::def_id::LOCAL_CRATE;
21use rustdoc_json_types as types;21use rustdoc_json_types as types;
22// It's important to use the FxHashMap from rustdoc_json_types here, instead of22// It's important to use the FxHashMap from rustdoc_json_types here, instead of
...@@ -35,14 +35,6 @@ use crate::formats::cache::Cache;...@@ -35,14 +35,6 @@ use crate::formats::cache::Cache;
35use crate::json::conversions::IntoJson;35use crate::json::conversions::IntoJson;
36use crate::{clean, try_err};36use crate::{clean, try_err};
3737
38#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
39struct FullItemId {
40 def_id: DefId,
41 name: Option<Symbol>,
42 /// Used to distinguish imports of different items with the same name
43 extra: Option<types::Id>,
44}
45
46#[derive(Clone)]38#[derive(Clone)]
47pub(crate) struct JsonRenderer<'tcx> {39pub(crate) struct JsonRenderer<'tcx> {
48 tcx: TyCtxt<'tcx>,40 tcx: TyCtxt<'tcx>,
...@@ -55,7 +47,7 @@ pub(crate) struct JsonRenderer<'tcx> {...@@ -55,7 +47,7 @@ pub(crate) struct JsonRenderer<'tcx> {
55 out_dir: Option<PathBuf>,47 out_dir: Option<PathBuf>,
56 cache: Rc<Cache>,48 cache: Rc<Cache>,
57 imported_items: DefIdSet,49 imported_items: DefIdSet,
58 id_interner: Rc<RefCell<FxHashMap<(FullItemId, Option<FullItemId>), types::Id>>>,50 id_interner: Rc<RefCell<ids::IdInterner>>,
59}51}
6052
61impl<'tcx> JsonRenderer<'tcx> {53impl<'tcx> JsonRenderer<'tcx> {
src/tools/build-manifest/src/main.rs-2
...@@ -386,7 +386,6 @@ impl Builder {...@@ -386,7 +386,6 @@ impl Builder {
386 // NOTE: this profile is effectively deprecated; do not add new components to it.386 // NOTE: this profile is effectively deprecated; do not add new components to it.
387 let mut complete = default;387 let mut complete = default;
388 complete.extend([388 complete.extend([
389 Rls,
390 RustAnalyzer,389 RustAnalyzer,
391 RustSrc,390 RustSrc,
392 LlvmTools,391 LlvmTools,
...@@ -475,7 +474,6 @@ impl Builder {...@@ -475,7 +474,6 @@ impl Builder {
475 // but might be marked as unavailable if they weren't built.474 // but might be marked as unavailable if they weren't built.
476 PkgType::Clippy475 PkgType::Clippy
477 | PkgType::Miri476 | PkgType::Miri
478 | PkgType::Rls
479 | PkgType::RustAnalyzer477 | PkgType::RustAnalyzer
480 | PkgType::Rustfmt478 | PkgType::Rustfmt
481 | PkgType::LlvmTools479 | PkgType::LlvmTools
src/tools/build-manifest/src/versions.rs-3
...@@ -51,7 +51,6 @@ pkg_type! {...@@ -51,7 +51,6 @@ pkg_type! {
51 Cargo = "cargo",51 Cargo = "cargo",
52 HtmlDocs = "rust-docs",52 HtmlDocs = "rust-docs",
53 RustAnalysis = "rust-analysis",53 RustAnalysis = "rust-analysis",
54 Rls = "rls"; preview = true,
55 RustAnalyzer = "rust-analyzer"; preview = true,54 RustAnalyzer = "rust-analyzer"; preview = true,
56 Clippy = "clippy"; preview = true,55 Clippy = "clippy"; preview = true,
57 Rustfmt = "rustfmt"; preview = true,56 Rustfmt = "rustfmt"; preview = true,
...@@ -77,7 +76,6 @@ impl PkgType {...@@ -77,7 +76,6 @@ impl PkgType {
77 fn should_use_rust_version(&self) -> bool {76 fn should_use_rust_version(&self) -> bool {
78 match self {77 match self {
79 PkgType::Cargo => false,78 PkgType::Cargo => false,
80 PkgType::Rls => false,
81 PkgType::RustAnalyzer => false,79 PkgType::RustAnalyzer => false,
82 PkgType::Clippy => false,80 PkgType::Clippy => false,
83 PkgType::Rustfmt => false,81 PkgType::Rustfmt => false,
...@@ -118,7 +116,6 @@ impl PkgType {...@@ -118,7 +116,6 @@ impl PkgType {
118 HtmlDocs => HOSTS,116 HtmlDocs => HOSTS,
119 JsonDocs => HOSTS,117 JsonDocs => HOSTS,
120 RustSrc => &["*"],118 RustSrc => &["*"],
121 Rls => HOSTS,
122 RustAnalyzer => HOSTS,119 RustAnalyzer => HOSTS,
123 Clippy => HOSTS,120 Clippy => HOSTS,
124 Miri => HOSTS,121 Miri => HOSTS,
src/tools/rls/Cargo.toml deleted-8
...@@ -1,8 +0,0 @@
1[package]
2name = "rls"
3version = "2.0.0"
4edition = "2021"
5license = "Apache-2.0/MIT"
6
7[dependencies]
8serde_json = "1.0.83"
src/tools/rls/README.md deleted-6
...@@ -1,6 +0,0 @@
1# RLS Stub
2
3RLS has been replaced with [rust-analyzer](https://rust-analyzer.github.io/).
4
5This directory contains a stub which replaces RLS with a simple LSP server
6which only displays an alert to the user that RLS is no longer available.
src/tools/rls/src/main.rs deleted-102
...@@ -1,102 +0,0 @@
1//! RLS stub.
2//!
3//! This is a small stub that replaces RLS to alert the user that RLS is no
4//! longer available.
5
6use std::error::Error;
7use std::io::{BufRead, Write};
8
9use serde_json::Value;
10
11const ALERT_MSG: &str = "\
12RLS is no longer available as of Rust 1.65.
13Consider migrating to rust-analyzer instead.
14See https://rust-analyzer.github.io/ for installation instructions.
15";
16
17fn main() {
18 if let Err(e) = run() {
19 eprintln!("error: {e}");
20 std::process::exit(1);
21 }
22}
23
24struct Message {
25 method: Option<String>,
26}
27
28fn run() -> Result<(), Box<dyn Error>> {
29 let mut stdin = std::io::stdin().lock();
30 let mut stdout = std::io::stdout().lock();
31
32 let init = read_message(&mut stdin)?;
33 if init.method.as_deref() != Some("initialize") {
34 return Err(format!("expected initialize, got {:?}", init.method).into());
35 }
36 // No response, the LSP specification says that `showMessageRequest` may
37 // be posted before during this phase.
38
39 // message_type 1 is "Error"
40 let alert = serde_json::json!({
41 "jsonrpc": "2.0",
42 "id": 1,
43 "method": "window/showMessageRequest",
44 "params": {
45 "message_type": "1",
46 "message": ALERT_MSG
47 }
48 });
49 write_message_raw(&mut stdout, serde_json::to_string(&alert).unwrap())?;
50
51 loop {
52 let message = read_message(&mut stdin)?;
53 if message.method.as_deref() == Some("shutdown") {
54 std::process::exit(0);
55 }
56 }
57}
58
59fn read_message_raw<R: BufRead>(reader: &mut R) -> Result<String, Box<dyn Error>> {
60 let mut content_length: usize = 0;
61
62 // Read headers.
63 loop {
64 let mut line = String::new();
65 reader.read_line(&mut line)?;
66 if line.is_empty() {
67 return Err("remote disconnected".into());
68 }
69 if line == "\r\n" {
70 break;
71 }
72 if line.to_lowercase().starts_with("content-length:") {
73 let value = &line[15..].trim();
74 content_length = usize::from_str_radix(value, 10)?;
75 }
76 }
77 if content_length == 0 {
78 return Err("no content-length".into());
79 }
80
81 let mut buffer = vec![0; content_length];
82 reader.read_exact(&mut buffer)?;
83 let content = String::from_utf8(buffer)?;
84
85 Ok(content)
86}
87
88fn read_message<R: BufRead>(reader: &mut R) -> Result<Message, Box<dyn Error>> {
89 let m = read_message_raw(reader)?;
90 match serde_json::from_str::<Value>(&m) {
91 Ok(message) => Ok(Message {
92 method: message.get("method").and_then(|value| value.as_str().map(String::from)),
93 }),
94 Err(e) => Err(format!("failed to parse message {m}\n{e}").into()),
95 }
96}
97
98fn write_message_raw<W: Write>(mut writer: W, output: String) -> Result<(), Box<dyn Error>> {
99 write!(writer, "Content-Length: {}\r\n\r\n{}", output.len(), output)?;
100 writer.flush()?;
101 Ok(())
102}
src/tools/tidy/src/walk.rs-2
...@@ -32,8 +32,6 @@ pub fn filter_dirs(path: &Path) -> bool {...@@ -32,8 +32,6 @@ pub fn filter_dirs(path: &Path) -> bool {
32 "src/doc/rustc-dev-guide",32 "src/doc/rustc-dev-guide",
33 "src/doc/reference",33 "src/doc/reference",
34 "src/gcc",34 "src/gcc",
35 // Filter RLS output directories
36 "target/rls",
37 "src/bootstrap/target",35 "src/bootstrap/target",
38 "vendor",36 "vendor",
39 ];37 ];
tests/codegen/naked-fn/naked-functions.rs+48-24
...@@ -1,10 +1,12 @@...@@ -1,10 +1,12 @@
1//@ add-core-stubs1//@ add-core-stubs
2//@ revisions: linux win macos thumb2//@ revisions: linux win_x86 win_i686 macos thumb
3//3//
4//@[linux] compile-flags: --target x86_64-unknown-linux-gnu4//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
5//@[linux] needs-llvm-components: x865//@[linux] needs-llvm-components: x86
6//@[win] compile-flags: --target x86_64-pc-windows-gnu6//@[win_x86] compile-flags: --target x86_64-pc-windows-gnu
7//@[win] needs-llvm-components: x867//@[win_x86] needs-llvm-components: x86
8//@[win_i686] compile-flags: --target i686-pc-windows-gnu
9//@[win_i686] needs-llvm-components: x86
8//@[macos] compile-flags: --target aarch64-apple-darwin10//@[macos] compile-flags: --target aarch64-apple-darwin
9//@[macos] needs-llvm-components: arm11//@[macos] needs-llvm-components: arm
10//@[thumb] compile-flags: --target thumbv7em-none-eabi12//@[thumb] compile-flags: --target thumbv7em-none-eabi
...@@ -19,10 +21,11 @@ use minicore::*;...@@ -19,10 +21,11 @@ use minicore::*;
1921
20// linux,win: .intel_syntax22// linux,win: .intel_syntax
21//23//
22// linux: .pushsection .text.naked_empty,\22ax\22, @progbits24// linux: .pushsection .text.naked_empty,\22ax\22, @progbits
23// macos: .pushsection __TEXT,__text,regular,pure_instructions25// macos: .pushsection __TEXT,__text,regular,pure_instructions
24// win: .pushsection .text.naked_empty,\22xr\2226// win_x86: .pushsection .text.naked_empty,\22xr\22
25// thumb: .pushsection .text.naked_empty,\22ax\22, %progbits27// win_i686: .pushsection .text._naked_empty,\22xr\22
28// thumb: .pushsection .text.naked_empty,\22ax\22, %progbits
26//29//
27// CHECK: .balign 430// CHECK: .balign 4
28//31//
...@@ -34,10 +37,12 @@ use minicore::*;...@@ -34,10 +37,12 @@ use minicore::*;
34//37//
35// linux: .type naked_empty, @function38// linux: .type naked_empty, @function
36//39//
37// win: .def naked_empty40// win_x86: .def naked_empty
38// win: .scl 241// win_i686: .def _naked_empty
39// win: .type 3242//
40// win: .endef naked_empty43// win_x86,win_i686: .scl 2
44// win_x86,win_i686: .type 32
45// win_x86,win_i686: .endef
41//46//
42// thumb: .type naked_empty, %function47// thumb: .type naked_empty, %function
43// thumb: .thumb48// thumb: .thumb
...@@ -66,10 +71,11 @@ pub unsafe extern "C" fn naked_empty() {...@@ -66,10 +71,11 @@ pub unsafe extern "C" fn naked_empty() {
6671
67// linux,win: .intel_syntax72// linux,win: .intel_syntax
68//73//
69// linux: .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits74// linux: .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits
70// macos: .pushsection __TEXT,__text,regular,pure_instructions75// macos: .pushsection __TEXT,__text,regular,pure_instructions
71// win: .pushsection .text.naked_with_args_and_return,\22xr\2276// win_x86: .pushsection .text.naked_with_args_and_return,\22xr\22
72// thumb: .pushsection .text.naked_with_args_and_return,\22ax\22, %progbits77// win_i686: .pushsection .text._naked_with_args_and_return,\22xr\22
78// thumb: .pushsection .text.naked_with_args_and_return,\22ax\22, %progbits
73//79//
74// CHECK: .balign 480// CHECK: .balign 4
75//81//
...@@ -81,10 +87,12 @@ pub unsafe extern "C" fn naked_empty() {...@@ -81,10 +87,12 @@ pub unsafe extern "C" fn naked_empty() {
81//87//
82// linux: .type naked_with_args_and_return, @function88// linux: .type naked_with_args_and_return, @function
83//89//
84// win: .def naked_with_args_and_return90// win_x86: .def naked_with_args_and_return
85// win: .scl 291// win_i686: .def _naked_with_args_and_return
86// win: .type 3292//
87// win: .endef naked_with_args_and_return93// win_x86,win_i686: .scl 2
94// win_x86,win_i686: .type 32
95// win_x86,win_i686: .endef
88//96//
89// thumb: .type naked_with_args_and_return, %function97// thumb: .type naked_with_args_and_return, %function
90// thumb: .thumb98// thumb: .thumb
...@@ -92,7 +100,7 @@ pub unsafe extern "C" fn naked_empty() {...@@ -92,7 +100,7 @@ pub unsafe extern "C" fn naked_empty() {
92//100//
93// CHECK-LABEL: naked_with_args_and_return:101// CHECK-LABEL: naked_with_args_and_return:
94//102//
95// linux, win: lea rax, [rdi + rsi]103// linux, win_x86,win_i686: lea rax, [rdi + rsi]
96// macos: add x0, x0, x1104// macos: add x0, x0, x1
97// thumb: adds r0, r0, r1105// thumb: adds r0, r0, r1
98//106//
...@@ -124,10 +132,10 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize...@@ -124,10 +132,10 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize
124 }132 }
125}133}
126134
127// linux: .pushsection .text.some_different_name,\22ax\22, @progbits135// linux: .pushsection .text.some_different_name,\22ax\22, @progbits
128// macos: .pushsection .text.some_different_name,regular,pure_instructions136// macos: .pushsection .text.some_different_name,regular,pure_instructions
129// win: .pushsection .text.some_different_name,\22xr\22137// win_x86,win_i686: .pushsection .text.some_different_name,\22xr\22
130// thumb: .pushsection .text.some_different_name,\22ax\22, %progbits138// thumb: .pushsection .text.some_different_name,\22ax\22, %progbits
131// CHECK-LABEL: test_link_section:139// CHECK-LABEL: test_link_section:
132#[no_mangle]140#[no_mangle]
133#[naked]141#[naked]
...@@ -139,3 +147,19 @@ pub unsafe extern "C" fn test_link_section() {...@@ -139,3 +147,19 @@ pub unsafe extern "C" fn test_link_section() {
139 #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]147 #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]
140 naked_asm!("bx lr");148 naked_asm!("bx lr");
141}149}
150
151// win_x86: .def fastcall_cc
152// win_i686: .def @fastcall_cc@4
153//
154// win_x86,win_i686: .scl 2
155// win_x86,win_i686: .type 32
156// win_x86,win_i686: .endef
157//
158// win_x86-LABEL: fastcall_cc:
159// win_i686-LABEL: @fastcall_cc@4:
160#[cfg(target_os = "windows")]
161#[no_mangle]
162#[naked]
163pub unsafe extern "fastcall" fn fastcall_cc(x: i32) -> i32 {
164 naked_asm!("ret");
165}
tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff+5-5
...@@ -55,16 +55,16 @@...@@ -55,16 +55,16 @@
55 bb3: {55 bb3: {
56 StorageDead(_9);56 StorageDead(_9);
57- _0 = AllCopy { a: move _2, b: move _5, c: move _8 };57- _0 = AllCopy { a: move _2, b: move _5, c: move _8 };
58- StorageDead(_10);
58+ _0 = copy (*_1);59+ _0 = copy (*_1);
60+ nop;
59 StorageDead(_8);61 StorageDead(_8);
60 StorageDead(_5);
61 StorageDead(_2);
62- StorageDead(_10);
63- StorageDead(_7);62- StorageDead(_7);
64- StorageDead(_4);
65+ nop;
66+ nop;63+ nop;
64 StorageDead(_5);
65- StorageDead(_4);
67+ nop;66+ nop;
67 StorageDead(_2);
68 return;68 return;
69 }69 }
70 }70 }
tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-after-simplifycfg.panic-abort.diff+3-3
...@@ -53,12 +53,12 @@...@@ -53,12 +53,12 @@
53 bb3: {53 bb3: {
54 StorageDead(_9);54 StorageDead(_9);
55 _0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };55 _0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };
56 StorageDead(_8);
57 StorageDead(_5);
58 StorageDead(_2);
59 StorageDead(_10);56 StorageDead(_10);
57 StorageDead(_8);
60 StorageDead(_7);58 StorageDead(_7);
59 StorageDead(_5);
61 StorageDead(_4);60 StorageDead(_4);
61 StorageDead(_2);
62 return;62 return;
63 }63 }
64 }64 }
tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-after-simplifycfg.panic-unwind.diff+3-3
...@@ -53,12 +53,12 @@...@@ -53,12 +53,12 @@
53 bb3: {53 bb3: {
54 StorageDead(_9);54 StorageDead(_9);
55 _0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };55 _0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };
56 StorageDead(_8);
57 StorageDead(_5);
58 StorageDead(_2);
59 StorageDead(_10);56 StorageDead(_10);
57 StorageDead(_8);
60 StorageDead(_7);58 StorageDead(_7);
59 StorageDead(_5);
61 StorageDead(_4);60 StorageDead(_4);
61 StorageDead(_2);
62 return;62 return;
63 }63 }
64 64
tests/run-make/core-no-fp-fmt-parse/rmake.rs+1-1
...@@ -5,7 +5,7 @@ use run_make_support::{rustc, source_root};...@@ -5,7 +5,7 @@ use run_make_support::{rustc, source_root};
55
6fn main() {6fn main() {
7 rustc()7 rustc()
8 .edition("2021")8 .edition("2024")
9 .arg("-Dwarnings")9 .arg("-Dwarnings")
10 .crate_type("rlib")10 .crate_type("rlib")
11 .input(source_root().join("library/core/src/lib.rs"))11 .input(source_root().join("library/core/src/lib.rs"))
tests/ui/macros/std-2024-macros.rs created+13
...@@ -0,0 +1,13 @@
1// Tests a small handful of macros in the standard library how they handle the
2// new behavior introduced in 2024 that allows `const{}` expressions.
3
4//@ check-pass
5
6fn main() {
7 assert_eq!(0, const { 0 });
8 assert_eq!(const { 0 }, const { 0 });
9 assert_eq!(const { 0 }, 0);
10
11 let _: Vec<Vec<String>> = vec![const { vec![] }];
12 let _: Vec<Vec<String>> = vec![const { vec![] }; 10];
13}