Skip to content

Commit 8b9fb9f

Browse files
committed
Auto merge of #141473 - matthiaskrgr:rollup-y3vhivo, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #140790 (Enable xray support for Mac) - #141405 (GetUserProfileDirectoryW is now documented to always store the size) - #141413 (Make #[cfg(version)] respect RUSTC_OVERRIDE_VERSION_STRING) - #141427 (Disable `triagebot`'s `glacier` handler) - #141429 (Dont walk into unsafe binders when emiting error for non-structural type match) - #141438 (Do not try to confirm non-dyn compatible method) - #141444 (Improve CONTRIBUTING.md grammar and clarity) - #141446 (Add 2nd Solaris target maintainer) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 80c3498 + e590661 commit 8b9fb9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+243
-327
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ and we appreciate all of them.
55

66
The best way to get started is by asking for help in the [#new
77
members](https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members)
8-
Zulip stream. We have lots of docs below of how to get started on your own, but
8+
Zulip stream. We have a lot of documentation below on how to get started on your own, but
99
the Zulip stream is the best place to *ask* for help.
1010

1111
Documentation for contributing to the compiler or tooling is located in the [Guide to Rustc
@@ -14,7 +14,7 @@ standard library in the [Standard library developers Guide][std-dev-guide], comm
1414

1515
## Making changes to subtrees and submodules
1616

17-
For submodules, changes need to be made against the repository corresponding the
17+
For submodules, changes need to be made against the repository corresponding to the
1818
submodule, and not the main `rust-lang/rust` repository.
1919

2020
For subtrees, prefer sending a PR against the subtree's repository if it does
@@ -25,15 +25,15 @@ rustc-dev-guide change that does not accompany a compiler change).
2525

2626
The [rustc-dev-guide] is meant to help document how rustc –the Rust compiler– works,
2727
as well as to help new contributors get involved in rustc development. It is recommended
28-
to read and understand the [rustc-dev-guide] before making a contribution. This guide
28+
that you read and understand the [rustc-dev-guide] before making a contribution. This guide
2929
talks about the different bots in the Rust ecosystem, the Rust development tools,
3030
bootstrapping, the compiler architecture, source code representation, and more.
3131

3232
## [Getting help](https://rustc-dev-guide.rust-lang.org/getting-started.html#asking-questions)
3333

