Skip to content

Commit 3de4f1c

Browse files
committed
Auto merge of #141484 - matthiaskrgr:rollup-dc58owu, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #141405 (GetUserProfileDirectoryW is now documented to always store the size) - #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) - #141456 (Suggest correct `version("..")` predicate syntax in check-cfg) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5af801b + 8019d08 commit 3de4f1c

37 files changed

+196
-315
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_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_lint/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ lint_unexpected_cfg_name_similar_name = there is a config with a similar name
835835
lint_unexpected_cfg_name_similar_name_different_values = there is a config with a similar name and different values
836836
lint_unexpected_cfg_name_similar_name_no_value = there is a config with a similar name and no value
837837
lint_unexpected_cfg_name_similar_name_value = there is a config with a similar name and value
838+
lint_unexpected_cfg_name_version_syntax = there is a similar config predicate: `version("..")`
838839
lint_unexpected_cfg_name_with_similar_value = found config with similar value
839840
840841
lint_unexpected_cfg_value = unexpected `cfg` condition value: {$has_value ->

compiler/rustc_lint/src/early/diagnostics/check_cfg.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ pub(super) fn unexpected_cfg_name(
140140

141141
let code_sugg = if is_feature_cfg && is_from_cargo {
142142
lints::unexpected_cfg_name::CodeSuggestion::DefineFeatures
143+
// Suggest correct `version("..")` predicate syntax
144+
} else if let Some((_value, value_span)) = value
145+
&& name == sym::version
146+
{
147+
lints::unexpected_cfg_name::CodeSuggestion::VersionSyntax {
148+
between_name_and_value: name_span.between(value_span),
149+
after_value: value_span.shrink_to_hi(),
150+
}
143151
// Suggest the most probable if we found one
144152
} else if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {
145153
is_feature_cfg |= best_match == sym::feature;

compiler/rustc_lint/src/lints.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,16 @@ pub(crate) mod unexpected_cfg_name {
22732273
pub(crate) enum CodeSuggestion {
22742274
#[help(lint_unexpected_cfg_define_features)]
22752275
DefineFeatures,
2276+
#[multipart_suggestion(
2277+
lint_unexpected_cfg_name_version_syntax,
2278+
applicability = "machine-applicable"
2279+
)]
2280+
VersionSyntax {
2281+
#[suggestion_part(code = "(")]
2282+
between_name_and_value: Span,
2283+
#[suggestion_part(code = ")")]
2284+
after_value: Span,
2285+
},
22762286
#[suggestion(
22772287
lint_unexpected_cfg_name_similar_name_value,
22782288
applicability = "maybe-incorrect",

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();

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/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`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Check warning for wrong `cfg(version("1.27"))` syntax
2+
//
3+
//@ check-pass
4+
//@ no-auto-check-cfg
5+
//@ compile-flags: --check-cfg=cfg()
6+
//@ run-rustfix
7+
8+
#![feature(cfg_version)]
9+
10+
#[cfg(not(version("1.48.0")))]
11+
//~^ WARNING unexpected `cfg` condition name: `version`
12+
pub fn g() {}
13+
14+
pub fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Check warning for wrong `cfg(version("1.27"))` syntax
2+
//
3+
//@ check-pass
4+
//@ no-auto-check-cfg
5+
//@ compile-flags: --check-cfg=cfg()
6+
//@ run-rustfix
7+
8+
#![feature(cfg_version)]
9+
10+
#[cfg(not(version = "1.48.0"))]
11+
//~^ WARNING unexpected `cfg` condition name: `version`
12+
pub fn g() {}
13+
14+
pub fn main() {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
warning: unexpected `cfg` condition name: `version`
2+
--> $DIR/wrong-version-syntax.rs:10:11
3+
|
4+
LL | #[cfg(not(version = "1.48.0"))]
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: to expect this configuration use `--check-cfg=cfg(version, values("1.48.0"))`
8+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
9+
= note: `#[warn(unexpected_cfgs)]` on by default
10+
help: there is a similar config predicate: `version("..")`
11+
|
12+
LL - #[cfg(not(version = "1.48.0"))]
13+
LL + #[cfg(not(version("1.48.0")))]
14+
|
15+
16+
warning: 1 warning emitted
17+

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() {

0 commit comments

Comments
 (0)