Skip to content

Commit e0ba2d0

Browse files
committed
Auto merge of #112987 - compiler-errors:rollup-6anskq1, r=compiler-errors
Rollup of 8 pull requests Successful merges: - #111087 (Implement `Sync` for `mpsc::Sender`) - #112763 (Bump compiler_builtins) - #112963 (Stop bubbling out hidden types from the eval obligation queries) - #112965 (Don't emit same goal as input during `wf::unnormalized_obligations`) - #112973 (Make sure to include default en-US ftl resources for `rustc_error` crate) - #112981 (Fix return type notation errors with -Zlower-impl-trait-in-trait-to-assoc-ty) - #112983 (Fix return type notation associated type suggestion when -Zlower-impl-trait-in-trait-to-assoc-ty) - #112986 (Update cargo) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1d67eba + d28f037 commit e0ba2d0

File tree

56 files changed

+508
-146
lines changed

Some content is hidden

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

56 files changed

+508
-146
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,9 @@ dependencies = [
697697

698698
[[package]]
699699
name = "compiler_builtins"
700-
version = "0.1.92"
700+
version = "0.1.93"
701701
source = "registry+https://github.com/rust-lang/crates.io-index"
702-
checksum = "64518f1ae689f74db058bbfb3238dfe6eb53f59f4ae712f1ff4348628522e190"
702+
checksum = "76630810d973ecea3dbf611e1b7aecfb1012751ef1ff8de3998f89014a166781"
703703
dependencies = [
704704
"cc",
705705
"rustc-std-workspace-core",

compiler/rustc_driver_impl/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
9797
rustc_codegen_ssa::DEFAULT_LOCALE_RESOURCE,
9898
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
9999
rustc_error_messages::DEFAULT_LOCALE_RESOURCE,
100+
rustc_errors::DEFAULT_LOCALE_RESOURCE,
100101
rustc_expand::DEFAULT_LOCALE_RESOURCE,
101102
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
102103
rustc_hir_typeck::DEFAULT_LOCALE_RESOURCE,

compiler/rustc_hir_analysis/src/astconv/bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
412412
// an RPITIT (return-position impl trait in trait) or AFIT (async fn in trait).
413413
let output = tcx.fn_sig(assoc_item.def_id).skip_binder().output();
414414
let output = if let ty::Alias(ty::Projection, alias_ty) = *output.skip_binder().kind()
415-
&& tcx.def_kind(alias_ty.def_id) == DefKind::ImplTraitPlaceholder
415+
&& tcx.is_impl_trait_in_trait(alias_ty.def_id)
416416
{
417417
alias_ty
418418
} else {

compiler/rustc_hir_analysis/src/astconv/errors.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
122122

123123
let all_candidate_names: Vec<_> = all_candidates()
124124
.flat_map(|r| self.tcx().associated_items(r.def_id()).in_definition_order())
125-
.filter_map(
126-
|item| if item.kind == ty::AssocKind::Type { Some(item.name) } else { None },
127-
)
125+
.filter_map(|item| {
126+
if item.opt_rpitit_info.is_none() && item.kind == ty::AssocKind::Type {
127+
Some(item.name)
128+
} else {
129+
None
130+
}
131+
})
128132
.collect();
129133

130134
if let (Some(suggested_name), true) = (
@@ -159,9 +163,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
159163
.flat_map(|trait_def_id| {
160164
self.tcx().associated_items(*trait_def_id).in_definition_order()
161165
})
162-
.filter_map(
163-
|item| if item.kind == ty::AssocKind::Type { Some(item.name) } else { None },
164-
)
166+
.filter_map(|item| {
167+
if item.opt_rpitit_info.is_none() && item.kind == ty::AssocKind::Type {
168+
Some(item.name)
169+
} else {
170+
None
171+
}
172+
})
165173
.collect();
166174

167175
if let (Some(suggested_name), true) = (

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
10491049
}
10501050

10511051
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty)) => {
1052+
let ty = self.resolve_vars_if_possible(ty);
10521053
match self.tcx.sess.opts.unstable_opts.trait_solver {
10531054
TraitSolver::Classic => {
10541055
// WF predicates cannot themselves make

compiler/rustc_trait_selection/src/traits/wf.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,19 @@ pub fn unnormalized_obligations<'tcx>(
7777
param_env: ty::ParamEnv<'tcx>,
7878
arg: GenericArg<'tcx>,
7979
) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
80+
debug_assert_eq!(arg, infcx.resolve_vars_if_possible(arg));
81+
82+
// However, if `arg` IS an unresolved inference variable, returns `None`,
83+
// because we are not able to make any progress at all. This is to prevent
84+
// "livelock" where we say "$0 is WF if $0 is WF".
85+
if arg.is_non_region_infer() {
86+
return None;
87+
}
88+
8089
if let ty::GenericArgKind::Lifetime(..) = arg.unpack() {
8190
return Some(vec![]);
8291
}
8392

84-
debug_assert_eq!(arg, infcx.resolve_vars_if_possible(arg));
85-
8693
let mut wf = WfPredicates {
8794
infcx,
8895
param_env,

compiler/rustc_traits/src/evaluate_obligation.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_infer::infer::TyCtxtInferExt;
22
use rustc_middle::query::Providers;
3-
use rustc_middle::traits::DefiningAnchor;
43
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
54
use rustc_span::source_map::DUMMY_SP;
65
use rustc_trait_selection::traits::query::CanonicalPredicateGoal;
@@ -18,12 +17,8 @@ fn evaluate_obligation<'tcx>(
1817
) -> Result<EvaluationResult, OverflowError> {
1918
assert!(!tcx.next_trait_solver_globally());
2019
debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal);
21-
// HACK This bubble is required for this tests to pass:
22-
// impl-trait/issue99642.rs
23-
let (ref infcx, goal, _canonical_inference_vars) = tcx
24-
.infer_ctxt()
25-
.with_opaque_type_inference(DefiningAnchor::Bubble)
26-
.build_with_canonical(DUMMY_SP, &canonical_goal);
20+
let (ref infcx, goal, _canonical_inference_vars) =
21+
tcx.infer_ctxt().build_with_canonical(DUMMY_SP, &canonical_goal);
2722
debug!("evaluate_obligation: goal={:#?}", goal);
2823
let ParamEnvAnd { param_env, value: predicate } = goal;
2924

compiler/rustc_traits/src/type_op.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use rustc_infer::infer::canonical::{Canonical, QueryResponse};
22
use rustc_infer::infer::TyCtxtInferExt;
33
use rustc_middle::query::Providers;
44
use rustc_middle::traits::query::NoSolution;
5-
use rustc_middle::traits::DefiningAnchor;
65
use rustc_middle::ty::{FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable};
76
use rustc_middle::ty::{ParamEnvAnd, Predicate};
87
use rustc_trait_selection::infer::InferCtxtBuilderExt;
@@ -106,15 +105,10 @@ fn type_op_prove_predicate<'tcx>(
106105
tcx: TyCtxt<'tcx>,
107106
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
108107
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
109-
// HACK This bubble is required for this test to pass:
110-
// impl-trait/issue-99642.rs
111-
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
112-
&canonicalized,
113-
|ocx, key| {
114-
type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());
115-
Ok(())
116-
},
117-
)
108+
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
109+
type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());
110+
Ok(())
111+
})
118112
}
119113

