Skip to content

Rollup of 16 pull requests #58665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 66 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
eb5b096
RangeInclusive internal iteration performance improvement.
matthieu-m Feb 3, 2019
a15916b
[WIP] add better error message for partial move
clintfred Feb 5, 2019
50be479
Updated RELEASES.md for 1.33.0
Feb 6, 2019
d4c52bf
error output updated by ./x.py test --stage 1 src/test/ui --increment…
clintfred Feb 6, 2019
6c71e7d
Update RELEASES.md
Aaronepower Feb 7, 2019
fb3ae57
Update RELEASES.md
mark-i-m Feb 9, 2019
4fed67f
Fix exhaustion of inclusive range try_fold and try_rfold
matthieu-m Feb 9, 2019
73921f6
Update RELEASES.md
Centril Feb 12, 2019
8a026f1
Update RELEASES.md
Centril Feb 12, 2019
4c0a3d5
Update RELEASES.md
Centril Feb 12, 2019
ee3371e
Update RELEASES.md
Centril Feb 12, 2019
4e5eda3
compute is_partial_move outside of the move_site loop for clarity
clintfred Feb 13, 2019
a496450
Update RELEASES.md
Centril Feb 13, 2019
96fd218
check if `used_place` and `moved_place` are equal when determining if…
clintfred Feb 13, 2019
755b320
simplified conditional
clintfred Feb 13, 2019
283ffcf
Check the self-type of inherent associated constants
matthewjasper Feb 11, 2019
347a42e
SGX target: fix panic = abort
Feb 14, 2019
503e74e
Fix SECURITY_SQOS_PRESENT missing
pitdicker Feb 6, 2019
9295f49
Correct OpenOptions::security_qos_flags documentation
pitdicker Feb 6, 2019
c34aac7
help suggestion when trying to delimit string literals with directed …
pmccarter Feb 17, 2019
71cd4c8
ui test for directed quote help suggestion #58436
pmccarter Feb 17, 2019
d26bf74
Change `Token::interpolated_to_tokenstream()`.
nnethercote Feb 14, 2019
f8801f3
Remove `LazyTokenStream`.
nnethercote Feb 14, 2019
f0d8fbd
Avoid a `clone()` in `transcribe()`.
nnethercote Feb 15, 2019
82ad4f1
Make `interpolated_to_tokenstream` a method on `Nonterminal`.
nnethercote Feb 17, 2019
895a794
Remove some unnecessary `into()` calls.
nnethercote Feb 17, 2019
de05548
re-blessing error output: ./x.py test src/test/ui --stage 1 --bless
clintfred Feb 18, 2019
0651157
Remove sys::*::Stderr Write implementation
pitdicker Feb 11, 2019
cc20ed6
Remove unused Read implementation on sys::Windows::Stdin
pitdicker Feb 14, 2019
f411852
Refactor Windows stdio and remove stdin double buffering
pitdicker Feb 14, 2019
8e219e7
Turn duration consts into associated consts
Feb 20, 2019
2621564
Update RELEASES.md
Aaronepower Feb 20, 2019
d072510
Update RELEASES.md
Aaronepower Feb 20, 2019
02fe6a7
./x.py test src/test/ui --stage 1 --bless -i --compare-mode=nll
clintfred Feb 20, 2019
b09803e
Address review comments
pitdicker Feb 19, 2019
6464e32
Use standard Read/Write traits in sys::stdio
pitdicker Feb 20, 2019
f223c03
Add examples for duration constants
Feb 20, 2019
36f18f2
Allow Self::Module to be mutated.
gabi-250 Feb 20, 2019
42d749c
Update RELEASES.md
tspiteri Feb 20, 2019
c6d24cd
Enable feature duration_constants in examples
Feb 21, 2019
8060eb4
Update RELEASES.md
Aaronepower Feb 21, 2019
0ab2aed
Update RELEASES.md
Aaronepower Feb 21, 2019
e5d1fa5
codegen and write_metadata can mutate ModuleLLvm.
gabi-250 Feb 21, 2019
9f58c5f
Optimise vec![false; N] to zero-alloc
RReverser Feb 21, 2019
bba0ea2
rustdoc: support methods on primitives in intra-doc links
tspiteri Feb 22, 2019
b5ae4d5
Don't generate minification variable if minification disabled
GuillaumeGomez Feb 22, 2019
e555854
Make target pointer-width specific variants of (very old) huge-array-…
pnkfelix Feb 22, 2019
b72ba05
Switch from error patterns to `//~ ERROR` markers.
pnkfelix Feb 22, 2019
fda51c2
Update RELEASES.md
Centril Feb 22, 2019
cc1cd83
Do not underflow after resetting unmatched braces count
estebank Feb 22, 2019
fd89cfe
Rollup merge of #58122 - matthieu-m:range_incl_perf, r=dtolnay
Centril Feb 23, 2019
6dabab9
Rollup merge of #58199 - clintfred:partial-move-err-msg, r=estebank
Centril Feb 23, 2019
e018763
Rollup merge of #58216 - pitdicker:sqos_flags, r=alexcrichton
Centril Feb 23, 2019
fc517c7
Rollup merge of #58227 - Aaronepower:master, r=Centril
Centril Feb 23, 2019
bad788a
Rollup merge of #58353 - matthewjasper:typeck-pattern-constants, r=ar…
Centril Feb 23, 2019
c96cecb
Rollup merge of #58453 - jethrogb:jb/sgx-panic-abort, r=nagisa
Centril Feb 23, 2019
27cc893
Rollup merge of #58454 - pitdicker:windows_stdio, r=alexcrichton
Centril Feb 23, 2019
117747d
Rollup merge of #58476 - nnethercote:rm-LazyTokenStream, r=petrochenkov
Centril Feb 23, 2019
ff11324
Rollup merge of #58526 - pmccarter:master, r=estebank
Centril Feb 23, 2019
cd76d58
Rollup merge of #58595 - stjepang:make-duration-consts-associated, r=…
Centril Feb 23, 2019
9c2875d
Rollup merge of #58609 - gabi-250:mutable-refs, r=oli-obk
Centril Feb 23, 2019
9364b14
Rollup merge of #58628 - RReverser:optimise-vec-false, r=oli-obk
Centril Feb 23, 2019
0cd3fd1
Rollup merge of #58642 - tspiteri:intra-rustdoc-prim-method, r=Guilla…
Centril Feb 23, 2019
3e8543f
Rollup merge of #58643 - GuillaumeGomez:extra-variables, r=Manishearth
Centril Feb 23, 2019
49c79de
Rollup merge of #58648 - pnkfelix:issue-23926-update-tests, r=nikomat…
Centril Feb 23, 2019
78f835e
Rollup merge of #58654 - estebank:underflow, r=nikomatsakis
Centril Feb 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments
  • Loading branch information
