Skip to content

Commit 8b2fac9

Browse files
committed
finishing touches, move fixed ICEs to ui tests
1 parent 0a23306 commit 8b2fac9

19 files changed

+182
-65
lines changed

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ where
877877

878878
let mut first_non_maybe = None;
879879
let mut non_maybe_count = 0;
880-
for ty in types {
880+
for ty in types.iter() {
881881
if !matches!(ty::EffectKind::try_from_ty(cx, ty), Some(ty::EffectKind::Maybe)) {
882882
first_non_maybe.get_or_insert(ty);
883883
non_maybe_count += 1;
@@ -902,7 +902,7 @@ where
902902
_ => {
903903
let mut min = ty::EffectKind::Maybe;
904904

905-
for ty in types {
905+
for ty in types.iter() {
906906
let Some(kind) = ty::EffectKind::try_from_ty(cx, ty) else {
907907
return Err(NoSolution);
908908
};

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ where
717717

718718
let cx = ecx.cx();
719719
let maybe_count = types
720-
.into_iter()
720+
.iter()
721721
.filter_map(|ty| ty::EffectKind::try_from_ty(cx, ty))
722722
.filter(|&ty| ty == ty::EffectKind::Maybe)
723723
.count();
@@ -727,7 +727,7 @@ where
727727
if types.len() - maybe_count > 1 {
728728
let mut min = ty::EffectKind::Maybe;
729729

730-
for ty in types {
730+
for ty in types.iter() {
731731
let Some(kind) = ty::EffectKind::try_from_ty(ecx.cx(), ty) else {
732732
return Err(NoSolution);
733733
};

src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs

+3
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ fn main() {}
104104

105105
struct D;
106106

107+
/* FIXME(effects)
107108
impl const Drop for D {
108109
fn drop(&mut self) {
109110
todo!();
110111
}
111112
}
113+
*/
112114

113115
// Lint this, since it can be dropped in const contexts
114116
// FIXME(effects)
115117
fn d(this: D) {}
118+
//~^ ERROR: this could be a `const fn`
116119

117120
mod msrv {
118121
struct Foo(*const u8, &'static u8);

src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr

+13-7
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ LL | const fn msrv_1_46() -> i32 {
157157
| +++++
158158

159159
error: this could be a `const fn`
160-
--> tests/ui/missing_const_for_fn/could_be_const.rs:122:9
160+
--> tests/ui/missing_const_for_fn/could_be_const.rs:117:1
161+
|
162+
LL | fn d(this: D) {}
163+
| ^^^^^^^^^^^^^^^^
164+
165+
error: this could be a `const fn`
166+
--> tests/ui/missing_const_for_fn/could_be_const.rs:125:9
161167
|
162168
LL | / fn deref_ptr_can_be_const(self) -> usize {
163169
LL | |
@@ -171,7 +177,7 @@ LL | const fn deref_ptr_can_be_const(self) -> usize {
171177
| +++++
172178

173179
error: this could be a `const fn`
174-
--> tests/ui/missing_const_for_fn/could_be_const.rs:127:9
180+
--> tests/ui/missing_const_for_fn/could_be_const.rs:130:9
175181
|
176182
LL | / fn deref_copied_val(self) -> usize {
177183
LL | |
@@ -185,7 +191,7 @@ LL | const fn deref_copied_val(self) -> usize {
185191
| +++++
186192

187193
error: this could be a `const fn`
188-
--> tests/ui/missing_const_for_fn/could_be_const.rs:138:5
194+
--> tests/ui/missing_const_for_fn/could_be_const.rs:141:5
189195
|
190196
LL | / fn union_access_can_be_const() {
191197
LL | |
@@ -200,7 +206,7 @@ LL | const fn union_access_can_be_const() {
200206
| +++++
201207

202208
error: this could be a `const fn`
203-
--> tests/ui/missing_const_for_fn/could_be_const.rs:152:9
209+
--> tests/ui/missing_const_for_fn/could_be_const.rs:155:9
204210
|
205211
LL | / pub fn new(strings: Vec<String>) -> Self {
206212
LL | | Self { strings }
@@ -213,7 +219,7 @@ LL | pub const fn new(strings: Vec<String>) -> Self {
213219
| +++++
214220

215221
error: this could be a `const fn`
216-
--> tests/ui/missing_const_for_fn/could_be_const.rs:157:9
222+
--> tests/ui/missing_const_for_fn/could_be_const.rs:160:9
217223
|
218224
LL | / pub fn empty() -> Self {
219225
LL | | Self { strings: Vec::new() }
@@ -226,7 +232,7 @@ LL | pub const fn empty() -> Self {
226232
| +++++
227233

228234
error: this could be a `const fn`
229-
--> tests/ui/missing_const_for_fn/could_be_const.rs:168:9
235+
--> tests/ui/missing_const_for_fn/could_be_const.rs:171:9
230236
|
231237
LL | / pub fn new(text: String) -> Self {
232238
LL | | let vec = Vec::new();
@@ -239,5 +245,5 @@ help: make the function `const`
239245
LL | pub const fn new(text: String) -> Self {
240246
| +++++
241247

242-
error: aborting due to 17 previous errors
248+
error: aborting due to 18 previous errors
243249

tests/crashes/119717.rs

-10
This file was deleted.

tests/crashes/123664.rs

-4
This file was deleted.

tests/crashes/124857.rs

-11
This file was deleted.

tests/crashes/126148.rs

-23
This file was deleted.

tests/rustdoc/rfc-2632-const-trait-impl.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//
99
// FIXME(effects) add `const_trait` to `Fn` so we use `~const`
1010
// FIXME(effects) restore `const_trait` to `Destruct`
11-
#![feature(const_trait_impl)]
11+
#![allow(incomplete_features)]
12+
#![feature(const_trait_impl, effects)]
1213
#![crate_name = "foo"]
1314

1415
use std::marker::Destruct;

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage-1.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied
2-
--> $DIR/assoc-type-const-bound-usage-1.rs:16:44
2+
--> $DIR/assoc-type-const-bound-usage-1.rs:15:44
33
|
44
LL | fn unqualified<T: const Trait>() -> Type<{ T::Assoc::func() }> {
55
| ^^^^^^^^ the trait `Compat` is not implemented for `Trait::{synthetic#0}`
66
|
77
note: required by a bound in `Trait::func`
8-
--> $DIR/assoc-type-const-bound-usage-1.rs:8:1
8+
--> $DIR/assoc-type-const-bound-usage-1.rs:7:1
99
|
1010
LL | #[const_trait]
1111
| ^^^^^^^^^^^^^^ required by this bound in `Trait::func`
@@ -14,13 +14,13 @@ LL | fn func() -> i32;
1414
| ---- required by a bound in this associated function
1515

1616
error[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied
17-
--> $DIR/assoc-type-const-bound-usage-1.rs:20:42
17+
--> $DIR/assoc-type-const-bound-usage-1.rs:19:42
1818
|
1919
LL | fn qualified<T: const Trait>() -> Type<{ <T as Trait>::Assoc::func() }> {
2020
| ^^^^^^^^^^^^^^^^^^^ the trait `Compat` is not implemented for `Trait::{synthetic#0}`
2121
|
2222
note: required by a bound in `Trait::func`
23-
--> $DIR/assoc-type-const-bound-usage-1.rs:8:1
23+
--> $DIR/assoc-type-const-bound-usage-1.rs:7:1
2424
|
2525
LL | #[const_trait]
2626
| ^^^^^^^^^^^^^^ required by this bound in `Trait::func`

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | #![feature(const_trait_impl, effects)]
88
= note: `#[warn(incomplete_features)]` on by default
99

1010
error[E0277]: the trait bound `Add::{synthetic#0}: Compat` is not satisfied
11-
--> $DIR/assoc-type.rs:40:15
11+
--> $DIR/assoc-type.rs:41:15
1212
|
1313
LL | type Qux: Add;
1414
| ^^^ the trait `Compat` is not implemented for `Add::{synthetic#0}`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![allow(incomplete_features)]
2+
#![feature(const_trait_impl, effects, try_trait_v2)]
3+
4+
use std::ops::FromResidual;
5+
6+
impl<T> const FromResidual for T {
7+
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
8+
//~| type parameter `T` must be used as the type parameter for some local type
9+
fn from_residual(t: T) -> _ {
10+
//~^ the placeholder `_` is not allowed
11+
t
12+
}
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
2+
--> $DIR/ice-119717-constant-lifetime.rs:6:15
3+
|
4+
LL | impl<T> const FromResidual for T {
5+
| ^^^^^^^^^^^^
6+
|
7+
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
8+
= note: adding a non-const method body in the future would be a breaking change
9+
10+
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
11+
--> $DIR/ice-119717-constant-lifetime.rs:6:6
12+
|
13+
LL | impl<T> const FromResidual for T {
14+
| ^ type parameter `T` must be used as the type parameter for some local type
15+
|
16+
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
17+
= note: only traits defined in the current crate can be implemented for a type parameter
18+
19+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
20+
--> $DIR/ice-119717-constant-lifetime.rs:9:31
21+
|
22+
LL | fn from_residual(t: T) -> _ {
23+
| ^ not allowed in type signatures
24+
|
25+
help: try replacing `_` with the type in the corresponding trait method signature
26+
|
27+
LL | fn from_residual(t: T) -> T {
28+
| ~
29+
30+
error: aborting due to 3 previous errors
31+
32+
Some errors have detailed explanations: E0121, E0210.
33+
For more information about an error, try `rustc --explain E0121`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![allow(incomplete_features)]
2+
#![feature(generic_const_exprs, const_trait_impl, effects)]
3+
4+
const fn with_positive<F: ~const Fn()>() {}
5+
//~^ ERROR `~const` can only be applied to `#[const_trait]` traits
6+
7+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `~const` can only be applied to `#[const_trait]` traits
2+
--> $DIR/ice-123664-unexpected-bound-var.rs:4:34
3+
|
4+
LL | const fn with_positive<F: ~const Fn()>() {}
5+
| ^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ compile-flags: -Znext-solver=coherence
2+
3+
#![allow(incomplete_features)]
4+
#![feature(const_trait_impl, effects)]
5+
6+
#[const_trait]
7+
trait Foo {}
8+
9+
impl const Foo for i32 {}
10+
11+
impl<T> const Foo for T where T: ~const Foo {}
12+
//~^ ERROR conflicting implementations of trait `Foo` for type `i32`
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0119]: conflicting implementations of trait `Foo` for type `i32`
2+
--> $DIR/ice-124857-combine-effect-const-infer-vars.rs:11:1
3+
|
4+
LL | impl const Foo for i32 {}
5+
| ---------------------- first implementation here
6+
LL |
7+
LL | impl<T> const Foo for T where T: ~const Foo {}
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0119`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![allow(incomplete_features)]
2+
#![feature(const_trait_impl, effects, try_trait_v2, const_try)]
3+
use std::ops::{FromResidual, Try};
4+
5+
struct TryMe;
6+
struct Error;
7+
8+
impl const FromResidual<Error> for TryMe {}
9+
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
10+
//~| ERROR not all trait items implemented
11+
12+
impl const Try for TryMe {
13+
//~^ ERROR const `impl` for trait `Try` which is not marked with `#[const_trait]`
14+
//~| ERROR not all trait items implemented
15+
type Output = ();
16+
type Residual = Error;
17+
}
18+
19+
const fn t() -> TryMe {
20+
TryMe?;
21+
TryMe
22+
}
23+
24+
const _: () = {
25+
t();
26+
};
27+
28+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
2+
--> $DIR/ice-126148-failed-to-normalize.rs:8:12
3+
|
4+
LL | impl const FromResidual<Error> for TryMe {}
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
8+
= note: adding a non-const method body in the future would be a breaking change
9+
10+
error[E0046]: not all trait items implemented, missing: `from_residual`
11+
--> $DIR/ice-126148-failed-to-normalize.rs:8:1
12+
|
13+
LL | impl const FromResidual<Error> for TryMe {}
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_residual` in implementation
15+
|
16+
= help: implement the missing item: `fn from_residual(_: Error) -> Self { todo!() }`
17+
18+
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
19+
--> $DIR/ice-126148-failed-to-normalize.rs:12:12
20+
|
21+
LL | impl const Try for TryMe {
22+
| ^^^
23+
|
24+
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
25+
= note: adding a non-const method body in the future would be a breaking change
26+
27+
error[E0046]: not all trait items implemented, missing: `from_output`, `branch`
28+
--> $DIR/ice-126148-failed-to-normalize.rs:12:1
29+
|
30+
LL | impl const Try for TryMe {
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_output`, `branch` in implementation
32+
|
33+
= help: implement the missing item: `fn from_output(_: <Self as Try>::Output) -> Self { todo!() }`
34+
= help: implement the missing item: `fn branch(self) -> ControlFlow<<Self as Try>::Residual, <Self as Try>::Output> { todo!() }`
35+
36+
error: aborting due to 4 previous errors
37+
38+
For more information about this error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)