120114
/// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ panic_unwind = { path = "../panic_unwind", optional = true }
1818
panic_abort = { path = "../panic_abort" }
1919
core = { path = "../core", public = true }
2020
libc = { version = "0.2.146", default-features = false, features = ['rustc-dep-of-std'], public = true }
21-
compiler_builtins = { version = "0.1.92" }
21+
compiler_builtins = { version = "0.1.93" }
2222
profiler_builtins = { path = "../profiler_builtins", optional = true }
2323
unwind = { path = "../unwind" }
2424
hashbrown = { version = "0.14", default-features = false, features = ['rustc-dep-of-std'] }

library/std/src/sync/mpsc/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ pub struct Sender<T> {
347347
#[stable(feature = "rust1", since = "1.0.0")]
348348
unsafe impl<T: Send> Send for Sender<T> {}
349349

350-
#[stable(feature = "rust1", since = "1.0.0")]
351-
impl<T> !Sync for Sender<T> {}
350+
#[stable(feature = "mpsc_sender_sync", since = "CURRENT_RUSTC_VERSION")]
351+
unsafe impl<T: Send> Sync for Sender<T> {}
352352

353353
/// The sending-half of Rust's synchronous [`sync_channel`] type.
354354
///

tests/run-make/target-specs/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ all:
88
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
99
$(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
1010
$(RUSTC) foo.rs --target=definitely-not-builtin-target 2>&1 | $(CGREP) 'may not set is_builtin'
11+
$(RUSTC) foo.rs --target=endianness-mismatch 2>&1 | $(CGREP) '"data-layout" claims architecture is little-endian'
1112
$(RUSTC) foo.rs --target=mismatching-data-layout --crate-type=lib
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"pre-link-args": {"gcc": ["-m64"]},
3+
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
4+
"linker-flavor": "gcc",
5+
"llvm-target": "x86_64-unknown-linux-gnu",
6+
"target-endian": "big",
7+
"target-pointer-width": "64",
8+
"target-c-int-width": "32",
9+
"arch": "x86_64",
10+
"os": "linux"
11+
}

tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr renamed to tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: return type notation uses `()` instead of `(..)` for elided arguments
2-
--> $DIR/bad-inputs-and-output.rs:18:24
2+
--> $DIR/bad-inputs-and-output.rs:20:24
33
|
44
LL | fn baz<T: Trait<method(..): Send>>() {}
55
| ^^ help: remove the `..`
66

77
error[E0658]: associated type bounds are unstable
8-
--> $DIR/bad-inputs-and-output.rs:10:17
8+
--> $DIR/bad-inputs-and-output.rs:12:17
99
|
1010
LL | fn foo<T: Trait<method(i32): Send>>() {}
1111
| ^^^^^^^^^^^^^^^^^
@@ -14,7 +14,7 @@ LL | fn foo<T: Trait<method(i32): Send>>() {}
1414
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
1515

1616
error[E0658]: associated type bounds are unstable
17-
--> $DIR/bad-inputs-and-output.rs:14:17
17+
--> $DIR/bad-inputs-and-output.rs:16:17
1818
|
1919
LL | fn bar<T: Trait<method() -> (): Send>>() {}
2020
| ^^^^^^^^^^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL | fn bar<T: Trait<method() -> (): Send>>() {}
2323
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
2424

2525
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
26-
--> $DIR/bad-inputs-and-output.rs:3:12
26+
--> $DIR/bad-inputs-and-output.rs:5:12
2727
|
2828
LL | #![feature(return_type_notation, async_fn_in_trait)]
2929
| ^^^^^^^^^^^^^^^^^^^^
@@ -32,13 +32,13 @@ LL | #![feature(return_type_notation, async_fn_in_trait)]
3232
= note: `#[warn(incomplete_features)]` on by default
3333

3434
error: argument types not allowed with return type notation
35-
--> $DIR/bad-inputs-and-output.rs:10:23
35+
--> $DIR/bad-inputs-and-output.rs:12:23
3636
|
3737
LL | fn foo<T: Trait<method(i32): Send>>() {}
3838
| ^^^^^ help: remove the input types: `()`
3939

4040
error: return type not allowed with return type notation
41-
--> $DIR/bad-inputs-and-output.rs:14:25
41+
--> $DIR/bad-inputs-and-output.rs:16:25
4242
|
4343
LL | fn bar<T: Trait<method() -> (): Send>>() {}
4444
| ^^^^^^ help: remove the return type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
error: return type notation uses `()` instead of `(..)` for elided arguments
2+
--> $DIR/bad-inputs-and-output.rs:20:24
3+
|
4+
LL | fn baz<T: Trait<method(..): Send>>() {}
5+
| ^^ help: remove the `..`
6+
7+
error[E0658]: associated type bounds are unstable
8+
--> $DIR/bad-inputs-and-output.rs:12:17
9+
|
10+
LL | fn foo<T: Trait<method(i32): Send>>() {}
11+
| ^^^^^^^^^^^^^^^^^
12+
|
13+
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
14+
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
15+
16+
error[E0658]: associated type bounds are unstable
17+
--> $DIR/bad-inputs-and-output.rs:16:17
18+
|
19+
LL | fn bar<T: Trait<method() -> (): Send>>() {}
20+
| ^^^^^^^^^^^^^^^^^^^^
21+
|
22+
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
23+
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
24+
25+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
26+
--> $DIR/bad-inputs-and-output.rs:5:12
27+
|
28+
LL | #![feature(return_type_notation, async_fn_in_trait)]
29+
| ^^^^^^^^^^^^^^^^^^^^
30+
|
31+
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
32+
= note: `#[warn(incomplete_features)]` on by default
33+
34+
error: argument types not allowed with return type notation
35+
--> $DIR/bad-inputs-and-output.rs:12:23
36+
|
37+
LL | fn foo<T: Trait<method(i32): Send>>() {}
38+
| ^^^^^ help: remove the input types: `()`
39+
40+
error: return type not allowed with return type notation
41+
--> $DIR/bad-inputs-and-output.rs:16:25
42+
|
43+
LL | fn bar<T: Trait<method() -> (): Send>>() {}
44+
| ^^^^^^ help: remove the return type
45+
46+
error: aborting due to 5 previous errors; 1 warning emitted
47+
48+
For more information about this error, try `rustc --explain E0658`.

tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// edition: 2021
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(return_type_notation, async_fn_in_trait)]
46
//~^ WARN the feature `return_type_notation` is incomplete
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/basic.rs:8:12
3+
|
4+
LL | #![feature(return_type_notation, async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/basic.rs:8:12
3+
|
4+
LL | #![feature(return_type_notation, async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error: future cannot be sent between threads safely
11+
--> $DIR/basic.rs:26:13
12+
|
13+
LL | is_send(foo::<T>());
14+
| ^^^^^^^^^^ future returned by `foo` is not `Send`
15+
|
16+
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>>`
17+
note: future is not `Send` as it awaits another future which is not `Send`
18+
--> $DIR/basic.rs:16:5
19+
|
20+
LL | T::method().await?;
21+
| ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>>`, which is not `Send`
22+
note: required by a bound in `is_send`
23+
--> $DIR/basic.rs:20:20
24+
|
25+
LL | fn is_send(_: impl Send) {}
26+
| ^^^^ required by this bound in `is_send`
27+
28+
error: aborting due to previous error; 1 warning emitted
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/basic.rs:8:12
3+
|
4+
LL | #![feature(return_type_notation, async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/basic.rs:8:12
3+
|
4+
LL | #![feature(return_type_notation, async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error: future cannot be sent between threads safely
11+
--> $DIR/basic.rs:26:13
12+
|
13+
LL | is_send(foo::<T>());
14+
| ^^^^^^^^^^ future returned by `foo` is not `Send`
15+
|
16+
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>>`
17+
note: future is not `Send` as it awaits another future which is not `Send`
18+
--> $DIR/basic.rs:16:5
19+
|
20+
LL | T::method().await?;
21+
| ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>>`, which is not `Send`
22+
note: required by a bound in `is_send`
23+
--> $DIR/basic.rs:20:20
24+
|
25+
LL | fn is_send(_: impl Send) {}
26+
| ^^^^ required by this bound in `is_send`
27+
28+
error: aborting due to previous error; 1 warning emitted
29+

tests/ui/associated-type-bounds/return-type-notation/basic.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
// revisions: with without
1+
// revisions: current_with current_without next_with next_without
2+
// [next_with] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// [next_without] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
24
// edition: 2021
3-
//[with] check-pass
5+
// [current_with] check-pass
6+
// [next_with] check-pass
47

58
#![feature(return_type_notation, async_fn_in_trait)]
69
//~^ WARN the feature `return_type_notation` is incomplete
@@ -17,11 +20,12 @@ async fn foo<T: Foo>() -> Result<(), ()> {
1720
fn is_send(_: impl Send) {}
1821

1922
fn test<
20-
#[cfg(with)] T: Foo<method(): Send>,
21-
#[cfg(without)] T: Foo,
23+
#[cfg(any(current_with, next_with))] T: Foo<method(): Send>,
24+
#[cfg(any(current_without, next_without))] T: Foo,
2225
>() {
2326
is_send(foo::<T>());
24-
//[without]~^ ERROR future cannot be sent between threads safely
27+
//[current_without]~^ ERROR future cannot be sent between threads safely
28+
//[next_without]~^^ ERROR future cannot be sent between threads safely
2529
}
2630

2731
fn main() {}

0 commit comments

Comments
 (0)