Skip to content

Commit 98d6df5

Browse files
committed
Auto merge of #64368 - Centril:rollup-4s8ko6f, r=Centril
Rollup of 6 pull requests Successful merges: - #64060 (Improve hygiene of `alloc::format!`) - #64072 (Replace file_stem by file_name in rustdoc markdown) - #64085 (Tweak unsatisfied HRTB errors) - #64129 (vxWorks: set DEFAULT_MIN_STACK_SIZE to 256K and use min_stack to pass initial stack size to rtpSpawn) - #64188 (rustc: Allow the cdylib crate type with wasm32-wasi) - #64349 (documentation for AtomicPtr CAS operations) Failed merges: r? @ghost
2 parents 34e82a7 + 115dede commit 98d6df5

19 files changed

+162
-73
lines changed

src/liballoc/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,9 @@ pub mod vec;
171171
mod std {
172172
pub use core::ops; // RangeFull
173173
}
174+
175+
#[doc(hidden)]
176+
#[unstable(feature = "liballoc_internals", issue = "0", reason = "implementation detail")]
177+
pub mod __export {
178+
pub use core::format_args;
179+
}

src/liballoc/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,5 @@ macro_rules! vec {
9898
#[macro_export]
9999
#[stable(feature = "rust1", since = "1.0.0")]
100100
macro_rules! format {
101-
($($arg:tt)*) => ($crate::fmt::format(::core::format_args!($($arg)*)))
101+
($($arg:tt)*) => ($crate::fmt::format($crate::__export::format_args!($($arg)*)))
102102
}

src/libcore/sync/atomic.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,8 @@ impl<T> AtomicPtr<T> {
979979
/// let some_ptr = AtomicPtr::new(ptr);
980980
///
981981
/// let other_ptr = &mut 10;
982-
/// let another_ptr = &mut 10;
983982
///
984-
/// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed);
983+
/// let value = some_ptr.compare_and_swap(ptr, other_ptr, Ordering::Relaxed);
985984
/// ```
986985
#[inline]
987986
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1021,9 +1020,8 @@ impl<T> AtomicPtr<T> {
10211020
/// let some_ptr = AtomicPtr::new(ptr);
10221021
///
10231022
/// let other_ptr = &mut 10;
1024-
/// let another_ptr = &mut 10;
10251023
///
1026-
/// let value = some_ptr.compare_exchange(other_ptr, another_ptr,
1024+
/// let value = some_ptr.compare_exchange(ptr, other_ptr,
10271025
/// Ordering::SeqCst, Ordering::Relaxed);
10281026
/// ```
10291027
#[inline]

src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs

+31-22
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,28 @@ impl NiceRegionError<'me, 'tcx> {
192192
vid, sub_placeholder, sup_placeholder, trait_def_id, expected_substs, actual_substs
193193
);
194194

195-
let mut err = self.tcx().sess.struct_span_err(
196-
cause.span(self.tcx()),
197-
&format!(
198-
"implementation of `{}` is not general enough",
199-
self.tcx().def_path_str(trait_def_id),
200-
),
195+
let span = cause.span(self.tcx());
196+
let msg = format!(
197+
"implementation of `{}` is not general enough",
198+
self.tcx().def_path_str(trait_def_id),
199+
);
200+
let mut err = self.tcx().sess.struct_span_err(span, &msg);
201+
err.span_label(
202+
self.tcx().def_span(trait_def_id),
203+
format!("trait `{}` defined here", self.tcx().def_path_str(trait_def_id)),
201204
);
202205

203-
match cause.code {
204-
ObligationCauseCode::ItemObligation(def_id) => {
205-
err.note(&format!(
206-
"Due to a where-clause on `{}`,",
207-
self.tcx().def_path_str(def_id),
208-
));
209-
}
210-
_ => (),
211-
}
206+
let leading_ellipsis = if let ObligationCauseCode::ItemObligation(def_id) = cause.code {
207+
err.span_label(span, "doesn't satisfy where-clause");
208+
err.span_label(
209+
self.tcx().def_span(def_id),
210+
&format!("due to a where-clause on `{}`...", self.tcx().def_path_str(def_id)),
211+
);
212+
true
213+
} else {
214+
err.span_label(span, &msg);
215+
false
216+
};
212217

213218
let expected_trait_ref = self.infcx.resolve_vars_if_possible(&ty::TraitRef {
214219
def_id: trait_def_id,
@@ -295,6 +300,7 @@ impl NiceRegionError<'me, 'tcx> {
295300
expected_has_vid,
296301
actual_has_vid,
297302
any_self_ty_has_vid,
303+
leading_ellipsis,
298304
);
299305

300306
err
@@ -318,6 +324,7 @@ impl NiceRegionError<'me, 'tcx> {
318324
expected_has_vid: Option<usize>,
319325
actual_has_vid: Option<usize>,
320326
any_self_ty_has_vid: bool,
327+
leading_ellipsis: bool,
321328
) {
322329
// HACK(eddyb) maybe move this in a more central location.
323330
#[derive(Copy, Clone)]
@@ -392,13 +399,15 @@ impl NiceRegionError<'me, 'tcx> {
392399

393400
let mut note = if passive_voice {
394401
format!(
395-
"`{}` would have to be implemented for the type `{}`",
402+
"{}`{}` would have to be implemented for the type `{}`",
403+
if leading_ellipsis { "..." } else { "" },
396404
expected_trait_ref,
397405
expected_trait_ref.map(|tr| tr.self_ty()),
398406
)
399407
} else {
400408
format!(
401-
"`{}` must implement `{}`",
409+
"{}`{}` must implement `{}`",
410+
if leading_ellipsis { "..." } else { "" },
402411
expected_trait_ref.map(|tr| tr.self_ty()),
403412
expected_trait_ref,
404413
)
@@ -407,20 +416,20 @@ impl NiceRegionError<'me, 'tcx> {
407416
match (has_sub, has_sup) {
408417
(Some(n1), Some(n2)) => {
409418
let _ = write!(note,
410-
", for any two lifetimes `'{}` and `'{}`",
419+
", for any two lifetimes `'{}` and `'{}`...",
411420
std::cmp::min(n1, n2),
412421
std::cmp::max(n1, n2),
413422
);
414423
}
415424
(Some(n), _) | (_, Some(n)) => {
416425
let _ = write!(note,
417-
", for any lifetime `'{}`",
426+
", for any lifetime `'{}`...",
418427
n,
419428
);
420429
}
421430
(None, None) => if let Some(n) = expected_has_vid {
422431
let _ = write!(note,
423-
", for some specific lifetime `'{}`",
432+
", for some specific lifetime `'{}`...",
424433
n,
425434
);
426435
},
@@ -439,13 +448,13 @@ impl NiceRegionError<'me, 'tcx> {
439448

440449
let mut note = if passive_voice {
441450
format!(
442-
"but `{}` is actually implemented for the type `{}`",
451+
"...but `{}` is actually implemented for the type `{}`",
443452
actual_trait_ref,
444453
actual_trait_ref.map(|tr| tr.self_ty()),
445454
)
446455
} else {
447456
format!(
448-
"but `{}` actually implements `{}`",
457+
"...but `{}` actually implements `{}`",
449458
actual_trait_ref.map(|tr| tr.self_ty()),
450459
actual_trait_ref,
451460
)

src/librustc_target/spec/wasm32_wasi.rs

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ pub fn target() -> Result<Target, String> {
9797
options.crt_static_default = true;
9898
options.crt_static_respected = true;
9999

100+
// Allow `+crt-static` to create a "cdylib" output which is just a wasm file
101+
// without a main function.
102+
options.crt_static_allows_dylibs = true;
103+
100104
Ok(Target {
101105
llvm_target: "wasm32-wasi".to_string(),
102106
target_endian: "little".to_string(),

src/librustdoc/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn render(
4343
edition: Edition
4444
) -> i32 {
4545
let mut output = options.output;
46-
output.push(input.file_stem().unwrap());
46+
output.push(input.file_name().unwrap());
4747
output.set_extension("html");
4848

4949
let mut css = String::new();

src/libstd/sys/vxworks/fast_thread_local.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Copyright (c) 2019 Wind River Systems, Inc.
2-
31
#![cfg(target_thread_local)]
42
#![unstable(feature = "thread_local_internals", issue = "0")]
53

src/libstd/sys/vxworks/process/process_vxworks.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::sys;
55
use crate::sys::cvt;
66
use crate::sys::process::rtp;
77
use crate::sys::process::process_common::*;
8+
use crate::sys_common::thread;
89

910
////////////////////////////////////////////////////////////////////////////////
1011
// Command
@@ -57,8 +58,7 @@ impl Command {
5758
self.get_argv().as_ptr() as *const _, // argv
5859
*sys::os::environ() as *const *const c_char,
5960
100 as c_int, // initial priority
60-
0x16000, // initial stack size. 0 defaults
61-
// to 0x4000 in 32 bit and 0x8000 in 64 bit
61+
thread::min_stack(), // initial stack size.
6262
0, // options
6363
0 // task options
6464
);

src/libstd/sys/vxworks/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::time::Duration;
88

99
use crate::sys_common::thread::*;
1010

11-
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
11+
pub const DEFAULT_MIN_STACK_SIZE: usize = 0x40000; // 256K
1212

1313
pub struct Thread {
1414
id: libc::pthread_t,
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
error: implementation of `Foo` is not general enough
22
--> $DIR/auto-trait-regions.rs:30:5
33
|
4+
LL | auto trait Foo {}
5+
| ----------------- trait `Foo` defined here
6+
...
47
LL | assert_foo(gen);
5-
| ^^^^^^^^^^
8+
| ^^^^^^^^^^ implementation of `Foo` is not general enough
69
|
7-
= note: `Foo` would have to be implemented for the type `&'0 OnlyFooIfStaticRef`, for any lifetime `'0`
8-
= note: but `Foo` is actually implemented for the type `&'1 OnlyFooIfStaticRef`, for some specific lifetime `'1`
10+
= note: `Foo` would have to be implemented for the type `&'0 OnlyFooIfStaticRef`, for any lifetime `'0`...
11+
= note: ...but `Foo` is actually implemented for the type `&'1 OnlyFooIfStaticRef`, for some specific lifetime `'1`
912

1013
error: implementation of `Foo` is not general enough
1114
--> $DIR/auto-trait-regions.rs:48:5
1215
|
16+
LL | auto trait Foo {}
17+
| ----------------- trait `Foo` defined here
18+
...
1319
LL | assert_foo(gen);
14-
| ^^^^^^^^^^
20+
| ^^^^^^^^^^ implementation of `Foo` is not general enough
1521
|
16-
= note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`
17-
= note: but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
22+
= note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`...
23+
= note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
1824

1925
error: aborting due to 2 previous errors
2026

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn main() {
2+
test::<FooS>(&mut 42); //~ ERROR implementation of `Foo` is not general enough
3+
}
4+
5+
trait Foo<'a> {}
6+
7+
struct FooS<'a> {
8+
data: &'a mut u32,
9+
}
10+
11+
impl<'a, 'b: 'a> Foo<'b> for FooS<'a> {}
12+
13+
fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: implementation of `Foo` is not general enough
2+
--> $DIR/due-to-where-clause.rs:2:5
3+
|
4+
LL | test::<FooS>(&mut 42);
5+
| ^^^^^^^^^^^^ doesn't satisfy where-clause
6+
...
7+
LL | trait Foo<'a> {}
8+
| ---------------- trait `Foo` defined here
9+
...
10+
LL | fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {}
11+
| ------------------------------------------------------------- due to a where-clause on `test`...
12+
|
13+
= note: ...`FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`...
14+
= note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1`
15+
16+
error: aborting due to previous error
17+
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
error: implementation of `Deserialize` is not general enough
22
--> $DIR/hrtb-cache-issue-54302.rs:19:5
33
|
4+
LL | trait Deserialize<'de> {}
5+
| ------------------------- trait `Deserialize` defined here
6+
...
47
LL | assert_deserialize_owned::<&'static str>();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Deserialize` is not general enough
69
|
7-
= note: `&'static str` must implement `Deserialize<'0>`, for any lifetime `'0`
8-
= note: but `&str` actually implements `Deserialize<'1>`, for some specific lifetime `'1`
10+
= note: `&'static str` must implement `Deserialize<'0>`, for any lifetime `'0`...
11+
= note: ...but `&str` actually implements `Deserialize<'1>`, for some specific lifetime `'1`
912

1013
error: aborting due to previous error
1114

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
error: implementation of `Stream` is not general enough
22
--> $DIR/issue-30786.rs:108:22
33
|
4-
LL | let map = source.map(|x: &_| x);
5-
| ^^^
4+
LL | / pub trait Stream {
5+
LL | | type Item;
6+
LL | | fn next(self) -> Option<Self::Item>;
7+
LL | | }
8+
| |_- trait `Stream` defined here
9+
...
10+
LL | let map = source.map(|x: &_| x);
11+
| ^^^ implementation of `Stream` is not general enough
612
|
7-
= note: `Stream` would have to be implemented for the type `&'0 mut Map<Repeat, [closure@$DIR/issue-30786.rs:108:26: 108:35]>`, for any lifetime `'0`
8-
= note: but `Stream` is actually implemented for the type `&'1 mut Map<Repeat, [closure@$DIR/issue-30786.rs:108:26: 108:35]>`, for some specific lifetime `'1`
13+
= note: `Stream` would have to be implemented for the type `&'0 mut Map<Repeat, [closure@$DIR/issue-30786.rs:108:26: 108:35]>`, for any lifetime `'0`...
14+
= note: ...but `Stream` is actually implemented for the type `&'1 mut Map<Repeat, [closure@$DIR/issue-30786.rs:108:26: 108:35]>`, for some specific lifetime `'1`
915

1016
error: aborting due to previous error
1117

src/test/ui/hrtb/issue-30786.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: higher-ranked subtype error
2-
--> $DIR/issue-30786.rs:112:18
2+
--> $DIR/issue-30786.rs:113:18
33
|
44
LL | let filter = map.filter(|x: &_| true);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: higher-ranked subtype error
8-
--> $DIR/issue-30786.rs:114:17
8+
--> $DIR/issue-30786.rs:115:17
99
|
1010
LL | let count = filter.count(); // Assert that we still have a valid stream.
1111
| ^^^^^^^^^^^^^^

src/test/ui/hrtb/issue-30786.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
//[nll]compile-flags: -Z borrowck=mir
1818

19-
pub trait Stream {
19+
pub trait Stream { //[migrate]~ NOTE trait `Stream` defined here
2020
type Item;
2121
fn next(self) -> Option<Self::Item>;
2222
}
@@ -109,6 +109,7 @@ fn main() {
109109
//[migrate]~^ ERROR implementation of `Stream` is not general enough
110110
//[migrate]~| NOTE `Stream` would have to be implemented for the type `&'0 mut Map
111111
//[migrate]~| NOTE but `Stream` is actually implemented for the type `&'1
112+
//[migrate]~| NOTE implementation of `Stream` is not general enough
112113
let filter = map.filter(|x: &_| true);
113114
//[nll]~^ ERROR higher-ranked subtype error
114115
let count = filter.count(); // Assert that we still have a valid stream.

0 commit comments

Comments
 (0)