Skip to content

Commit 198addc

Browse files
committed
Auto merge of #97088 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] Kickoff 1.62 beta r? `@Mark-Simulacrum`
2 parents 2a8a0fc + 61aebf7 commit 198addc

File tree

9 files changed

+57
-149
lines changed

9 files changed

+57
-149
lines changed

Cargo.lock

+22-28
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ dependencies = [
364364
"tar",
365365
"tempfile",
366366
"termcolor",
367-
"toml_edit 0.14.3",
367+
"toml_edit",
368368
"unicode-width",
369369
"unicode-xid",
370370
"url 2.2.2",
@@ -451,7 +451,7 @@ dependencies = [
451451
"snapbox",
452452
"tar",
453453
"termcolor",
454-
"toml_edit 0.14.3",
454+
"toml_edit",
455455
"url 2.2.2",
456456
]
457457

@@ -2041,15 +2041,6 @@ dependencies = [
20412041
"unicase",
20422042
]
20432043

2044-
[[package]]
2045-
name = "kstring"
2046-
version = "1.0.6"
2047-
source = "registry+https://github.com/rust-lang/crates.io-index"
2048-
checksum = "8b310ccceade8121d7d77fee406160e457c2f4e7c7982d589da3499bc7ea4526"
2049-
dependencies = [
2050-
"serde",
2051-
]
2052-
20532044
[[package]]
20542045
name = "kstring"
20552046
version = "2.0.0"
@@ -3003,19 +2994,35 @@ dependencies = [
30032994
[[package]]
30042995
name = "racer"
30052996
version = "2.2.2"
3006-
source = "registry+https://github.com/rust-lang/crates.io-index"
3007-
checksum = "64954e44fc0d1dcc64e0b9f2b155249ad62849eba25354b76ae1598d1e8f0fa0"
30082997
dependencies = [
30092998
"bitflags",
30102999
"clap 2.34.0",
30113000
"derive_more",
30123001
"env_logger 0.7.1",
30133002
"humantime 2.0.1",
30143003
"lazy_static",
3004+
"lazycell",
30153005
"log",
3006+
"racer-cargo-metadata",
30163007
"rls-span",
30173008
]
30183009

3010+
[[package]]
3011+
name = "racer-cargo-metadata"
3012+
version = "0.1.2"
3013+
dependencies = [
3014+
"racer-interner",
3015+
"serde",
3016+
"serde_json",
3017+
]
3018+
3019+
[[package]]
3020+
name = "racer-interner"
3021+
version = "0.1.0"
3022+
dependencies = [
3023+
"serde",
3024+
]
3025+
30193026
[[package]]
30203027
name = "rand"
30213028
version = "0.7.3"
@@ -3246,7 +3253,7 @@ dependencies = [
32463253
"tokio-stream",
32473254
"tokio-util",
32483255
"toml",
3249-
"toml_edit 0.13.4",
3256+
"toml_edit",
32503257
"url 2.2.2",
32513258
"walkdir",
32523259
]
@@ -5320,19 +5327,6 @@ dependencies = [
53205327
"serde",
53215328
]
53225329

5323-
[[package]]
5324-
name = "toml_edit"
5325-
version = "0.13.4"
5326-
source = "registry+https://github.com/rust-lang/crates.io-index"
5327-
checksum = "744e9ed5b352340aa47ce033716991b5589e23781acb97cad37d4ea70560f55b"
5328-
dependencies = [
5329-
"combine",
5330-
"indexmap",
5331-
"itertools",
5332-
"kstring 1.0.6",
5333-
"serde",
5334-
]
5335-
53365330
[[package]]
53375331
name = "toml_edit"
53385332
version = "0.14.3"
@@ -5342,7 +5336,7 @@ dependencies = [
53425336
"combine",
53435337
"indexmap",
53445338
"itertools",
5345-
"kstring 2.0.0",
5339+
"kstring",
53465340
"serde",
53475341
]
53485342

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ members = [
2828
"src/tools/cargo/crates/credential/cargo-credential-wincred",
2929
"src/tools/rustdoc",
3030
"src/tools/rls",
31+
"src/tools/rls/racer/metadata",
32+
"src/tools/rls/racer/interner",
3133
"src/tools/rustfmt",
3234
"src/tools/miri",
3335
"src/tools/miri/cargo-miri",

library/std/src/os/windows/io/handle.rs

-12
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,6 @@ impl OwnedHandle {
204204
})?;
205205
unsafe { Ok(Self::from_raw_handle(ret)) }
206206
}
207-
208-
/// Allow child processes to inherit the handle.
209-
pub(crate) fn set_inheritable(&self) -> io::Result<()> {
210-
cvt(unsafe {
211-
c::SetHandleInformation(
212-
self.as_raw_handle(),
213-
c::HANDLE_FLAG_INHERIT,
214-
c::HANDLE_FLAG_INHERIT,
215-
)
216-
})?;
217-
Ok(())
218-
}
219207
}
220208

