Merge typeck loop with static/const item eval loop

This commit is contained in:
Oli Scherer 2025-05-09 15:16:26 +00:00
parent e964ccafed
commit 0b6e493515
11 changed files with 133 additions and 137 deletions

View File

@ -223,10 +223,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
}
_ => (),
}
});
tcx.par_hir_body_owners(|item_def_id| {
let def_kind = tcx.def_kind(item_def_id);
// Skip `AnonConst`s because we feed their `type_of`.
if !matches!(def_kind, DefKind::AnonConst) {
tcx.ensure_ok().typeck(item_def_id);

View File

@ -1,11 +1,3 @@
error[E0308]: mismatched types
--> $DIR/closure-return-type-mismatch.rs:20:41
|
LL | static FOO: fn() -> bool = || -> bool { 1 };
| ---- ^ expected `bool`, found integer
| |
| expected `bool` because of return type
error[E0308]: mismatched types
--> $DIR/closure-return-type-mismatch.rs:7:9
|
@ -27,6 +19,14 @@ LL | if false {
LL | return "hello"
| ^^^^^^^ expected `bool`, found `&str`
error[E0308]: mismatched types
--> $DIR/closure-return-type-mismatch.rs:20:41
|
LL | static FOO: fn() -> bool = || -> bool { 1 };
| ---- ^ expected `bool`, found integer
| |
| expected `bool` because of return type
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -24,21 +24,6 @@ help: consider returning a value here
LL | fn for_in_arg(a: &[(); for x in 0..2 {} /* `usize` value */]) -> bool {
| +++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/coerce-loop-issue-122561.rs:85:5
|
LL | / for i in 0.. {
LL | |
LL | | }
| |_____^ expected `i32`, found `()`
|
= note: `for` loops evaluate to unit type `()`
help: consider returning a value here
|
LL ~ }
LL + /* `i32` value */
|
error[E0308]: mismatched types
--> $DIR/coerce-loop-issue-122561.rs:4:5
|
@ -202,6 +187,21 @@ LL ~ }
LL + /* `loop {}` or `panic!("...")` */
|
error[E0308]: mismatched types
--> $DIR/coerce-loop-issue-122561.rs:85:5
|
LL | / for i in 0.. {
LL | |
LL | | }
| |_____^ expected `i32`, found `()`
|
= note: `for` loops evaluate to unit type `()`
help: consider returning a value here
|
LL ~ }
LL + /* `i32` value */
|
error[E0308]: mismatched types
--> $DIR/coerce-loop-issue-122561.rs:92:9
|

View File

@ -1,19 +1,3 @@
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/effect_param.rs:11:9
|
LL | i8::checked_sub::<false>(42, 43);
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/effect_param.rs:13:9
|
LL | i8::checked_sub::<true>(42, 43);
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/effect_param.rs:4:9
|
@ -30,6 +14,22 @@ LL | i8::checked_sub::<false>(42, 43);
| |
| expected 0 generic arguments
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/effect_param.rs:11:9
|
LL | i8::checked_sub::<false>(42, 43);
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/effect_param.rs:13:9
|
LL | i8::checked_sub::<true>(42, 43);
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0107`.

View File

@ -1,18 +1,3 @@
error[E0560]: struct `Crate` has no field named `fiel`
--> $DIR/dont-suggest-hygienic-fields.rs:44:34
|
LL | environment!();
| -------------- in this macro invocation
...
LL | const CRATE: Crate = Crate { fiel: () };
| ^^^^ unknown field
|
= note: this error originates in the macro `environment` (in Nightly builds, run with -Z macro-backtrace for more info)
help: a field with a similar name exists
|
LL | const CRATE: Crate = Crate { field: () };
| +
error[E0609]: no field `field` on type `Compound`
--> $DIR/dont-suggest-hygienic-fields.rs:24:16
|
@ -48,6 +33,21 @@ error[E0609]: no field `0` on type `Component`
LL | let _ = ty.0;
| ^ unknown field
error[E0560]: struct `Crate` has no field named `fiel`
--> $DIR/dont-suggest-hygienic-fields.rs:44:34
|
LL | environment!();
| -------------- in this macro invocation
...
LL | const CRATE: Crate = Crate { fiel: () };
| ^^^^ unknown field
|
= note: this error originates in the macro `environment` (in Nightly builds, run with -Z macro-backtrace for more info)
help: a field with a similar name exists
|
LL | const CRATE: Crate = Crate { field: () };
| +
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0026, E0560, E0609.

View File

@ -25,14 +25,6 @@ LL | pub type Alias<'a> = impl T<Item = &'a ()>;
|
= note: `Alias` must be used in combination with a concrete type within the same crate
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/normalize-tait-in-const.rs:28:5
|
LL | fun(filter_positive());
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error[E0308]: mismatched types
--> $DIR/normalize-tait-in-const.rs:22:9
|
@ -52,6 +44,14 @@ note: this item must have a `#[define_opaque(foo::Alias)]` attribute to be able
LL | pub const fn filter_positive<'a>() -> &'a Alias<'a> {
| ^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/normalize-tait-in-const.rs:28:5
|
LL | fun(filter_positive());
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0015, E0308.

View File

@ -6,12 +6,6 @@ LL | let Test(&desc[..]) = x;
|
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
error[E0308]: mismatched types
--> $DIR/pat-lt-bracket-6.rs:10:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected `()`, found integer
error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
--> $DIR/pat-lt-bracket-6.rs:5:14
|
@ -26,6 +20,12 @@ help: use `_` to explicitly ignore each field
LL | let Test(&desc[..], _) = x;
| +++
error[E0308]: mismatched types
--> $DIR/pat-lt-bracket-6.rs:10:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected `()`, found integer
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0023, E0308.

View File

@ -10,6 +10,19 @@ help: this trait has no implementations, consider adding one
LL | trait Project {
| ^^^^^^^^^^^^^
error[E0277]: the trait bound `(): Project` is not satisfied
--> $DIR/bad-projection.rs:14:17
|
LL | pub fn uwu() -> <() as Project>::Assoc {}
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()`
|
help: this trait has no implementations, consider adding one
--> $DIR/bad-projection.rs:9:1
|
LL | trait Project {
| ^^^^^^^^^^^^^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0593]: function is expected to take 1 argument, but it takes 0 arguments
--> $DIR/bad-projection.rs:14:1
|
@ -47,19 +60,6 @@ help: this trait has no implementations, consider adding one
LL | trait Project {
| ^^^^^^^^^^^^^
error[E0277]: the trait bound `(): Project` is not satisfied
--> $DIR/bad-projection.rs:14:17
|
LL | pub fn uwu() -> <() as Project>::Assoc {}
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()`
|
help: this trait has no implementations, consider adding one
--> $DIR/bad-projection.rs:9:1
|
LL | trait Project {
| ^^^^^^^^^^^^^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0277, E0593.

View File

@ -1,9 +1,3 @@
error[E0308]: mismatched types
--> $DIR/dont-suggest-through-inner-const.rs:4:9
|
LL | 0
| ^ expected `()`, found integer
error[E0308]: mismatched types
--> $DIR/dont-suggest-through-inner-const.rs:1:17
|
@ -12,6 +6,12 @@ LL | const fn f() -> usize {
| |
| implicitly returns `()` as its body has no tail or `return` expression
error[E0308]: mismatched types
--> $DIR/dont-suggest-through-inner-const.rs:4:9
|
LL | 0
| ^ expected `()`, found integer
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View File

@ -1,3 +1,31 @@
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/no-explicit-const-params.rs:15:5
|
LL | foo::<true>();
| ^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: function defined here, with 0 generic parameters
--> $DIR/no-explicit-const-params.rs:3:10
|
LL | const fn foo() {}
| ^^^
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/no-explicit-const-params.rs:17:12
|
LL | <() as Bar<true>>::bar();
| ^^^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: trait defined here, with 0 generic parameters
--> $DIR/no-explicit-const-params.rs:6:7
|
LL | trait Bar {
| ^^^
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/no-explicit-const-params.rs:22:5
|
@ -32,34 +60,6 @@ error[E0277]: the trait bound `(): const Bar` is not satisfied
LL | <() as Bar<false>>::bar();
| ^^
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/no-explicit-const-params.rs:15:5
|
LL | foo::<true>();
| ^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: function defined here, with 0 generic parameters
--> $DIR/no-explicit-const-params.rs:3:10
|
LL | const fn foo() {}
| ^^^
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/no-explicit-const-params.rs:17:12
|
LL | <() as Bar<true>>::bar();
| ^^^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: trait defined here, with 0 generic parameters
--> $DIR/no-explicit-const-params.rs:6:7
|
LL | trait Bar {
| ^^^
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0107, E0277.

View File

@ -1,21 +1,3 @@
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited.rs:41:9
|
LL | assert!(false);
| ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited.rs:63:9
|
LL | assert!(false);
| ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited.rs:87:9
|
LL | assert!(false);
| ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false
error[E0277]: `()` cannot be safely transmuted into `void::Void`
--> $DIR/uninhabited.rs:29:41
|
@ -58,6 +40,12 @@ LL | | lifetimes: true,
LL | | }>
| |__________^ required by this bound in `is_maybe_transmutable`
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited.rs:41:9
|
LL | assert!(false);
| ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false
error[E0277]: `()` cannot be safely transmuted into `yawning_void_enum::Void`
--> $DIR/uninhabited.rs:71:41
|
@ -79,6 +67,12 @@ LL | | lifetimes: true,
LL | | }>
| |__________^ required by this bound in `is_maybe_transmutable`
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited.rs:63:9
|
LL | assert!(false);
| ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false
error[E0277]: `u128` cannot be safely transmuted into `DistantVoid`
--> $DIR/uninhabited.rs:92:43
|
@ -100,6 +94,12 @@ LL | | lifetimes: true,
LL | | }>
| |__________^ required by this bound in `is_maybe_transmutable`
error[E0080]: evaluation of constant value failed
--> $DIR/uninhabited.rs:87:9
|
LL | assert!(false);
| ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false
error[E0277]: `Src` cannot be safely transmuted into `issue_126267::Error`
--> $DIR/uninhabited.rs:108:42
|