Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4d404b3

Browse files
committedMar 19, 2020
Auto merge of #70130 - Centril:rollup-8hk2y7z, r=Centril
Rollup of 9 pull requests Successful merges: - #69036 (rustc: don't resolve Instances which would produce malformed shims.) - #69443 (tidy: Better license checks.) - #69814 (Smaller and more correct generator codegen) - #69929 (Regenerate tables for Unicode 13.0.0) - #69959 (std: Don't abort process when printing panics in tests) - #69969 (unix: Set a guard page at the end of signal stacks) - #70005 ([rustdoc] Improve visibility for code blocks warnings) - #70088 (Use copy bound in atomic operations to generate simpler MIR) - #70095 (Implement -Zlink-native-libraries) Failed merges: r? @ghost
2 parents 57e1da5 + 89dbdc7 commit 4d404b3

File tree

23 files changed

+1174
-874
lines changed

23 files changed

+1174
-874
lines changed
 

‎Cargo.lock

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ dependencies = [
386386

387387
[[package]]
388388
name = "cargo_metadata"
389-
version = "0.9.0"
389+
version = "0.9.1"
390390
source = "registry+https://github.com/rust-lang/crates.io-index"
391-
checksum = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d"
391+
checksum = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202"
392392
dependencies = [
393393
"semver",
394394
"serde",
@@ -450,7 +450,7 @@ dependencies = [
450450
name = "clippy"
451451
version = "0.0.212"
452452
dependencies = [
453-
"cargo_metadata 0.9.0",
453+
"cargo_metadata 0.9.1",
454454
"clippy-mini-macro-test",
455455
"clippy_lints",
456456
"compiletest_rs",
@@ -473,7 +473,7 @@ version = "0.2.0"
473473
name = "clippy_lints"
474474
version = "0.0.212"
475475
dependencies = [
476-
"cargo_metadata 0.9.0",
476+
"cargo_metadata 0.9.1",
477477
"if_chain",
478478
"itertools 0.9.0",
479479
"lazy_static 1.4.0",
@@ -2132,7 +2132,7 @@ name = "miri"
21322132
version = "0.1.0"
21332133
dependencies = [
21342134
"byteorder",
2135-
"cargo_metadata 0.9.0",
2135+
"cargo_metadata 0.9.1",
21362136
"colored",
21372137
"compiletest_rs",
21382138
"directories",
@@ -4860,10 +4860,9 @@ dependencies = [
48604860
name = "tidy"
48614861
version = "0.1.0"
48624862
dependencies = [
4863+
"cargo_metadata 0.9.1",
48634864
"lazy_static 1.4.0",
48644865
"regex",
4865-
"serde",
4866-
"serde_json",
48674866
"walkdir",
48684867
]
48694868

‎src/bootstrap/test.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,6 @@ impl Step for Tidy {
728728
let mut cmd = builder.tool_cmd(Tool::Tidy);
729729
cmd.arg(builder.src.join("src"));
730730
cmd.arg(&builder.initial_cargo);
731-
if !builder.config.vendor {
732-
cmd.arg("--no-vendor");
733-
}
734731
if builder.is_verbose() {
735732
cmd.arg("--verbose");
736733
}

‎src/libcore/sync/atomic.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,7 @@ fn strongest_failure_ordering(order: Ordering) -> Ordering {
22592259
}
22602260

22612261
#[inline]
2262-
unsafe fn atomic_store<T>(dst: *mut T, val: T, order: Ordering) {
2262+
unsafe fn atomic_store<T: Copy>(dst: *mut T, val: T, order: Ordering) {
22632263
match order {
22642264
Release => intrinsics::atomic_store_rel(dst, val),
22652265
Relaxed => intrinsics::atomic_store_relaxed(dst, val),
@@ -2270,7 +2270,7 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order: Ordering) {
22702270
}
22712271

22722272
#[inline]
2273-
unsafe fn atomic_load<T>(dst: *const T, order: Ordering) -> T {
2273+
unsafe fn atomic_load<T: Copy>(dst: *const T, order: Ordering) -> T {
22742274
match order {
22752275
Acquire => intrinsics::atomic_load_acq(dst),
22762276
Relaxed => intrinsics::atomic_load_relaxed(dst),
@@ -2282,7 +2282,7 @@ unsafe fn atomic_load<T>(dst: *const T, order: Ordering) -> T {
22822282

22832283
#[inline]
22842284
#[cfg(target_has_atomic = "8")]
2285-
unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
2285+
unsafe fn atomic_swap<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
22862286
match order {
22872287
Acquire => intrinsics::atomic_xchg_acq(dst, val),
22882288
Release => intrinsics::atomic_xchg_rel(dst, val),
@@ -2295,7 +2295,7 @@ unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
22952295
/// Returns the previous value (like __sync_fetch_and_add).
22962296
#[inline]
22972297
#[cfg(target_has_atomic = "8")]
2298-
unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
2298+
unsafe fn atomic_add<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
22992299
match order {
23002300
Acquire => intrinsics::atomic_xadd_acq(dst, val),
23012301
Release => intrinsics::atomic_xadd_rel(dst, val),
@@ -2308,7 +2308,7 @@ unsafe fn atomic_add<T>(dst: *mut T, val: T, order: Ordering) -> T {
23082308
/// Returns the previous value (like __sync_fetch_and_sub).
23092309
#[inline]
23102310
#[cfg(target_has_atomic = "8")]
2311-
unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
2311+
unsafe fn atomic_sub<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
23122312
match order {
23132313
Acquire => intrinsics::atomic_xsub_acq(dst, val),
23142314
Release => intrinsics::atomic_xsub_rel(dst, val),
@@ -2320,7 +2320,7 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
23202320

23212321
#[inline]
23222322
#[cfg(target_has_atomic = "8")]
2323-
unsafe fn atomic_compare_exchange<T>(
2323+
unsafe fn atomic_compare_exchange<T: Copy>(
23242324
dst: *mut T,
23252325
old: T,
23262326
new: T,
@@ -2346,7 +2346,7 @@ unsafe fn atomic_compare_exchange<T>(
23462346

23472347
#[inline]
23482348
#[cfg(target_has_atomic = "8")]
2349-
unsafe fn atomic_compare_exchange_weak<T>(
2349+
unsafe fn atomic_compare_exchange_weak<T: Copy>(
23502350
dst: *mut T,
23512351
old: T,
23522352
new: T,
@@ -2372,7 +2372,7 @@ unsafe fn atomic_compare_exchange_weak<T>(
23722372

23732373
#[inline]
23742374
#[cfg(target_has_atomic = "8")]
2375-
unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
2375+
unsafe fn atomic_and<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
23762376
match order {
23772377
Acquire => intrinsics::atomic_and_acq(dst, val),
23782378
Release => intrinsics::atomic_and_rel(dst, val),
@@ -2384,7 +2384,7 @@ unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
23842384

23852385
#[inline]
23862386
#[cfg(target_has_atomic = "8")]
2387-
unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
2387+
unsafe fn atomic_nand<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
23882388
match order {
23892389
Acquire => intrinsics::atomic_nand_acq(dst, val),
23902390
Release => intrinsics::atomic_nand_rel(dst, val),
@@ -2396,7 +2396,7 @@ unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
23962396

23972397
#[inline]
23982398
#[cfg(target_has_atomic = "8")]
2399-
unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
2399+
unsafe fn atomic_or<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
24002400
match order {
24012401
Acquire => intrinsics::atomic_or_acq(dst, val),
24022402
Release => intrinsics::atomic_or_rel(dst, val),
@@ -2408,7 +2408,7 @@ unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
24082408

24092409
#[inline]
24102410
#[cfg(target_has_atomic = "8")]
2411-
unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
2411+
unsafe fn atomic_xor<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
24122412
match order {
24132413
Acquire => intrinsics::atomic_xor_acq(dst, val),
24142414
Release => intrinsics::atomic_xor_rel(dst, val),
@@ -2421,7 +2421,7 @@ unsafe fn atomic_xor<T>(dst: *mut T, val: T, order: Ordering) -> T {
24212421
/// returns the max value (signed comparison)
24222422
#[inline]
24232423
#[cfg(target_has_atomic = "8")]
2424-
unsafe fn atomic_max<T>(dst: *mut T, val: T, order: Ordering) -> T {
2424+
unsafe fn atomic_max<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
24252425
match order {
24262426
Acquire => intrinsics::atomic_max_acq(dst, val),
24272427
Release => intrinsics::atomic_max_rel(dst, val),
@@ -2434,7 +2434,7 @@ unsafe fn atomic_max<T>(dst: *mut T, val: T, order: Ordering) -> T {
24342434
/// returns the min value (signed comparison)
24352435
#[inline]
24362436
#[cfg(target_has_atomic = "8")]
2437-
unsafe fn atomic_min<T>(dst: *mut T, val: T, order: Ordering) -> T {
2437+
unsafe fn atomic_min<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
24382438
match order {
24392439
Acquire => intrinsics::atomic_min_acq(dst, val),
24402440
Release => intrinsics::atomic_min_rel(dst, val),
@@ -2447,7 +2447,7 @@ unsafe fn atomic_min<T>(dst: *mut T, val: T, order: Ordering) -> T {
24472447
/// returns the max value (unsigned comparison)
24482448
#[inline]
24492449
#[cfg(target_has_atomic = "8")]
2450-
unsafe fn atomic_umax<T>(dst: *mut T, val: T, order: Ordering) -> T {
2450+
unsafe fn atomic_umax<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
24512451
match order {
24522452
Acquire => intrinsics::atomic_umax_acq(dst, val),
24532453
Release => intrinsics::atomic_umax_rel(dst, val),
@@ -2460,7 +2460,7 @@ unsafe fn atomic_umax<T>(dst: *mut T, val: T, order: Ordering) -> T {
24602460
/// returns the min value (unsigned comparison)
24612461
#[inline]
24622462
#[cfg(target_has_atomic = "8")]
2463-
unsafe fn atomic_umin<T>(dst: *mut T, val: T, order: Ordering) -> T {
2463+
unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
24642464
match order {
24652465
Acquire => intrinsics::atomic_umin_acq(dst, val),
24662466
Release => intrinsics::atomic_umin_rel(dst, val),

‎src/libcore/unicode/printable.rs

Lines changed: 92 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(crate) fn is_printable(x: char) -> bool {
4444
} else if x < 0x20000 {
4545
check(lower, SINGLETONS1U, SINGLETONS1L, NORMAL1)
4646
} else {
47-
if 0x2a6d7 <= x && x < 0x2a700 {
47+
if 0x2a6de <= x && x < 0x2a700 {
4848
return false;
4949
}
5050
if 0x2b735 <= x && x < 0x2b740 {
@@ -59,7 +59,10 @@ pub(crate) fn is_printable(x: char) -> bool {
5959
if 0x2ebe1 <= x && x < 0x2f800 {
6060
return false;
6161
}
62-
if 0x2fa1e <= x && x < 0xe0100 {
62+
if 0x2fa1e <= x && x < 0x30000 {
63+
return false;
64+
}
65+
if 0x3134b <= x && x < 0xe0100 {
6366
return false;
6467
}
6568
if 0xe01f0 <= x && x < 0x110000 {
@@ -81,7 +84,7 @@ const SINGLETONS0U: &[(u8, u8)] = &[
8184
(0x0a, 28),
8285
(0x0b, 25),
8386
(0x0c, 20),
84-
(0x0d, 18),
87+
(0x0d, 16),
8588
(0x0e, 13),
8689
(0x0f, 4),
8790
(0x10, 3),
@@ -96,7 +99,7 @@ const SINGLETONS0U: &[(u8, u8)] = &[
9699
(0x1d, 1),
97100
(0x1f, 22),
98101
(0x20, 3),
99-
(0x2b, 4),
102+
(0x2b, 3),
100103
(0x2c, 2),
101104
(0x2d, 11),
102105
(0x2e, 1),
@@ -129,29 +132,29 @@ const SINGLETONS0L: &[u8] = &[
129132
0x4a, 0x5e, 0x64, 0x65, 0x84, 0x91, 0x9b, 0x9d,
130133
0xc9, 0xce, 0xcf, 0x0d, 0x11, 0x29, 0x45, 0x49,
131134
0x57, 0x64, 0x65, 0x8d, 0x91, 0xa9, 0xb4, 0xba,
132-
0xbb, 0xc5, 0xc9, 0xdf, 0xe4, 0xe5, 0xf0, 0x04,
133-
0x0d, 0x11, 0x45, 0x49, 0x64, 0x65, 0x80, 0x81,
134-
0x84, 0xb2, 0xbc, 0xbe, 0xbf, 0xd5, 0xd7, 0xf0,
135-
0xf1, 0x83, 0x85, 0x8b, 0xa4, 0xa6, 0xbe, 0xbf,
136-
0xc5, 0xc7, 0xce, 0xcf, 0xda, 0xdb, 0x48, 0x98,
137-
0xbd, 0xcd, 0xc6, 0xce, 0xcf, 0x49, 0x4e, 0x4f,
138-
0x57, 0x59, 0x5e, 0x5f, 0x89, 0x8e, 0x8f, 0xb1,
139-
0xb6, 0xb7, 0xbf, 0xc1, 0xc6, 0xc7, 0xd7, 0x11,
140-
0x16, 0x17, 0x5b, 0x5c, 0xf6, 0xf7, 0xfe, 0xff,
141-
0x80, 0x0d, 0x6d, 0x71, 0xde, 0xdf, 0x0e, 0x0f,
142-
0x1f, 0x6e, 0x6f, 0x1c, 0x1d, 0x5f, 0x7d, 0x7e,
143-
0xae, 0xaf, 0xbb, 0xbc, 0xfa, 0x16, 0x17, 0x1e,
144-
0x1f, 0x46, 0x47, 0x4e, 0x4f, 0x58, 0x5a, 0x5c,
145-
0x5e, 0x7e, 0x7f, 0xb5, 0xc5, 0xd4, 0xd5, 0xdc,
146-
0xf0, 0xf1, 0xf5, 0x72, 0x73, 0x8f, 0x74, 0x75,
147-
0x96, 0x97, 0x2f, 0x5f, 0x26, 0x2e, 0x2f, 0xa7,
148-
0xaf, 0xb7, 0xbf, 0xc7, 0xcf, 0xd7, 0xdf, 0x9a,
149-
0x40, 0x97, 0x98, 0x30, 0x8f, 0x1f, 0xc0, 0xc1,
150-
0xce, 0xff, 0x4e, 0x4f, 0x5a, 0x5b, 0x07, 0x08,
151-
0x0f, 0x10, 0x27, 0x2f, 0xee, 0xef, 0x6e, 0x6f,
152-
0x37, 0x3d, 0x3f, 0x42, 0x45, 0x90, 0x91, 0xfe,
153-
0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9, 0xd0, 0xd1,
154-
0xd8, 0xd9, 0xe7, 0xfe, 0xff,
135+
0xbb, 0xc5, 0xc9, 0xdf, 0xe4, 0xe5, 0xf0, 0x0d,
136+
0x11, 0x45, 0x49, 0x64, 0x65, 0x80, 0x84, 0xb2,
137+
0xbc, 0xbe, 0xbf, 0xd5, 0xd7, 0xf0, 0xf1, 0x83,
138+
0x85, 0x8b, 0xa4, 0xa6, 0xbe, 0xbf, 0xc5, 0xc7,
139+
0xce, 0xcf, 0xda, 0xdb, 0x48, 0x98, 0xbd, 0xcd,
140+
0xc6, 0xce, 0xcf, 0x49, 0x4e, 0x4f, 0x57, 0x59,
141+
0x5e, 0x5f, 0x89, 0x8e, 0x8f, 0xb1, 0xb6, 0xb7,
142+
0xbf, 0xc1, 0xc6, 0xc7, 0xd7, 0x11, 0x16, 0x17,
143+
0x5b, 0x5c, 0xf6, 0xf7, 0xfe, 0xff, 0x80, 0x0d,
144+
0x6d, 0x71, 0xde, 0xdf, 0x0e, 0x0f, 0x1f, 0x6e,
145+
0x6f, 0x1c, 0x1d, 0x5f, 0x7d, 0x7e, 0xae, 0xaf,
146+
0xbb, 0xbc, 0xfa, 0x16, 0x17, 0x1e, 0x1f, 0x46,
147+
0x47, 0x4e, 0x4f, 0x58, 0x5a, 0x5c, 0x5e, 0x7e,
148+
0x7f, 0xb5, 0xc5, 0xd4, 0xd5, 0xdc, 0xf0, 0xf1,
149+
0xf5, 0x72, 0x73, 0x8f, 0x74, 0x75, 0x96, 0x2f,
150+
0x5f, 0x26, 0x2e, 0x2f, 0xa7, 0xaf, 0xb7, 0xbf,
151+
0xc7, 0xcf, 0xd7, 0xdf, 0x9a, 0x40, 0x97, 0x98,
152+
0x30, 0x8f, 0x1f, 0xc0, 0xc1, 0xce, 0xff, 0x4e,
153+
0x4f, 0x5a, 0x5b, 0x07, 0x08, 0x0f, 0x10, 0x27,
154+
0x2f, 0xee, 0xef, 0x6e, 0x6f, 0x37, 0x3d, 0x3f,
155+
0x42, 0x45, 0x90, 0x91, 0xfe, 0xff, 0x53, 0x67,
156+
0x75, 0xc8, 0xc9, 0xd0, 0xd1, 0xd8, 0xd9, 0xe7,
157+
0xfe, 0xff,
155158
];
156159
#[rustfmt::skip]
157160
const SINGLETONS1U: &[(u8, u8)] = &[
@@ -163,14 +166,15 @@ const SINGLETONS1U: &[(u8, u8)] = &[
163166
(0x09, 2),
164167
(0x0a, 5),
165168
(0x0b, 2),
169+
(0x0e, 4),
166170
(0x10, 1),
167-
(0x11, 4),
171+
(0x11, 2),
168172
(0x12, 5),
169173
(0x13, 17),
170-
(0x14, 2),
174+
(0x14, 1),
171175
(0x15, 2),
172176
(0x17, 2),
173-
(0x19, 4),
177+
(0x19, 13),
174178
(0x1c, 5),
175179
(0x1d, 8),
176180
(0x24, 1),
@@ -188,32 +192,35 @@ const SINGLETONS1U: &[(u8, u8)] = &[
188192
(0xe8, 2),
189193
(0xee, 32),
190194
(0xf0, 4),
191-
(0xf9, 6),
195+
(0xf8, 2),
196+
(0xf9, 2),
192197
(0xfa, 2),
198+
(0xfb, 1),
193199
];
194200
#[rustfmt::skip]
195201
const SINGLETONS1L: &[u8] = &[
196202
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
197203
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
198204
0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36,
199-
0x37, 0x56, 0x57, 0xbd, 0x35, 0xce, 0xcf, 0xe0,
200-
0x12, 0x87, 0x89, 0x8e, 0x9e, 0x04, 0x0d, 0x0e,
201-
0x11, 0x12, 0x29, 0x31, 0x34, 0x3a, 0x45, 0x46,
202-
0x49, 0x4a, 0x4e, 0x4f, 0x64, 0x65, 0x5a, 0x5c,
203-
0xb6, 0xb7, 0x1b, 0x1c, 0xa8, 0xa9, 0xd8, 0xd9,
204-
0x09, 0x37, 0x90, 0x91, 0xa8, 0x07, 0x0a, 0x3b,
205-
0x3e, 0x66, 0x69, 0x8f, 0x92, 0x6f, 0x5f, 0xee,
206-
0xef, 0x5a, 0x62, 0x9a, 0x9b, 0x27, 0x28, 0x55,
207-
0x9d, 0xa0, 0xa1, 0xa3, 0xa4, 0xa7, 0xa8, 0xad,
208-
0xba, 0xbc, 0xc4, 0x06, 0x0b, 0x0c, 0x15, 0x1d,
209-
0x3a, 0x3f, 0x45, 0x51, 0xa6, 0xa7, 0xcc, 0xcd,
210-
0xa0, 0x07, 0x19, 0x1a, 0x22, 0x25, 0x3e, 0x3f,
211-
0xc5, 0xc6, 0x04, 0x20, 0x23, 0x25, 0x26, 0x28,
212-
0x33, 0x38, 0x3a, 0x48, 0x4a, 0x4c, 0x50, 0x53,
213-
0x55, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x63,
214-
0x65, 0x66, 0x6b, 0x73, 0x78, 0x7d, 0x7f, 0x8a,
215-
0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0, 0x0c, 0x72,
216-
0xa3, 0xa4, 0xcb, 0xcc, 0x6e, 0x6f,
205+
0x37, 0x56, 0x57, 0x7f, 0xaa, 0xae, 0xaf, 0xbd,
206+
0x35, 0xe0, 0x12, 0x87, 0x89, 0x8e, 0x9e, 0x04,
207+
0x0d, 0x0e, 0x11, 0x12, 0x29, 0x31, 0x34, 0x3a,
208+
0x45, 0x46, 0x49, 0x4a, 0x4e, 0x4f, 0x64, 0x65,
209+
0x5c, 0xb6, 0xb7, 0x1b, 0x1c, 0x07, 0x08, 0x0a,
210+
0x0b, 0x14, 0x17, 0x36, 0x39, 0x3a, 0xa8, 0xa9,
211+
0xd8, 0xd9, 0x09, 0x37, 0x90, 0x91, 0xa8, 0x07,
212+
0x0a, 0x3b, 0x3e, 0x66, 0x69, 0x8f, 0x92, 0x6f,
213+
0x5f, 0xee, 0xef, 0x5a, 0x62, 0x9a, 0x9b, 0x27,
214+
0x28, 0x55, 0x9d, 0xa0, 0xa1, 0xa3, 0xa4, 0xa7,
215+
0xa8, 0xad, 0xba, 0xbc, 0xc4, 0x06, 0x0b, 0x0c,
216+
0x15, 0x1d, 0x3a, 0x3f, 0x45, 0x51, 0xa6, 0xa7,
217+
0xcc, 0xcd, 0xa0, 0x07, 0x19, 0x1a, 0x22, 0x25,
218+
0x3e, 0x3f, 0xc5, 0xc6, 0x04, 0x20, 0x23, 0x25,
219+
0x26, 0x28, 0x33, 0x38, 0x3a, 0x48, 0x4a, 0x4c,
220+
0x50, 0x53, 0x55, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
221+
0x60, 0x63, 0x65, 0x66, 0x6b, 0x73, 0x78, 0x7d,
222+
0x7f, 0x8a, 0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0,
223+
0xae, 0xaf, 0x79, 0xcc, 0x6e, 0x6f, 0x93,
217224
];
218225
#[rustfmt::skip]
219226
const NORMAL0: &[u8] = &[
@@ -225,7 +232,7 @@ const NORMAL0: &[u8] = &[
225232
0x06, 0x11,
226233
0x81, 0xac, 0x0e,
227234
0x80, 0xab, 0x35,
228-
0x1e, 0x15,
235+
0x28, 0x0b,
229236
0x80, 0xe0, 0x03,
230237
0x19, 0x08,
231238
0x01, 0x04,
@@ -237,8 +244,8 @@ const NORMAL0: &[u8] = &[
237244
0x11, 0x0a,
238245
0x50, 0x0f,
239246
0x12, 0x07,
240-
0x55, 0x08,
241-
0x02, 0x04,
247+
0x55, 0x07,
248+
0x03, 0x04,
242249
0x1c, 0x0a,
243250
0x09, 0x03,
244251
0x08, 0x03,
@@ -292,7 +299,7 @@ const NORMAL0: &[u8] = &[
292299
0x0b, 0x03,
293300
0x80, 0xac, 0x06,
294301
0x0a, 0x06,
295-
0x1f, 0x41,
302+
0x21, 0x3f,
296303
0x4c, 0x04,
297304
0x2d, 0x03,
298305
0x74, 0x08,
@@ -315,21 +322,19 @@ const NORMAL0: &[u8] = &[
315322
0x3b, 0x07,
316323
0x02, 0x0e,
317324
0x18, 0x09,
318-
0x80, 0xb0, 0x30,
325+
0x80, 0xb3, 0x2d,
319326
0x74, 0x0c,
320327
0x80, 0xd6, 0x1a,
321328
0x0c, 0x05,
322329
0x80, 0xff, 0x05,
323-
0x80, 0xb6, 0x05,
324-
0x24, 0x0c,
325-
0x9b, 0xc6, 0x0a,
326-
0xd2, 0x30, 0x10,
330+
0x80, 0xdf, 0x0c,
331+
0xee, 0x0d, 0x03,
327332
0x84, 0x8d, 0x03,
328333
0x37, 0x09,
329334
0x81, 0x5c, 0x14,
330335
0x80, 0xb8, 0x08,
331-
0x80, 0xc7, 0x30,
332-
0x35, 0x04,
336+
0x80, 0xcb, 0x2a,
337+
0x38, 0x03,
333338
0x0a, 0x06,
334339
0x38, 0x08,
335340
0x46, 0x08,
@@ -341,7 +346,7 @@ const NORMAL0: &[u8] = &[
341346
0x80, 0x83, 0x18,
342347
0x1c, 0x0a,
343348
0x16, 0x09,
344-
0x48, 0x08,
349+
0x4c, 0x04,
345350
0x80, 0x8a, 0x06,
346351
0xab, 0xa4, 0x0c,
347352
0x17, 0x04,
@@ -365,7 +370,7 @@ const NORMAL1: &[u8] = &[
365370
0x7b, 0x05,
366371
0x03, 0x04,
367372
0x2d, 0x03,
368-
0x65, 0x04,
373+
0x66, 0x03,
369374
0x01, 0x2f,
370375
0x2e, 0x80, 0x82,
371376
0x1d, 0x03,
@@ -410,16 +415,17 @@ const NORMAL1: &[u8] = &[
410415
0x33, 0x07,
411416
0x2e, 0x08,
412417
0x0a, 0x81, 0x26,
413-
0x1f, 0x80, 0x81,
418+
0x52, 0x4e,
414419
0x28, 0x08,
415-
0x2a, 0x80, 0x86,
420+
0x2a, 0x56,
421+
0x1c, 0x14,
416422
0x17, 0x09,
417423
0x4e, 0x04,
418424
0x1e, 0x0f,
419425
0x43, 0x0e,
420426
0x19, 0x07,
421427
0x0a, 0x06,
422-
0x47, 0x09,
428+
0x48, 0x08,
423429
0x27, 0x09,
424430
0x75, 0x0b,
425431
0x3f, 0x41,
@@ -430,7 +436,7 @@ const NORMAL1: &[u8] = &[
430436
0x01, 0x05,
431437
0x10, 0x03,
432438
0x05, 0x80, 0x8b,
433-
0x60, 0x20,
439+
0x62, 0x1e,
434440
0x48, 0x08,
435441
0x0a, 0x80, 0xa6,
436442
0x5e, 0x22,
@@ -443,7 +449,8 @@ const NORMAL1: &[u8] = &[
443449
0x10, 0x80, 0xc0,
444450
0x3c, 0x64,
445451
0x53, 0x0c,
446-
0x01, 0x80, 0xa0,
452+
0x48, 0x09,
453+
0x0a, 0x46,
447454
0x45, 0x1b,
448455
0x48, 0x08,
449456
0x53, 0x1d,
@@ -456,7 +463,8 @@ const NORMAL1: &[u8] = &[
456463
0x0a, 0x06,
457464
0x39, 0x07,
458465
0x0a, 0x81, 0x36,
459-
0x19, 0x80, 0xc7,
466+
0x19, 0x80, 0xb7,
467+
0x01, 0x0f,
460468
0x32, 0x0d,
461469
0x83, 0x9b, 0x66,
462470
0x75, 0x0b,
@@ -474,9 +482,11 @@ const NORMAL1: &[u8] = &[
474482
0x4b, 0x04,
475483
0x39, 0x07,
476484
0x11, 0x40,
477-
0x04, 0x1c,
485+
0x05, 0x0b,
486+
0x02, 0x0e,
478487
0x97, 0xf8, 0x08,
479-
0x82, 0xf3, 0xa5, 0x0d,
488+
0x84, 0xd6, 0x2a,
489+
0x09, 0xa2, 0xf7,
480490
0x81, 0x1f, 0x31,
481491
0x03, 0x11,
482492
0x04, 0x08,
@@ -515,30 +525,31 @@ const NORMAL1: &[u8] = &[
515525
0x2c, 0x04,
516526
0x64, 0x0c,
517527
0x56, 0x0a,
518-
0x0d, 0x03,
519-
0x5d, 0x03,
520-
0x3d, 0x39,
528+
0x80, 0xae, 0x38,
521529
0x1d, 0x0d,
522530
0x2c, 0x04,
523531
0x09, 0x07,
524532
0x02, 0x0e,
525533
0x06, 0x80, 0x9a,
526-
0x83, 0xd6, 0x0a,
534+
0x83, 0xd8, 0x08,
535+
0x0d, 0x03,
527536
0x0d, 0x03,
528-
0x0b, 0x05,
529537
0x74, 0x0c,
530538
0x59, 0x07,
531539
0x0c, 0x14,
532540
0x0c, 0x04,
533541
0x38, 0x08,
534542
0x0a, 0x06,
535543
0x28, 0x08,
536-
0x1e, 0x52,
537-
0x77, 0x03,
538-
0x31, 0x03,
539-
0x80, 0xa6, 0x0c,
540-
0x14, 0x04,
544+
0x22, 0x4e,
545+
0x81, 0x54, 0x0c,
546+
0x15, 0x03,
541547
0x03, 0x05,
548+
0x07, 0x09,
549+
0x19, 0x07,
550+
0x07, 0x09,
542551
0x03, 0x0d,
543-
0x06, 0x85, 0x6a,
552+
0x07, 0x29,
553+
0x80, 0xcb, 0x25,
554+
0x0a, 0x84, 0x06,
544555
];

‎src/libcore/unicode/unicode_data.rs

Lines changed: 370 additions & 364 deletions
Large diffs are not rendered by default.

‎src/librustc/ty/instance.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ pub enum InstanceDef<'tcx> {
3939

4040
/// `<fn() as FnTrait>::call_*`
4141
/// `DefId` is `FnTrait::call_*`.
42+
///
43+
/// NB: the (`fn` pointer) type must currently be monomorphic to avoid double substitution
44+
/// problems with the MIR shim bodies. `Instance::resolve` enforces this.
45+
// FIXME(#69925) support polymorphic MIR shim bodies properly instead.
4246
FnPtrShim(DefId, Ty<'tcx>),
4347

4448
/// `<dyn Trait as Trait>::fn`, "direct calls" of which are implicitly
@@ -57,9 +61,17 @@ pub enum InstanceDef<'tcx> {
5761
/// The `DefId` is for `core::ptr::drop_in_place`.
5862
/// The `Option<Ty<'tcx>>` is either `Some(T)`, or `None` for empty drop
5963
/// glue.
64+
///
65+
/// NB: the type must currently be monomorphic to avoid double substitution
66+
/// problems with the MIR shim bodies. `Instance::resolve` enforces this.
67+
// FIXME(#69925) support polymorphic MIR shim bodies properly instead.
6068
DropGlue(DefId, Option<Ty<'tcx>>),
6169

6270
///`<T as Clone>::clone` shim.
71+
///
72+
/// NB: the type must currently be monomorphic to avoid double substitution
73+
/// problems with the MIR shim bodies. `Instance::resolve` enforces this.
74+
// FIXME(#69925) support polymorphic MIR shim bodies properly instead.
6375
CloneShim(DefId, Ty<'tcx>),
6476
}
6577

‎src/librustc_codegen_ssa/back/link.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,10 +1380,17 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
13801380
// link line. And finally upstream native libraries can't depend on anything
13811381
// in this DAG so far because they're only dylibs and dylibs can only depend
13821382
// on other dylibs (e.g., other native deps).
1383-
add_local_native_libraries(cmd, sess, codegen_results);
1383+
//
1384+
// If -Zlink-native-libraries=false is set, then the assumption is that an
1385+
// external build system already has the native dependencies defined, and it
1386+
// will provide them to the linker itself.
1387+
if sess.opts.debugging_opts.link_native_libraries.unwrap_or(true) {
1388+
add_local_native_libraries(cmd, sess, codegen_results);
1389+
}
13841390
add_upstream_rust_crates::<B>(cmd, sess, codegen_results, crate_type, tmpdir);
1385-
add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
1386-
1391+
if sess.opts.debugging_opts.link_native_libraries.unwrap_or(true) {
1392+
add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
1393+
}
13871394
// Tell the linker what we're doing.
13881395
if crate_type != config::CrateType::Executable {
13891396
cmd.build_dylib(out_filename);

‎src/librustc_mir/shim.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use rustc::mir::*;
22
use rustc::ty::layout::VariantIdx;
33
use rustc::ty::query::Providers;
44
use rustc::ty::subst::{InternalSubsts, Subst};
5-
use rustc::ty::{self, Ty, TyCtxt};
5+
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
66
use rustc_hir as hir;
77
use rustc_hir::def_id::DefId;
88

99
use rustc_index::vec::{Idx, IndexVec};
1010

11-
use rustc_span::{sym, Span};
11+
use rustc_span::Span;
1212
use rustc_target::spec::abi::Abi;
1313

1414
use std::fmt;
@@ -39,6 +39,11 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx
3939
None,
4040
),
4141
ty::InstanceDef::FnPtrShim(def_id, ty) => {
42+
// FIXME(eddyb) support generating shims for a "shallow type",
43+
// e.g. `Foo<_>` or `[_]` instead of requiring a fully monomorphic
44+
// `Foo<Bar>` or `[String]` etc.
45+
assert!(!ty.needs_subst());
46+
4247
let trait_ = tcx.trait_of_item(def_id).unwrap();
4348
let adjustment = match tcx.fn_trait_kind_from_lang_item(trait_) {
4449
Some(ty::ClosureKind::FnOnce) => Adjustment::Identity,
@@ -81,17 +86,21 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx
8186
None,
8287
)
8388
}
84-
ty::InstanceDef::DropGlue(def_id, ty) => build_drop_shim(tcx, def_id, ty),
89+
ty::InstanceDef::DropGlue(def_id, ty) => {
90+
// FIXME(eddyb) support generating shims for a "shallow type",
91+
// e.g. `Foo<_>` or `[_]` instead of requiring a fully monomorphic
92+
// `Foo<Bar>` or `[String]` etc.
93+
assert!(!ty.needs_subst());
94+
95+
build_drop_shim(tcx, def_id, ty)
96+
}
8597
ty::InstanceDef::CloneShim(def_id, ty) => {
86-
let name = tcx.item_name(def_id);
87-
if name == sym::clone {
88-
build_clone_shim(tcx, def_id, ty)
89-
} else if name == sym::clone_from {
90-
debug!("make_shim({:?}: using default trait implementation", instance);
91-
return tcx.optimized_mir(def_id);
92-
} else {
93-
bug!("builtin clone shim {:?} not supported", instance)
94-
}
98+
// FIXME(eddyb) support generating shims for a "shallow type",
99+
// e.g. `Foo<_>` or `[_]` instead of requiring a fully monomorphic
100+
// `Foo<Bar>` or `[String]` etc.
101+
assert!(!ty.needs_subst());
102+
103+
build_clone_shim(tcx, def_id, ty)
95104
}
96105
ty::InstanceDef::Virtual(..) => {
97106
bug!("InstanceDef::Virtual ({:?}) is for direct calls only", instance)

‎src/librustc_mir/transform/generator.rs

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -988,18 +988,101 @@ fn insert_panic_block<'tcx>(
988988
assert_block
989989
}
990990

991+
fn can_return<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
992+
// Returning from a function with an uninhabited return type is undefined behavior.
993+
if body.return_ty().conservative_is_privately_uninhabited(tcx) {
994+
return false;
995+
}
996+
997+
// If there's a return terminator the function may return.
998+
for block in body.basic_blocks() {
999+
if let TerminatorKind::Return = block.terminator().kind {
1000+
return true;
1001+
}
1002+
}
1003+
1004+
// Otherwise the function can't return.
1005+
false
1006+
}
1007+
1008+
fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
1009+
// Nothing can unwind when landing pads are off.
1010+
if tcx.sess.no_landing_pads() {
1011+
return false;
1012+
}
1013+
1014+
// Unwinds can only start at certain terminators.
1015+
for block in body.basic_blocks() {
1016+
match block.terminator().kind {
1017+
// These never unwind.
1018+
TerminatorKind::Goto { .. }
1019+
| TerminatorKind::SwitchInt { .. }
1020+
| TerminatorKind::Abort
1021+
| TerminatorKind::Return
1022+
| TerminatorKind::Unreachable
1023+
| TerminatorKind::GeneratorDrop
1024+
| TerminatorKind::FalseEdges { .. }
1025+
| TerminatorKind::FalseUnwind { .. } => {}
1026+
1027+
// Resume will *continue* unwinding, but if there's no other unwinding terminator it
1028+
// will never be reached.
1029+
TerminatorKind::Resume => {}
1030+
1031+
TerminatorKind::Yield { .. } => {
1032+
unreachable!("`can_unwind` called before generator transform")
1033+
}
1034+
1035+
// These may unwind.
1036+
TerminatorKind::Drop { .. }
1037+
| TerminatorKind::DropAndReplace { .. }
1038+
| TerminatorKind::Call { .. }
1039+
| TerminatorKind::Assert { .. } => return true,
1040+
}
1041+
}
1042+
1043+
// If we didn't find an unwinding terminator, the function cannot unwind.
1044+
false
1045+
}
1046+
9911047
fn create_generator_resume_function<'tcx>(
9921048
tcx: TyCtxt<'tcx>,
9931049
transform: TransformVisitor<'tcx>,
9941050
def_id: DefId,
9951051
source: MirSource<'tcx>,
9961052
body: &mut BodyAndCache<'tcx>,
1053+
can_return: bool,
9971054
) {
1055+
let can_unwind = can_unwind(tcx, body);
1056+
9981057
// Poison the generator when it unwinds
999-
for block in body.basic_blocks_mut() {
1000-
let source_info = block.terminator().source_info;
1001-
if let &TerminatorKind::Resume = &block.terminator().kind {
1002-
block.statements.push(transform.set_discr(VariantIdx::new(POISONED), source_info));
1058+
if can_unwind {
1059+
let poison_block = BasicBlock::new(body.basic_blocks().len());
1060+
let source_info = source_info(body);
1061+
body.basic_blocks_mut().push(BasicBlockData {
1062+
statements: vec![transform.set_discr(VariantIdx::new(POISONED), source_info)],
1063+
terminator: Some(Terminator { source_info, kind: TerminatorKind::Resume }),
1064+
is_cleanup: true,
1065+
});
1066+
1067+
for (idx, block) in body.basic_blocks_mut().iter_enumerated_mut() {
1068+
let source_info = block.terminator().source_info;
1069+
1070+
if let TerminatorKind::Resume = block.terminator().kind {
1071+
// An existing `Resume` terminator is redirected to jump to our dedicated
1072+
// "poisoning block" above.
1073+
if idx != poison_block {
1074+
*block.terminator_mut() = Terminator {
1075+
source_info,
1076+
kind: TerminatorKind::Goto { target: poison_block },
1077+
};
1078+
}
1079+
} else if !block.is_cleanup {
1080+
// Any terminators that *can* unwind but don't have an unwind target set are also
1081+
// pointed at our poisoning block (unless they're part of the cleanup path).
1082+
if let Some(unwind @ None) = block.terminator_mut().unwind_mut() {
1083+
*unwind = Some(poison_block);
1084+
}
1085+
}
10031086
}
10041087
}
10051088

@@ -1012,8 +1095,20 @@ fn create_generator_resume_function<'tcx>(
10121095

10131096
// Panic when resumed on the returned or poisoned state
10141097
let generator_kind = body.generator_kind.unwrap();
1015-
cases.insert(1, (RETURNED, insert_panic_block(tcx, body, ResumedAfterReturn(generator_kind))));
1016-
cases.insert(2, (POISONED, insert_panic_block(tcx, body, ResumedAfterPanic(generator_kind))));
1098+
1099+
if can_unwind {
1100+
cases.insert(
1101+
1,
1102+
(POISONED, insert_panic_block(tcx, body, ResumedAfterPanic(generator_kind))),
1103+
);
1104+
}
1105+
1106+
if can_return {
1107+
cases.insert(
1108+
1,
1109+
(RETURNED, insert_panic_block(tcx, body, ResumedAfterReturn(generator_kind))),
1110+
);
1111+
}
10171112

10181113
insert_switch(body, cases, &transform, TerminatorKind::Unreachable);
10191114

@@ -1197,6 +1292,8 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
11971292
let (remap, layout, storage_liveness) =
11981293
compute_layout(tcx, source, &upvars, interior, movable, body);
11991294

1295+
let can_return = can_return(tcx, body);
1296+
12001297
// Run the transformation which converts Places from Local to generator struct
12011298
// accesses for locals in `remap`.
12021299
// It also rewrites `return x` and `yield y` as writing a new generator state and returning
@@ -1240,6 +1337,6 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
12401337
body.generator_drop = Some(box drop_shim);
12411338

12421339
// Create the Generator::resume function
1243-
create_generator_resume_function(tcx, transform, def_id, source, body);
1340+
create_generator_resume_function(tcx, transform, def_id, source, body, can_return);
12441341
}
12451342
}

‎src/librustc_session/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,4 +968,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
968968
"link the `.rlink` file generated by `-Z no-link`"),
969969
new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
970970
"use new LLVM pass manager"),
971+
link_native_libraries: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
972+
"Link native libraries in the linker invocation."),
971973
}

‎src/librustc_ty/instance.rs

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc::ty::subst::SubstsRef;
22
use rustc::ty::{self, Instance, TyCtxt, TypeFoldable};
33
use rustc_hir::def_id::DefId;
4+
use rustc_span::sym;
45
use rustc_target::spec::abi::Abi;
56
use rustc_trait_selection::traits;
67

@@ -31,21 +32,26 @@ pub fn resolve_instance<'tcx>(
3132
debug!(" => intrinsic");
3233
ty::InstanceDef::Intrinsic(def_id)
3334
}
34-
_ => {
35-
if Some(def_id) == tcx.lang_items().drop_in_place_fn() {
36-
let ty = substs.type_at(0);
37-
if ty.needs_drop(tcx, param_env.with_reveal_all()) {
38-
debug!(" => nontrivial drop glue");
39-
ty::InstanceDef::DropGlue(def_id, Some(ty))
40-
} else {
41-
debug!(" => trivial drop glue");
42-
ty::InstanceDef::DropGlue(def_id, None)
35+
ty::FnDef(def_id, substs) if Some(def_id) == tcx.lang_items().drop_in_place_fn() => {
36+
let ty = substs.type_at(0);
37+
38+
if ty.needs_drop(tcx, param_env) {
39+
// `DropGlue` requires a monomorphic aka concrete type.
40+
if ty.needs_subst() {
41+
return None;
4342
}
43+
44+
debug!(" => nontrivial drop glue");
45+
ty::InstanceDef::DropGlue(def_id, Some(ty))
4446
} else {
45-
debug!(" => free item");
46-
ty::InstanceDef::Item(def_id)
47+
debug!(" => trivial drop glue");
48+
ty::InstanceDef::DropGlue(def_id, None)
4749
}
4850
}
51+
_ => {
52+
debug!(" => free item");
53+
ty::InstanceDef::Item(def_id)
54+
}
4955
};
5056
Some(Instance { def, substs })
5157
};
@@ -113,20 +119,44 @@ fn resolve_associated_item<'tcx>(
113119
trait_closure_kind,
114120
))
115121
}
116-
traits::VtableFnPointer(ref data) => Some(Instance {
117-
def: ty::InstanceDef::FnPtrShim(trait_item.def_id, data.fn_ty),
118-
substs: rcvr_substs,
119-
}),
122+
traits::VtableFnPointer(ref data) => {
123+
// `FnPtrShim` requires a monomorphic aka concrete type.
124+
if data.fn_ty.needs_subst() {
125+
return None;
126+
}
127+
128+
Some(Instance {
129+
def: ty::InstanceDef::FnPtrShim(trait_item.def_id, data.fn_ty),
130+
substs: rcvr_substs,
131+
})
132+
}
120133
traits::VtableObject(ref data) => {
121134
let index = traits::get_vtable_index_of_object_method(tcx, data, def_id);
122135
Some(Instance { def: ty::InstanceDef::Virtual(def_id, index), substs: rcvr_substs })
123136
}
124137
traits::VtableBuiltin(..) => {
125-
if tcx.lang_items().clone_trait().is_some() {
126-
Some(Instance {
127-
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
128-
substs: rcvr_substs,
129-
})
138+
if Some(trait_ref.def_id) == tcx.lang_items().clone_trait() {
139+
// FIXME(eddyb) use lang items for methods instead of names.
140+
let name = tcx.item_name(def_id);
141+
if name == sym::clone {
142+
let self_ty = trait_ref.self_ty();
143+
144+
// `CloneShim` requires a monomorphic aka concrete type.
145+
if self_ty.needs_subst() {
146+
return None;
147+
}
148+
149+
Some(Instance {
150+
def: ty::InstanceDef::CloneShim(def_id, self_ty),
151+
substs: rcvr_substs,
152+
})
153+
} else {
154+
assert_eq!(name, sym::clone_from);
155+
156+
// Use the default `fn clone_from` from `trait Clone`.
157+
let substs = tcx.erase_regions(&rcvr_substs);
158+
Some(ty::Instance::new(def_id, substs))
159+
}
130160
} else {
131161
None
132162
}

‎src/librustdoc/html/static/rustdoc.css

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
10321032

10331033
.information {
10341034
position: absolute;
1035-
left: -20px;
1035+
left: -25px;
10361036
margin-top: 7px;
10371037
z-index: 1;
10381038
}
@@ -1047,12 +1047,13 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
10471047
width: 120px;
10481048
display: none;
10491049
text-align: center;
1050-
padding: 5px 3px;
1050+
padding: 5px 3px 3px 3px;
10511051
border-radius: 6px;
10521052
margin-left: 5px;
10531053
top: -5px;
10541054
left: 105%;
10551055
z-index: 10;
1056+
font-size: 16px;
10561057
}
10571058

10581059
.tooltip:hover .tooltiptext {
@@ -1063,14 +1064,20 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
10631064
content: " ";
10641065
position: absolute;
10651066
top: 50%;
1066-
left: 11px;
1067+
left: 16px;
10671068
margin-top: -5px;
10681069
border-width: 5px;
10691070
border-style: solid;
10701071
}
10711072

1073+
.tooltip.compile_fail, .tooltip.ignore {
1074+
font-weight: bold;
1075+
font-size: 20px;
1076+
}
1077+
10721078
.tooltip .tooltiptext {
10731079
border: 1px solid;
1080+
font-weight: normal;
10741081
}
10751082

10761083
pre.rust {

‎src/librustdoc/html/static/themes/dark.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ a.test-arrow:hover{
254254
}
255255

256256
pre.compile_fail {
257-
border-left: 2px solid rgba(255,0,0,.6);
257+
border-left: 2px solid rgba(255,0,0,.8);
258258
}
259259

260260
pre.compile_fail:hover, .information:hover + pre.compile_fail {
@@ -270,7 +270,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
270270
}
271271

272272
.tooltip.compile_fail {
273-
color: rgba(255,0,0,.6);
273+
color: rgba(255,0,0,.8);
274274
}
275275

276276
.information > .compile_fail:hover {
@@ -282,16 +282,17 @@ pre.ignore:hover, .information:hover + pre.ignore {
282282
}
283283

284284
.information > .ignore:hover {
285-
color: rgba(255,142,0,1);
285+
color: #ff9200;
286286
}
287287

288288
.search-failed a {
289289
color: #0089ff;
290290
}
291291

292292
.tooltip .tooltiptext {
293-
background-color: black;
293+
background-color: #000;
294294
color: #fff;
295+
border-color: #000;
295296
}
296297

297298
.tooltip .tooltiptext::after {

‎src/librustdoc/html/static/themes/light.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,43 +248,43 @@ a.test-arrow:hover{
248248
}
249249

250250
pre.compile_fail {
251-
border-left: 2px solid rgba(255,0,0,.4);
251+
border-left: 2px solid rgba(255,0,0,.5);
252252
}
253253

254254
pre.compile_fail:hover, .information:hover + pre.compile_fail {
255255
border-left: 2px solid #f00;
256256
}
257257

258258
pre.ignore {
259-
border-left: 2px solid rgba(255,142,0,.4);
259+
border-left: 2px solid rgba(255,142,0,.6);
260260
}
261261

262262
pre.ignore:hover, .information:hover + pre.ignore {
263263
border-left: 2px solid #ff9200;
264264
}
265265

266266
.tooltip.compile_fail {
267-
color: rgba(255,0,0,.3);
267+
color: rgba(255,0,0,.5);
268268
}
269269

270270
.information > .compile_fail:hover {
271271
color: #f00;
272272
}
273273

274274
.tooltip.ignore {
275-
color: rgba(255,142,0,.3);
275+
color: rgba(255,142,0,.6);
276276
}
277277

278278
.information > .ignore:hover {
279-
color: rgba(255,142,0,1);
279+
color: #ff9200;
280280
}
281281

282282
.search-failed a {
283283
color: #0089ff;
284284
}
285285

286286
.tooltip .tooltiptext {
287-
background-color: black;
287+
background-color: #000;
288288
color: #fff;
289289
}
290290

‎src/libstd/io/stdio.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,14 @@ fn print_to<T>(
792792
{
793793
let result = local_s
794794
.try_with(|s| {
795-
if let Ok(mut borrowed) = s.try_borrow_mut() {
796-
if let Some(w) = borrowed.as_mut() {
797-
return w.write_fmt(args);
798-
}
795+
// Note that we completely remove a local sink to write to in case
796+
// our printing recursively panics/prints, so the recursive
797+
// panic/print goes to the global sink instead of our local sink.
798+
let prev = s.borrow_mut().take();
799+
if let Some(mut w) = prev {
800+
let result = w.write_fmt(args);
801+
*s.borrow_mut() = Some(w);
802+
return result;
799803
}
800804
global_s().write_fmt(args)
801805
})

‎src/libstd/sys/unix/stack_overflow.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ mod imp {
4545
use libc::{mmap, munmap};
4646
use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIG_DFL};
4747
use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
48-
use libc::{MAP_ANON, MAP_PRIVATE, PROT_READ, PROT_WRITE, SIGSEGV};
48+
use libc::{MAP_ANON, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE, SIGSEGV};
4949

50+
use crate::sys::unix::os::page_size;
5051
use crate::sys_common::thread_info;
5152

5253
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -137,12 +138,22 @@ mod imp {
137138
}
138139

139140
unsafe fn get_stackp() -> *mut libc::c_void {
140-
let stackp =
141-
mmap(ptr::null_mut(), SIGSTKSZ, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
141+
let stackp = mmap(
142+
ptr::null_mut(),
143+
SIGSTKSZ + page_size(),
144+
PROT_READ | PROT_WRITE,
145+
MAP_PRIVATE | MAP_ANON,
146+
-1,
147+
0,
148+
);
142149
if stackp == MAP_FAILED {
143150
panic!("failed to allocate an alternative stack");
144151
}
145-
stackp
152+
let guard_result = libc::mprotect(stackp, page_size(), PROT_NONE);
153+
if guard_result != 0 {
154+
panic!("failed to set up alternative stack guard page");
155+
}
156+
stackp.add(page_size())
146157
}
147158

148159
#[cfg(any(
@@ -190,7 +201,9 @@ mod imp {
190201
ss_size: SIGSTKSZ,
191202
};
192203
sigaltstack(&stack, ptr::null_mut());
193-
munmap(handler._data, SIGSTKSZ);
204+
// We know from `get_stackp` that the alternate stack we installed is part of a mapping
205+
// that started one page earlier, so walk back a page and unmap from there.
206+
munmap(handler._data.sub(page_size()), SIGSTKSZ + page_size());
194207
}
195208
}
196209
}

‎src/test/mir-opt/generator-tiny.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! Tests that generators that cannot return or unwind don't have unnecessary
2+
//! panic branches.
3+
4+
// compile-flags: -Zno-landing-pads
5+
6+
#![feature(generators, generator_trait)]
7+
8+
struct HasDrop;
9+
10+
impl Drop for HasDrop {
11+
fn drop(&mut self) {}
12+
}
13+
14+
fn callee() {}
15+
16+
fn main() {
17+
let _gen = |_x: u8| {
18+
let _d = HasDrop;
19+
loop {
20+
yield;
21+
callee();
22+
}
23+
};
24+
}
25+
26+
// END RUST SOURCE
27+
28+
// START rustc.main-{{closure}}.generator_resume.0.mir
29+
// bb0: {
30+
// ...
31+
// switchInt(move _11) -> [0u32: bb1, 3u32: bb5, otherwise: bb6];
32+
// }
33+
// ...
34+
// END rustc.main-{{closure}}.generator_resume.0.mir

‎src/test/ui/issues/issue-70093.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// run-pass
2+
// compile-flags: -Zlink-native-libraries=no -Cdefault-linker-libraries=yes
3+
4+
#[link(name = "some-random-non-existent-library", kind = "static")]
5+
extern "C" {}
6+
7+
fn main() {}

‎src/test/ui/panic-while-printing.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// run-pass
2+
// ignore-emscripten no subprocess support
3+
4+
#![feature(set_stdio)]
5+
6+
use std::fmt;
7+
use std::fmt::{Display, Formatter};
8+
use std::io::set_panic;
9+
10+
pub struct A;
11+
12+
impl Display for A {
13+
fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result {
14+
panic!();
15+
}
16+
}
17+
18+
fn main() {
19+
set_panic(Some(Box::new(Vec::new())));
20+
assert!(std::panic::catch_unwind(|| {
21+
eprintln!("{}", A);
22+
})
23+
.is_err());
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// compile-flags:--test
2+
// run-pass
3+
// ignore-emscripten no subprocess support
4+
5+
use std::fmt;
6+
use std::fmt::{Display, Formatter};
7+
8+
pub struct A(Vec<u32>);
9+
10+
impl Display for A {
11+
fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result {
12+
self.0[0];
13+
Ok(())
14+
}
15+
}
16+
17+
#[test]
18+
fn main() {
19+
let result = std::panic::catch_unwind(|| {
20+
let a = A(vec![]);
21+
eprintln!("{}", a);
22+
});
23+
assert!(result.is_err());
24+
}

‎src/tools/tidy/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
55
edition = "2018"
66

77
[dependencies]
8+
cargo_metadata = "0.9.1"
89
regex = "1"
9-
serde = { version = "1.0.8", features = ["derive"] }
10-
serde_json = "1.0.2"
1110
lazy_static = "1"
1211
walkdir = "2"

‎src/tools/tidy/src/deps.rs

Lines changed: 354 additions & 334 deletions
Large diffs are not rendered by default.

‎src/tools/tidy/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ fn main() {
3030
pal::check(&path, &mut bad);
3131
unstable_book::check(&path, collected, &mut bad);
3232
unit_tests::check(&path, &mut bad);
33-
if !args.iter().any(|s| *s == "--no-vendor") {
34-
deps::check(&path, &mut bad);
35-
}
36-
deps::check_whitelist(&path, &cargo, &mut bad);
33+
deps::check(&path, &cargo, &mut bad);
3734
extdeps::check(&path, &mut bad);
3835
ui_tests::check(&path, &mut bad);
3936
error_codes_check::check(&path, &mut bad);

0 commit comments

Comments
 (0)
Please sign in to comment.