pitdicker committed Feb 20, 2019
commit b09803e8694b3ad83f988e30b4f0a3903ebe2632
58 changes: 36 additions & 22 deletions src/libstd/sys/windows/stdio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![unstable(issue = "0", feature = "windows_stdio")]

use cell::Cell;
use char::decode_utf16;
use cmp;
use io;
use ptr;
Expand Down Expand Up @@ -64,22 +65,27 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
//
// If the data is not valid UTF-8 we write out as many bytes as are valid.
// Only when there are no valid bytes (which will happen on the next call), return an error.
let len = cmp::min(data.len(), MAX_BUFFER_SIZE);
let len = cmp::min(data.len(), MAX_BUFFER_SIZE / 2);
let utf8 = match str::from_utf8(&data[..len]) {
Ok(s) => s,
Err(ref e) if e.valid_up_to() == 0 => {
return Err(io::Error::new(io::ErrorKind::InvalidData,
"Windows stdio in console mode does not support non-UTF-8 byte sequences; \
see https://github.com/rust-lang/rust/issues/23344"))
"Windows stdio in console mode does not support writing non-UTF-8 byte sequences"))
},
Err(e) => str::from_utf8(&data[..e.valid_up_to()]).unwrap(),
};
let utf16 = utf8.encode_utf16().collect::<Vec<u16>>();
let mut utf16 = [0u16; MAX_BUFFER_SIZE / 2];
let mut len_utf16 = 0;
for (chr, dest) in utf8.encode_utf16().zip(utf16.iter_mut()) {
*dest = chr;
len_utf16 += 1;
}
let utf16 = &utf16[..len_utf16];