221209
impl TryFrom<HandleOrInvalid> for OwnedHandle {

library/std/src/sys/windows/c.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1022,12 +1022,6 @@ extern "system" {
10221022
bWaitAll: BOOL,
10231023
dwMilliseconds: DWORD,
10241024
) -> DWORD;
1025-
pub fn CreatePipe(
1026-
hReadPipe: *mut HANDLE,
1027-
hWritePipe: *mut HANDLE,
1028-
lpPipeAttributes: *const SECURITY_ATTRIBUTES,
1029-
nSize: DWORD,
1030-
) -> BOOL;
10311025
pub fn CreateNamedPipeW(
10321026
lpName: LPCWSTR,
10331027
dwOpenMode: DWORD,

library/std/src/sys/windows/handle.rs

-4
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ impl Handle {
221221
Ok(Self(self.0.duplicate(access, inherit, options)?))
222222
}
223223

224-
pub(crate) fn set_inheritable(&self) -> io::Result<()> {
225-
self.0.set_inheritable()
226-
}
227-
228224
/// Performs a synchronous read.
229225
///
230226
/// If the handle is opened for asynchronous I/O then this abort the process.

library/std/src/sys/windows/pipe.rs

+25-65
Original file line numberDiff line numberDiff line change
@@ -18,56 +18,20 @@ use crate::sys_common::IntoInner;
1818
// Anonymous pipes
1919
////////////////////////////////////////////////////////////////////////////////
2020

21-
// A 64kb pipe capacity is the same as a typical Linux default.
22-
const PIPE_BUFFER_CAPACITY: u32 = 64 * 1024;
23-
24-
pub enum AnonPipe {
25-
Sync(Handle),
26-
Async(Handle),
21+
pub struct AnonPipe {
22+
inner: Handle,
2723
}
2824

2925
impl IntoInner<Handle> for AnonPipe {
3026
fn into_inner(self) -> Handle {
31-
match self {
32-
Self::Sync(handle) => handle,
33-
Self::Async(handle) => handle,
34-
}
27+
self.inner
3528
}
3629
}
3730

3831
pub struct Pipes {
3932
pub ours: AnonPipe,
4033
pub theirs: AnonPipe,
4134
}
42-
impl Pipes {
43-
/// Create a new pair of pipes where both pipes are synchronous.
44-
///
45-
/// These must not be used asynchronously.
46-
pub fn new_synchronous(
47-
ours_readable: bool,
48-
their_handle_inheritable: bool,
49-
) -> io::Result<Self> {
50-
unsafe {
51-
// If `CreatePipe` succeeds, these will be our pipes.
52-
let mut read = ptr::null_mut();
53-
let mut write = ptr::null_mut();
54-
55-
if c::CreatePipe(&mut read, &mut write, ptr::null(), PIPE_BUFFER_CAPACITY) == 0 {
56-
Err(io::Error::last_os_error())
57-
} else {
58-
let (ours, theirs) = if ours_readable { (read, write) } else { (write, read) };
59-
let ours = Handle::from_raw_handle(ours);
60-
let theirs = Handle::from_raw_handle(theirs);
61-
62-
if their_handle_inheritable {
63-
theirs.set_inheritable()?;
64-
}
65-
66-
Ok(Pipes { ours: AnonPipe::Sync(ours), theirs: AnonPipe::Sync(theirs) })
67-
}
68-
}
69-
}
70-
}
7135

7236
/// Although this looks similar to `anon_pipe` in the Unix module it's actually
7337
/// subtly different. Here we'll return two pipes in the `Pipes` return value,
@@ -89,6 +53,9 @@ impl Pipes {
8953
/// with `OVERLAPPED` instances, but also works out ok if it's only ever used
9054
/// once at a time (which we do indeed guarantee).
9155
pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Result<Pipes> {
56+
// A 64kb pipe capacity is the same as a typical Linux default.
57+
const PIPE_BUFFER_CAPACITY: u32 = 64 * 1024;
58+
9259
// Note that we specifically do *not* use `CreatePipe` here because
9360
// unfortunately the anonymous pipes returned do not support overlapped
9461
// operations. Instead, we create a "hopefully unique" name and create a
@@ -189,9 +156,12 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
189156
};
190157
opts.security_attributes(&mut sa);
191158
let theirs = File::open(Path::new(&name), &opts)?;
192-
let theirs = AnonPipe::Sync(theirs.into_inner());
159+
let theirs = AnonPipe { inner: theirs.into_inner() };
193160

194-
Ok(Pipes { ours: AnonPipe::Async(ours), theirs })
161+
Ok(Pipes {
162+
ours: AnonPipe { inner: ours },
163+
theirs: AnonPipe { inner: theirs.into_inner() },
164+
})
195165
}
196166
}
197167

@@ -201,12 +171,12 @@ pub fn anon_pipe(ours_readable: bool, their_handle_inheritable: bool) -> io::Res
201171
/// This is achieved by creating a new set of pipes and spawning a thread that
202172
/// relays messages between the source and the synchronous pipe.
203173
pub fn spawn_pipe_relay(
204-
source: &Handle,
174+
source: &AnonPipe,
205175
ours_readable: bool,
206176
their_handle_inheritable: bool,
207177
) -> io::Result<AnonPipe> {
208178
// We need this handle to live for the lifetime of the thread spawned below.
209-
let source = AnonPipe::Async(source.duplicate(0, true, c::DUPLICATE_SAME_ACCESS)?);
179+
let source = source.duplicate()?;
210180

211181
// create a new pair of anon pipes.
212182
let Pipes { theirs, ours } = anon_pipe(ours_readable, their_handle_inheritable)?;
@@ -257,24 +227,19 @@ type AlertableIoFn = unsafe extern "system" fn(
257227

258228
impl AnonPipe {
259229
pub fn handle(&self) -> &Handle {
260-
match self {
261-
Self::Async(ref handle) => handle,
262-
Self::Sync(ref handle) => handle,
263-
}
230+
&self.inner
264231
}
265232
pub fn into_handle(self) -> Handle {
266-
self.into_inner()
233+
self.inner
234+
}
235+
fn duplicate(&self) -> io::Result<Self> {
236+
self.inner.duplicate(0, false, c::DUPLICATE_SAME_ACCESS).map(|inner| AnonPipe { inner })
267237
}
268238

269239
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
270240
let result = unsafe {
271241
let len = crate::cmp::min(buf.len(), c::DWORD::MAX as usize) as c::DWORD;
272-
match self {
273-
Self::Sync(ref handle) => handle.read(buf),
274-
Self::Async(_) => {
275-
self.alertable_io_internal(c::ReadFileEx, buf.as_mut_ptr() as _, len)
276-
}
277-
}
242+
self.alertable_io_internal(c::ReadFileEx, buf.as_mut_ptr() as _, len)
278243
};
279244

280245
match result {
@@ -288,33 +253,28 @@ impl AnonPipe {
288253
}
289254

290255
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
291-
io::default_read_vectored(|buf| self.read(buf), bufs)
256+
self.inner.read_vectored(bufs)
292257
}
293258

294259
#[inline]
295260
pub fn is_read_vectored(&self) -> bool {
296-
false
261+
self.inner.is_read_vectored()
297262
}
298263

299264
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
300265
unsafe {
301266
let len = crate::cmp::min(buf.len(), c::DWORD::MAX as usize) as c::DWORD;
302-
match self {
303-
Self::Sync(ref handle) => handle.write(buf),
304-
Self::Async(_) => {
305-
self.alertable_io_internal(c::WriteFileEx, buf.as_ptr() as _, len)
306-
}
307-
}
267+
self.alertable_io_internal(c::WriteFileEx, buf.as_ptr() as _, len)
308268
}
309269
}
310270

311271
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
312-
io::default_write_vectored(|buf| self.write(buf), bufs)
272+
self.inner.write_vectored(bufs)
313273
}
314274

315275
#[inline]
316276
pub fn is_write_vectored(&self) -> bool {
317-
false
277+
self.inner.is_write_vectored()
318278
}
319279

320280
/// Synchronizes asynchronous reads or writes using our anonymous pipe.
@@ -386,7 +346,7 @@ impl AnonPipe {
386346

387347
// Asynchronous read of the pipe.
388348
// If successful, `callback` will be called once it completes.
389-
let result = io(self.handle().as_handle(), buf, len, &mut overlapped, callback);
349+
let result = io(self.inner.as_handle(), buf, len, &mut overlapped, callback);
390350
if result == c::FALSE {
391351
// We can return here because the call failed.
392352
// After this we must not return until the I/O completes.

0 commit comments

Comments
 (0)