Skip to content

Commit 6d0bb91

Browse files
committedJan 15, 2020
Auto merge of #68248 - JohnTitor:rollup-x0kml5f, r=JohnTitor
Rollup of 12 pull requests Successful merges: - #67784 (Reset Formatter flags on exit from pad_integral) - #67914 (Don't run const propagation on items with inconsistent bounds) - #68141 (use winapi for non-stdlib Windows bindings) - #68211 (Add failing example for E0170 explanation) - #68219 (Untangle ZST validation from integer validation and generalize it to all zsts) - #68222 (Update the wasi-libc bundled with libstd) - #68226 (Avoid calling tcx.hir().get() on CRATE_HIR_ID) - #68227 (Update to a version of cmake with windows arm64 support) - #68229 (Update iovec to a version with no winapi dependency) - #68230 (Update libssh2-sys to a version that can build for aarch64-pc-windows…) - #68231 (Better support for cross compilation on Windows.) - #68233 (Update compiler_builtins with changes to fix 128 bit integer remainder for aarch64 windows.) Failed merges: r? @ghost
2 parents c74353c + d2840e6 commit 6d0bb91

File tree

37 files changed

+306
-310
lines changed

37 files changed

+306
-310
lines changed
 

‎Cargo.lock

+14-9
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ dependencies = [
207207
"serde_json",
208208
"time",
209209
"toml",
210+
"winapi 0.3.8",
210211
]
211212