3434
There are many ways you can get help when you're stuck. Rust has many platforms for this:
3535
[internals], [rust-zulip], and [rust-discord]. It is recommended to ask for help on
36-
the [rust-zulip], but any of these platforms are a great way to seek help and even
36+
the [rust-zulip], but any of these platforms are great ways to seek help and even
3737
find a mentor! You can learn more about asking questions and getting help in the
3838
[Asking Questions](https://rustc-dev-guide.rust-lang.org/getting-started.html#asking-questions) chapter of the [rustc-dev-guide].
3939

compiler/rustc_attr_data_structures/src/version.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::fmt::{self, Display};
2+
use std::sync::OnceLock;
23

34
use rustc_macros::{
45
Decodable, Encodable, HashStable_Generic, PrintAttribute, current_rustc_version,
@@ -16,8 +17,29 @@ pub struct RustcVersion {
1617

1718
impl RustcVersion {
1819
pub const CURRENT: Self = current_rustc_version!();
20+
pub fn current_overridable() -> Self {
21+
*CURRENT_OVERRIDABLE.get_or_init(|| {
22+
if let Ok(override_var) = std::env::var("RUSTC_OVERRIDE_VERSION_STRING")
23+
&& let Some(override_) = Self::parse_str(&override_var)
24+
{
25+
override_
26+
} else {
27+
Self::CURRENT
28+
}
29+
})
30+
}
31+
fn parse_str(value: &str) -> Option<Self> {
32+
// Ignore any suffixes such as "-dev" or "-nightly".
33+
let mut components = value.split('-').next().unwrap().splitn(3, '.');
34+
let major = components.next()?.parse().ok()?;
35+
let minor = components.next()?.parse().ok()?;
36+
let patch = components.next().unwrap_or("0").parse().ok()?;
37+
Some(RustcVersion { major, minor, patch })
38+
}
1939
}
2040

41+
static CURRENT_OVERRIDABLE: OnceLock<RustcVersion> = OnceLock::new();
42+
2143
impl Display for RustcVersion {
2244
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
2345
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ pub fn eval_condition(
129129

130130
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
131131
if sess.psess.assume_incomplete_release {
132-
RustcVersion::CURRENT > min_version
132+
RustcVersion::current_overridable() > min_version
133133
} else {
134-
RustcVersion::CURRENT >= min_version
134+
RustcVersion::current_overridable() >= min_version
135135
}
136136
}
137137
MetaItemKind::List(mis) => {

compiler/rustc_hir_typeck/src/method/confirm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
291291
probe::ObjectPick => {
292292
let trait_def_id = pick.item.container_id(self.tcx);
293293

294+
// If the trait is not object safe (specifically, we care about when
295+
// the receiver is not valid), then there's a chance that we will not
296+
// actually be able to recover the object by derefing the receiver like
297+
// we should if it were valid.
298+
if !self.tcx.is_dyn_compatible(trait_def_id) {
299+
return ty::GenericArgs::extend_with_error(self.tcx, trait_def_id, &[]);
300+
}
301+
294302
// This shouldn't happen for non-region error kinds, but may occur
295303
// when we have error regions. Specifically, since we canonicalize
296304
// during method steps, we may successfully deref when we assemble

compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ fn extend_type_not_partial_eq<'tcx>(
382382
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
383383
match ty.kind() {
384384
ty::Dynamic(..) => return ControlFlow::Break(()),
385+
// Unsafe binders never implement `PartialEq`, so avoid walking into them
386+
// which would require instantiating its binder with placeholders too.
387+
ty::UnsafeBinder(..) => return ControlFlow::Break(()),
385388
ty::FnPtr(..) => return ControlFlow::Continue(()),
386389
ty::Adt(def, _args) => {
387390
let ty_def_id = def.did();

compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) fn target() -> Target {
2222
max_atomic_width: Some(128),
2323
// FIXME: The leak sanitizer currently fails the tests, see #88132.
2424
supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD,
25+
supports_xray: true,
2526
..opts
2627
},
2728
}

compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {
2323
| SanitizerSet::CFI
2424
| SanitizerSet::LEAK
2525
| SanitizerSet::THREAD,
26+
supports_xray: true,
2627
..opts
2728
},
2829
}

library/std/src/sys/pal/windows/os.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ fn home_dir_crt() -> Option<PathBuf> {
202202
|buf, mut sz| {
203203
// GetUserProfileDirectoryW does not quite use the usual protocol for
204204
// negotiating the buffer size, so we have to translate.
205-
// FIXME(#141254): We rely on the *undocumented* property that this function will
206-
// always set the size, not just on failure.
207205
match c::GetUserProfileDirectoryW(
208206
ptr::without_provenance_mut(CURRENT_PROCESS_TOKEN),
209207
buf,

src/doc/rustc/src/platform-support/solaris.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Rust for Solaris operating system.
88
## Target maintainers
99

1010
[@psumbera](https://github.com/psumbera)
11+
[@kulikjak](https://github.com/kulikjak)
1112

1213
## Requirements
1314

src/tools/miri/src/shims/windows/env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
230230
interp_ok(match directories::UserDirs::new() {
231231
Some(dirs) => {
232232
let home = dirs.home_dir();
233-
let size_avail = if this.ptr_is_null(size.ptr())? {
233+
let size_avail = if this.ptr_is_null(buf)? {
234234
0 // if the buf pointer is null, we can't write to it; `size` will be updated to the required length
235235
} else {
236236
this.read_scalar(&size)?.to_u32()?
237237
};
238238
// Of course we cannot use `windows_check_buffer_size` here since this uses
239239
// a different method for dealing with a too-small buffer than the other functions...
240240
let (success, len) = this.write_path_to_wide_str(home, buf, size_avail.into())?;
241-
// The Windows docs just say that this is written on failure, but std relies on it
242-
// always being written. Also see <https://github.com/rust-lang/rust/issues/141254>.
241+
// As per <https://github.com/MicrosoftDocs/sdk-api/pull/1810>, the size is always
242+
// written, not just on failure.
243243
this.write_scalar(Scalar::from_u32(len.try_into().unwrap()), &size)?;
244244
if success {
245245
Scalar::from_i32(1) // return TRUE

tests/assembly/x86_64-xray.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ assembly-output: emit-asm
2+
//@ compile-flags: --crate-type lib -Zinstrument-xray=always -C llvm-args=-x86-asm-syntax=intel
3+
//@ only-x86_64
4+
//@ ignore-sgx
5+
6+
// CHECK-LABEL: xray_func:
7+
#[no_mangle]
8+
pub fn xray_func() {
9+
// CHECK: nop word ptr [rax + rax + 512]
10+
11+
std::hint::black_box(());
12+
13+
// CHECK: ret
14+
// CHECK-NEXT: nop word ptr cs:[rax + rax + 512]
15+
}

tests/ui/async-await/dyn/mut-is-pointer-like.stderr

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output;
4242
= help: consider moving `async_dispatch` to another trait
4343
= note: required for the cast from `Pin<&mut {async block@$DIR/mut-is-pointer-like.rs:32:32: 32:37}>` to `Pin<&mut dyn AsyncTrait<Output = ()>>`
4444

45-
error[E0277]: the trait bound `dyn AsyncTrait<Output = ()>: AsyncTrait` is not satisfied
46-
--> $DIR/mut-is-pointer-like.rs:36:11
47-
|
48-
LL | x.async_dispatch().await;
49-
| ^^^^^^^^^^^^^^ the trait `AsyncTrait` is not implemented for `dyn AsyncTrait<Output = ()>`
50-
51-
error[E0038]: the trait `AsyncTrait` is not dyn compatible
52-
--> $DIR/mut-is-pointer-like.rs:36:9
53-
|
54-
LL | x.async_dispatch().await;
55-
| ^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
56-
|
57-
note: for a trait to be dyn compatible it needs to allow building a vtable
58-
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
59-
--> $DIR/mut-is-pointer-like.rs:16:14
60-
|
61-
LL | trait AsyncTrait {
62-
| ---------- this trait is not dyn compatible...
63-
...
64-
LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output;
65-
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
66-
= help: consider moving `async_dispatch` to another trait
67-
68-
error: aborting due to 4 previous errors; 1 warning emitted
45+
error: aborting due to 2 previous errors; 1 warning emitted
6946

70-
Some errors have detailed explanations: E0038, E0277.
71-
For more information about an error, try `rustc --explain E0038`.
47+
For more information about this error, try `rustc --explain E0038`.

tests/ui/async-await/dyn/works.stderr

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,6 @@ LL | async fn async_dispatch(&self);
4242
= help: consider moving `async_dispatch` to another trait
4343
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
4444

45-
error[E0038]: the trait `AsyncTrait` is not dyn compatible
46-
--> $DIR/works.rs:28:11
47-
|
48-
LL | x.async_dispatch().await;
49-
| ^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
50-
|
51-
note: for a trait to be dyn compatible it needs to allow building a vtable
52-
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
53-
--> $DIR/works.rs:14:14
54-
|
55-
LL | trait AsyncTrait {
56-
| ---------- this trait is not dyn compatible...
57-
LL | async fn async_dispatch(&self);
58-
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
59-
= help: consider moving `async_dispatch` to another trait
60-
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
61-
62-
error[E0038]: the trait `AsyncTrait` is not dyn compatible
63-
--> $DIR/works.rs:28:9
64-
|
65-
LL | x.async_dispatch().await;
66-
| ^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
67-
|
68-
note: for a trait to be dyn compatible it needs to allow building a vtable
69-
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
70-
--> $DIR/works.rs:14:14
71-
|
72-
LL | trait AsyncTrait {
73-
| ---------- this trait is not dyn compatible...
74-
LL | async fn async_dispatch(&self);
75-
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
76-
= help: consider moving `async_dispatch` to another trait
77-
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
78-
79-
error: aborting due to 4 previous errors; 1 warning emitted
45+
error: aborting due to 2 previous errors; 1 warning emitted
8046

8147
For more information about this error, try `rustc --explain E0038`.

tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl Foo for () {
1515
}
1616

1717
fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` is not dyn compatible
18-
v.test(); //~ERROR the trait `Foo` is not dyn compatible
18+
v.test();
1919
}
2020

2121
fn main() {}

tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,6 @@ LL | fn test(&self) -> [u8; bar::<Self>()];
1717
= help: consider moving `test` to another trait
1818
= help: only type `()` implements `Foo`; consider using it directly instead.
1919

20-
error[E0038]: the trait `Foo` is not dyn compatible
21-
--> $DIR/dyn-compatibility-err-ret.rs:18:5
22-
|
23-
LL | v.test();
24-
| ^^^^^^^^ `Foo` is not dyn compatible
25-
|
26-
note: for a trait to be dyn compatible it needs to allow building a vtable
27-
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
28-
--> $DIR/dyn-compatibility-err-ret.rs:8:8
29-
|
30-
LL | trait Foo {
31-
| --- this trait is not dyn compatible...
32-
LL | fn test(&self) -> [u8; bar::<Self>()];
33-
| ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
34-
| |
35-
| ...because method `test` references the `Self` type in its `where` clause
36-
= help: consider moving `test` to another trait
37-
= help: only type `()` implements `Foo`; consider using it directly instead.
38-
39-
error: aborting due to 2 previous errors
20+
error: aborting due to 1 previous error
4021

4122
For more information about this error, try `rustc --explain E0038`.

tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ impl Foo for () {
1515
fn use_dyn(v: &dyn Foo) {
1616
//~^ ERROR the trait `Foo` is not dyn compatible
1717
v.test();
18-
//~^ ERROR the trait `Foo` is not dyn compatible
1918
}
2019

2120
fn main() {}

tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,6 @@ LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
1515
= help: consider moving `test` to another trait
1616
= help: only type `()` implements `Foo`; consider using it directly instead.
1717

18-
error[E0038]: the trait `Foo` is not dyn compatible
19-
--> $DIR/dyn-compatibility-err-where-bounds.rs:17:5
20-
|
21-
LL | v.test();
22-
| ^^^^^^^^ `Foo` is not dyn compatible
23-
|
24-
note: for a trait to be dyn compatible it needs to allow building a vtable
25-
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
26-
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
27-
|
28-
LL | trait Foo {
29-
| --- this trait is not dyn compatible...
30-
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
31-
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
32-
= help: consider moving `test` to another trait
33-
= help: only type `()` implements `Foo`; consider using it directly instead.
34-
35-
error: aborting due to 2 previous errors
18+
error: aborting due to 1 previous error
3619

3720
For more information about this error, try `rustc --explain E0038`.

tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ pub fn foo() {
2525
let fetcher = fetcher();
2626
//~^ ERROR the trait `Fetcher` is not dyn compatible
2727
let _ = fetcher.get();
28-
//~^ ERROR the trait `Fetcher` is not dyn compatible
2928
}

tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,6 @@ LL | pub trait Fetcher: Send + Sync {
3434
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
3535
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
3636

37-
error[E0038]: the trait `Fetcher` is not dyn compatible
38-
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:27:13
39-
|
40-
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
41-
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
42-
...
43-
LL | let _ = fetcher.get();
44-
| ^^^^^^^^^^^^^ `Fetcher` is not dyn compatible
45-
|
46-
note: for a trait to be dyn compatible it needs to allow building a vtable
47-
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
48-
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22
49-
|
50-
LL | pub trait Fetcher: Send + Sync {
51-
| ------- this trait is not dyn compatible...
52-
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
53-
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
54-
55-
error: aborting due to 3 previous errors
37+
error: aborting due to 2 previous errors
5638

5739
For more information about this error, try `rustc --explain E0038`.

tests/ui/error-codes/E0038.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ trait Trait {
55
fn call_foo(x: Box<dyn Trait>) {
66
//~^ ERROR E0038
77
let y = x.foo();
8-
//~^ ERROR E0038
9-
//~| ERROR E0277
108
}
119

1210
fn main() {

tests/ui/error-codes/E0038.stderr

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,6 @@ LL | fn foo(&self) -> Self;
1414
| ^^^^ ...because method `foo` references the `Self` type in its return type
1515
= help: consider moving `foo` to another trait
1616

17-
error[E0038]: the trait `Trait` is not dyn compatible
18-
--> $DIR/E0038.rs:7:13
19-
|
20-
LL | let y = x.foo();
21-
| ^^^^^^^ `Trait` is not dyn compatible
22-
|
23-
note: for a trait to be dyn compatible it needs to allow building a vtable
24-
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
25-
--> $DIR/E0038.rs:2:22
26-
|
27-
LL | trait Trait {
28-
| ----- this trait is not dyn compatible...
29-
LL | fn foo(&self) -> Self;
30-
| ^^^^ ...because method `foo` references the `Self` type in its return type
31-
= help: consider moving `foo` to another trait
32-
33-
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
34-
--> $DIR/E0038.rs:7:9
35-
|
36-
LL | let y = x.foo();
37-
| ^ doesn't have a size known at compile-time
38-
|
39-
= help: the trait `Sized` is not implemented for `dyn Trait`
40-
= note: all local variables must have a statically known size
41-
= help: unsized locals are gated as an unstable feature
42-
43-
error: aborting due to 3 previous errors
17+
error: aborting due to 1 previous error
4418

45-
Some errors have detailed explanations: E0038, E0277.
46-
For more information about an error, try `rustc --explain E0038`.
19+
For more information about this error, try `rustc --explain E0038`.

0 commit comments

Comments
 (0)