let mut written = write_u16s(handle, &utf16)?;

// Figure out how many bytes of as UTF-8 were written away as UTF-16.
if written >= utf16.len() {
if written == utf16.len() {
Ok(utf8.len())
} else {
// Make sure we didn't end up writing only half of a surrogate pair (even though the chance
Expand All @@ -90,7 +96,7 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
let first_char_remaining = utf16[written];
if first_char_remaining >= 0xDCEE && first_char_remaining <= 0xDFFF { // low surrogate
// We just hope this works, and give up otherwise
let _ = write_u16s(handle, &utf16[written..written]);
let _ = write_u16s(handle, &utf16[written..written+1]);
written += 1;
}
// Calculate the number of bytes of `utf8` that were actually written.
Expand All @@ -103,6 +109,7 @@ fn write(handle_id: c::DWORD, data: &[u8]) -> io::Result<usize> {
_ => 3,
};
}
debug_assert!(String::from_utf16(&utf16[..written]).unwrap() == utf8[..count]);
Ok(count)
}
}
Expand Down Expand Up @@ -137,7 +144,7 @@ impl Stdin {
return Ok(0);
} else if buf.len() < 4 {
return Err(io::Error::new(io::ErrorKind::InvalidInput,
"Windows stdin in console mode does not support a buffer too small to; \
"Windows stdin in console mode does not support a buffer too small to \
guarantee holding one arbitrary UTF-8 character (4 bytes)"))
}

Expand All @@ -147,27 +154,14 @@ impl Stdin {
// lost.
let amount = cmp::min(buf.len() / 3, utf16_buf.len());
let read = self.read_u16s_fixup_surrogates(handle, &mut utf16_buf, amount)?;
let utf16 = &utf16_buf[..read];

// FIXME: it would be nice if we could directly decode into the buffer instead of doing an
// allocation.
let data = match String::from_utf16(&utf16) {
Ok(utf8) => utf8.into_bytes(),
Err(..) => {
// We can't really do any better than forget all data and return an error.
return Err(io::Error::new(io::ErrorKind::InvalidData,
"Windows stdin in console mode does not support non-UTF-16 input; \
encountered unpaired surrogate"))
},
};
buf.copy_from_slice(&data);
Ok(data.len())
utf16_to_utf8(&utf16_buf[..read], buf)
}

// We assume that if the last `u16` is an unpaired surrogate they got sliced apart by our
// buffer size, and keep it around for the next read hoping to put them together.
// This is a best effort, and may not work if we are not the only reader on Stdin.
pub fn read_u16s_fixup_surrogates(&self, handle: c::HANDLE, buf: &mut [u16], mut amount: usize)
fn read_u16s_fixup_surrogates(&self, handle: c::HANDLE, buf: &mut [u16], mut amount: usize)
-> io::Result<usize>
{
// Insert possibly remaining unpaired surrogate from last read.
Expand Down Expand Up @@ -223,6 +217,26 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [u16]) -> io::Result<usize> {
Ok(amount as usize)
}

#[allow(unused)]
fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result<usize> {
let mut written = 0;
for chr in decode_utf16(utf16.iter().cloned()) {
match chr {
Ok(chr) => {
chr.encode_utf8(&mut utf8[written..]);
written += chr.len_utf8();
}
Err(_) => {
// We can't really do any better than forget all data and return an error.
return Err(io::Error::new(io::ErrorKind::InvalidData,
"Windows stdin in console mode does not support non-UTF-16 input; \
encountered unpaired surrogate"))
}
}
}
Ok(written)
}

impl Stdout {
pub fn new() -> io::Result<Stdout> {
Ok(Stdout)
Expand Down