212213
[[package]]
@@ -520,9 +521,9 @@ dependencies = [
520521

521522
[[package]]
522523
name = "cmake"
523-
version = "0.1.38"
524+
version = "0.1.42"
524525
source = "registry+https://github.com/rust-lang/crates.io-index"
525-
checksum = "96210eec534fc3fbfc0452a63769424eaa80205fda6cea98e5b61cb3d97bcec8"
526+
checksum = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62"
526527
dependencies = [
527528
"cc",
528529
]
@@ -576,9 +577,9 @@ dependencies = [
576577

577578
[[package]]
578579
name = "compiler_builtins"
579-
version = "0.1.22"
580+
version = "0.1.24"
580581
source = "registry+https://github.com/rust-lang/crates.io-index"
581-
checksum = "e6f083abf9bb9005a27d2da62706f661245278cb7096da37ab27410eaf60f2c1"
582+
checksum = "b9975aefa63997ef75ca9cf013ff1bb81487aaa0b622c21053afd3b92979a7af"
582583
dependencies = [
583584
"cc",
584585
"rustc-std-workspace-core",
@@ -1587,12 +1588,11 @@ dependencies = [
15871588

15881589
[[package]]
15891590
name = "iovec"
1590-
version = "0.1.2"
1591+
version = "0.1.4"
15911592
source = "registry+https://github.com/rust-lang/crates.io-index"
1592-
checksum = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
1593+
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
15931594
dependencies = [
15941595
"libc",
1595-
"winapi 0.2.8",
15961596
]
15971597

15981598
[[package]]
@@ -1812,9 +1812,9 @@ dependencies = [
18121812

18131813
[[package]]
18141814
name = "libssh2-sys"
1815-
version = "0.2.11"
1815+
version = "0.2.14"
18161816
source = "registry+https://github.com/rust-lang/crates.io-index"
1817-
checksum = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d"
1817+
checksum = "36aa6e813339d3a063292b77091dfbbb6152ff9006a459895fa5bebed7d34f10"
18181818
dependencies = [
18191819
"cc",
18201820
"libc",
@@ -3497,6 +3497,7 @@ dependencies = [
34973497
"serialize",
34983498
"smallvec 1.0.0",
34993499
"stable_deref_trait",
3500+
"winapi 0.3.8",
35003501
]
35013502

35023503
[[package]]
@@ -3524,6 +3525,7 @@ dependencies = [
35243525
"rustc_target",
35253526
"serialize",
35263527
"syntax",
3528+
"winapi 0.3.8",
35273529
]
35283530

35293531
[[package]]
@@ -3543,6 +3545,7 @@ dependencies = [
35433545
"term_size",
35443546
"termcolor",
35453547
"unicode-width",
3548+
"winapi 0.3.8",
35463549
]
35473550

35483551
[[package]]
@@ -3654,6 +3657,7 @@ dependencies = [
36543657
"smallvec 1.0.0",
36553658
"syntax",
36563659
"tempfile",
3660+
"winapi 0.3.8",
36573661
]
36583662

36593663
[[package]]
@@ -3723,6 +3727,7 @@ dependencies = [
37233727
"smallvec 1.0.0",
37243728
"stable_deref_trait",
37253729
"syntax",
3730+
"winapi 0.3.8",
37263731
]
37273732

37283733
[[package]]

‎src/bootstrap/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,9 @@ lazy_static = "1.3.0"
4949
time = "0.1"
5050
ignore = "0.4.10"
5151

52+
[target.'cfg(windows)'.dependencies.winapi]
53+
version = "0.3"
54+
features = ["fileapi", "ioapiset", "jobapi2", "handleapi", "winioctl"]
55+
5256
[dev-dependencies]
5357
pretty_assertions = "0.5"

‎src/bootstrap/job.rs

+10-78
Original file line numberDiff line numberDiff line change
@@ -35,84 +35,16 @@ use std::io;
3535
use std::mem;
3636
use std::ptr;
3737

38-
type HANDLE = *mut u8;
39-
type BOOL = i32;
40-
type DWORD = u32;
41-
type LPHANDLE = *mut HANDLE;
42-
type LPVOID = *mut u8;
43-
type JOBOBJECTINFOCLASS = i32;
44-
type SIZE_T = usize;
45-
type LARGE_INTEGER = i64;
46-
type UINT = u32;
47-
type ULONG_PTR = usize;
48-
type ULONGLONG = u64;
49-
50-
const FALSE: BOOL = 0;
51-
const DUPLICATE_SAME_ACCESS: DWORD = 0x2;
52-
const PROCESS_DUP_HANDLE: DWORD = 0x40;
53-
const JobObjectExtendedLimitInformation: JOBOBJECTINFOCLASS = 9;
54-
const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: DWORD = 0x2000;
55-
const JOB_OBJECT_LIMIT_PRIORITY_CLASS: DWORD = 0x00000020;
56-
const SEM_FAILCRITICALERRORS: UINT = 0x0001;
57-
const SEM_NOGPFAULTERRORBOX: UINT = 0x0002;
58-
const BELOW_NORMAL_PRIORITY_CLASS: DWORD = 0x00004000;
59-
60-
extern "system" {
61-
fn CreateJobObjectW(lpJobAttributes: *mut u8, lpName: *const u8) -> HANDLE;
62-
fn CloseHandle(hObject: HANDLE) -> BOOL;
63-
fn GetCurrentProcess() -> HANDLE;
64-
fn OpenProcess(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwProcessId: DWORD) -> HANDLE;
65-
fn DuplicateHandle(
66-
hSourceProcessHandle: HANDLE,
67-
hSourceHandle: HANDLE,
68-
hTargetProcessHandle: HANDLE,
69-
lpTargetHandle: LPHANDLE,
70-
dwDesiredAccess: DWORD,
71-
bInheritHandle: BOOL,
72-
dwOptions: DWORD,
73-
) -> BOOL;
74-
fn AssignProcessToJobObject(hJob: HANDLE, hProcess: HANDLE) -> BOOL;
75-
fn SetInformationJobObject(
76-
hJob: HANDLE,
77-
JobObjectInformationClass: JOBOBJECTINFOCLASS,
78-
lpJobObjectInformation: LPVOID,
79-
cbJobObjectInformationLength: DWORD,
80-
) -> BOOL;
81-
fn SetErrorMode(mode: UINT) -> UINT;
82-
}
83-
84-
#[repr(C)]
85-
struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
86-
BasicLimitInformation: JOBOBJECT_BASIC_LIMIT_INFORMATION,
87-
IoInfo: IO_COUNTERS,
88-
ProcessMemoryLimit: SIZE_T,
89-
JobMemoryLimit: SIZE_T,
90-
PeakProcessMemoryUsed: SIZE_T,
91-
PeakJobMemoryUsed: SIZE_T,
92-
}
93-
94-
#[repr(C)]
95-
struct IO_COUNTERS {
96-
ReadOperationCount: ULONGLONG,
97-
WriteOperationCount: ULONGLONG,
98-
OtherOperationCount: ULONGLONG,
99-
ReadTransferCount: ULONGLONG,
100-
WriteTransferCount: ULONGLONG,
101-
OtherTransferCount: ULONGLONG,
102-
}
103-
104-
#[repr(C)]
105-
struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
106-
PerProcessUserTimeLimit: LARGE_INTEGER,
107-
PerJobUserTimeLimit: LARGE_INTEGER,
108-
LimitFlags: DWORD,
109-
MinimumWorkingsetSize: SIZE_T,
110-
MaximumWorkingsetSize: SIZE_T,
111-
ActiveProcessLimit: DWORD,
112-
Affinity: ULONG_PTR,
113-
PriorityClass: DWORD,
114-
SchedulingClass: DWORD,
115-
}
38+
use winapi::shared::minwindef::{DWORD, FALSE, LPVOID};
39+
use winapi::um::errhandlingapi::SetErrorMode;
40+
use winapi::um::handleapi::{CloseHandle, DuplicateHandle};
41+
use winapi::um::jobapi2::{AssignProcessToJobObject, CreateJobObjectW, SetInformationJobObject};
42+
use winapi::um::processthreadsapi::{GetCurrentProcess, OpenProcess};
43+
use winapi::um::winbase::{BELOW_NORMAL_PRIORITY_CLASS, SEM_NOGPFAULTERRORBOX};
44+
use winapi::um::winnt::{
45+
JobObjectExtendedLimitInformation, DUPLICATE_SAME_ACCESS, JOBOBJECT_EXTENDED_LIMIT_INFORMATION,
46+
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, JOB_OBJECT_LIMIT_PRIORITY_CLASS, PROCESS_DUP_HANDLE,
47+
};
11648

11749
pub unsafe fn setup(build: &mut Build) {
11850
// Enable the Windows Error Reporting dialog which msys disables,

‎src/bootstrap/native.rs

+2
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ impl Step for Llvm {
230230
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
231231
} else if target.contains("freebsd") {
232232
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
233+
} else if target.contains("windows") {
234+
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
233235
}
234236

235237
cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build"));

‎src/bootstrap/util.rs

+13-49
Original file line numberDiff line numberDiff line change
@@ -123,37 +123,24 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
123123
// what can be found here:
124124
//
125125
// http://www.flexhex.com/docs/articles/hard-links.phtml
126-
//
127-
// Copied from std
128126
#[cfg(windows)]
129-
#[allow(nonstandard_style)]
130127
fn symlink_dir_inner(target: &Path, junction: &Path) -> io::Result<()> {
131128
use std::ffi::OsStr;
132129
use std::os::windows::ffi::OsStrExt;
133130
use std::ptr;
134131

135-
const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: usize = 16 * 1024;
136-
const GENERIC_WRITE: DWORD = 0x40000000;
137-
const OPEN_EXISTING: DWORD = 3;
138-
const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
139-
const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
140-
const FSCTL_SET_REPARSE_POINT: DWORD = 0x900a4;
141-
const IO_REPARSE_TAG_MOUNT_POINT: DWORD = 0xa0000003;
142-
const FILE_SHARE_DELETE: DWORD = 0x4;
143-
const FILE_SHARE_READ: DWORD = 0x1;
144-
const FILE_SHARE_WRITE: DWORD = 0x2;
145-
146-
type BOOL = i32;
147-
type DWORD = u32;
148-
type HANDLE = *mut u8;
149-
type LPCWSTR = *const u16;
150-
type LPDWORD = *mut DWORD;
151-
type LPOVERLAPPED = *mut u8;
152-
type LPSECURITY_ATTRIBUTES = *mut u8;
153-
type LPVOID = *mut u8;
154-
type WCHAR = u16;
155-
type WORD = u16;
156-
132+
use winapi::shared::minwindef::{DWORD, WORD};
133+
use winapi::um::fileapi::{CreateFileW, OPEN_EXISTING};
134+
use winapi::um::handleapi::CloseHandle;
135+
use winapi::um::ioapiset::DeviceIoControl;
136+
use winapi::um::winbase::{FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_OPEN_REPARSE_POINT};
137+
use winapi::um::winioctl::FSCTL_SET_REPARSE_POINT;
138+
use winapi::um::winnt::{
139+
FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, GENERIC_WRITE,
140+
IO_REPARSE_TAG_MOUNT_POINT, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, WCHAR,
141+
};
142+
143+
#[allow(non_snake_case)]
157144
#[repr(C)]
158145
struct REPARSE_MOUNTPOINT_DATA_BUFFER {
159146
ReparseTag: DWORD,
@@ -165,29 +152,6 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
165152
ReparseTarget: WCHAR,
166153
}
167154

168-
extern "system" {
169-
fn CreateFileW(
170-
lpFileName: LPCWSTR,
171-
dwDesiredAccess: DWORD,
172-
dwShareMode: DWORD,
173-
lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
174-
dwCreationDisposition: DWORD,
175-
dwFlagsAndAttributes: DWORD,
176-
hTemplateFile: HANDLE,
177-
) -> HANDLE;
178-
fn DeviceIoControl(
179-
hDevice: HANDLE,
180-
dwIoControlCode: DWORD,
181-
lpInBuffer: LPVOID,
182-
nInBufferSize: DWORD,
183-
lpOutBuffer: LPVOID,
184-
nOutBufferSize: DWORD,
185-
lpBytesReturned: LPDWORD,
186-
lpOverlapped: LPOVERLAPPED,
187-
) -> BOOL;
188-
fn CloseHandle(hObject: HANDLE) -> BOOL;
189-
}
190-
191155
fn to_u16s<S: AsRef<OsStr>>(s: S) -> io::Result<Vec<u16>> {
192156
Ok(s.as_ref().encode_wide().chain(Some(0)).collect())
193157
}
@@ -212,7 +176,7 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
212176
ptr::null_mut(),
213177
);
214178

215-
let mut data = [0u8; MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
179+
let mut data = [0u8; MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize];
216180
let db = data.as_mut_ptr() as *mut REPARSE_MOUNTPOINT_DATA_BUFFER;
217181
let buf = &mut (*db).ReparseTarget as *mut u16;
218182
let mut i = 0;

‎src/ci/docker/dist-various-2/build-wasi-toolchain.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export PATH=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-14.04/bin:$PATH
1212
git clone https://github.com/CraneStation/wasi-libc
1313

1414
cd wasi-libc
15-
git reset --hard f645f498dfbbbc00a7a97874d33082d3605c3f21
15+
git reset --hard 1fad33890a5e299027ce0eab7b6ad5260585e347
1616
make -j$(nproc) INSTALL_DIR=/wasm32-wasi install
1717

1818
cd ..

‎src/libcore/fmt/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1244,12 +1244,15 @@ impl<'a> Formatter<'a> {
12441244
// The sign and prefix goes before the padding if the fill character
12451245
// is zero
12461246
Some(min) if self.sign_aware_zero_pad() => {
1247-
self.fill = '0';
1248-
self.align = rt::v1::Alignment::Right;
1247+
let old_fill = crate::mem::replace(&mut self.fill, '0');
1248+
let old_align = crate::mem::replace(&mut self.align, rt::v1::Alignment::Right);
12491249
write_prefix(self, sign, prefix)?;
12501250
let post_padding = self.padding(min - width, rt::v1::Alignment::Right)?;
12511251
self.buf.write_str(buf)?;
1252-
post_padding.write(self.buf)
1252+
post_padding.write(self.buf)?;
1253+
self.fill = old_fill;
1254+
self.align = old_align;
1255+
Ok(())
12531256
}
12541257
// Otherwise, the sign and prefix goes after the padding
12551258
Some(min) => {

‎src/libcore/tests/fmt/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@ fn test_estimated_capacity() {
2828
assert_eq!(format_args!("{}, hello!", "World").estimated_capacity(), 0);
2929
assert_eq!(format_args!("{}. 16-bytes piece", "World").estimated_capacity(), 32);
3030
}
31+
32+
#[test]
33+
fn pad_integral_resets() {
34+
struct Bar;
35+
36+
impl core::fmt::Display for Bar {
37+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
38+
"1".fmt(f)?;
39+
f.pad_integral(true, "", "5")?;
40+
"1".fmt(f)
41+
}
42+
}
43+
44+
assert_eq!(format!("{:<03}", Bar), "1 0051 ");
45+
}

‎src/librustc/infer/opaque_types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ pub fn may_define_opaque_type(tcx: TyCtxt<'_>, def_id: DefId, opaque_hir_id: hir
12191219
let res = hir_id == scope;
12201220
trace!(
12211221
"may_define_opaque_type(def={:?}, opaque_node={:?}) = {}",
1222-
tcx.hir().get(hir_id),
1222+
tcx.hir().find(hir_id),
12231223
tcx.hir().get(opaque_hir_id),
12241224
res
12251225
);

‎src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#![feature(const_transmute)]
3535
#![feature(core_intrinsics)]
3636
#![feature(drain_filter)]
37-
#![cfg_attr(windows, feature(libc))]
3837
#![feature(never_type)]
3938
#![feature(exhaustive_patterns)]
4039
#![feature(overlapping_marker_traits)]

‎src/librustc/mir/mono.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId};
22
use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
33
use crate::session::config::OptLevel;
4+
use crate::traits::TraitQueryMode;
45
use crate::ty::print::obsolete::DefPathBasedNames;
56
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
67
use rustc_data_structures::base_n;
@@ -167,7 +168,9 @@ impl<'tcx> MonoItem<'tcx> {
167168
MonoItem::GlobalAsm(..) => return true,
168169
};
169170

170-
tcx.substitute_normalize_and_test_predicates((def_id, &substs))
171+
// We shouldn't encounter any overflow here, so we use TraitQueryMode::Standard\
172+
// to report an error if overflow somehow occurs.
173+
tcx.substitute_normalize_and_test_predicates((def_id, &substs, TraitQueryMode::Standard))
171174
}
172175

173176
pub fn to_string(&self, tcx: TyCtxt<'tcx>, debug: bool) -> String {

‎src/librustc/query/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1148,11 +1148,11 @@ rustc_queries! {
11481148
desc { "normalizing `{:?}`", goal }
11491149
}
11501150

1151-
query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1151+
query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>, traits::TraitQueryMode)) -> bool {
11521152
no_force
11531153
desc { |tcx|
1154-
"testing substituted normalized predicates:`{}`",
1155-
tcx.def_path_str(key.0)
1154+
"testing substituted normalized predicates in mode {:?}:`{}`",
1155+
key.2, tcx.def_path_str(key.0)
11561156
}
11571157
}
11581158

0 commit comments

Comments
 (0)