Skip to content

Commit b105556

Browse files
committed
Auto merge of #140854 - oli-obk:merge-queries, r=nnethercote
Merge typeck loop with static/const item eval loop r? `@ghost` Let's try a small one first. Doing this in general has some bad cache coherence issues because the query caches are laid out in `Vec<QueryResult>` lists per query where each index refers to a `DefId` in the same order as we're iterating. Iterating two or more lists at the same time does have cache issues, so I want to poke a bit at it to see if we can't merge just a few of them at a time.
2 parents 7e432c4 + 0b6e493 commit b105556

File tree

11 files changed

+119
-123
lines changed

11 files changed

+119
-123
lines changed

compiler/rustc_hir_analysis/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
223223
}
224224
_ => (),
225225
}
226-
});
227-
228-
tcx.par_hir_body_owners(|item_def_id| {
229-
let def_kind = tcx.def_kind(item_def_id);
230226
// Skip `AnonConst`s because we feed their `type_of`.
231227
if !matches!(def_kind, DefKind::AnonConst) {
232228
tcx.ensure_ok().typeck(item_def_id);

tests/ui/closures/closure-return-type-mismatch.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/closure-return-type-mismatch.rs:20:41
3-
|
4-
LL | static FOO: fn() -> bool = || -> bool { 1 };
5-
| ---- ^ expected `bool`, found integer
6-
| |
7-
| expected `bool` because of return type
8-
91
error[E0308]: mismatched types
102
--> $DIR/closure-return-type-mismatch.rs:7:9
113
|
@@ -27,6 +19,14 @@ LL | if false {
2719
LL | return "hello"
2820
| ^^^^^^^ expected `bool`, found `&str`
2921

22+
error[E0308]: mismatched types
23+
--> $DIR/closure-return-type-mismatch.rs:20:41
24+
|
25+
LL | static FOO: fn() -> bool = || -> bool { 1 };
26+
| ---- ^ expected `bool`, found integer
27+
| |
28+
| expected `bool` because of return type
29+
3030
error: aborting due to 3 previous errors
3131

3232
For more information about this error, try `rustc --explain E0308`.

tests/ui/coercion/coerce-loop-issue-122561.stderr

+15-15
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ help: consider returning a value here
2424
LL | fn for_in_arg(a: &[(); for x in 0..2 {} /* `usize` value */]) -> bool {
2525
| +++++++++++++++++++
2626

27-
error[E0308]: mismatched types
28-
--> $DIR/coerce-loop-issue-122561.rs:85:5
29-
|
30-
LL | / for i in 0.. {
31-
LL | |
32-
LL | | }
33-
| |_____^ expected `i32`, found `()`
34-
|
35-
= note: `for` loops evaluate to unit type `()`
36-
help: consider returning a value here
37-
|
38-
LL ~ }
39-
LL + /* `i32` value */
40-
|
41-
4227
error[E0308]: mismatched types
4328
--> $DIR/coerce-loop-issue-122561.rs:4:5
4429
|
@@ -202,6 +187,21 @@ LL ~ }
202187
LL + /* `loop {}` or `panic!("...")` */
203188
|
204189

190+
error[E0308]: mismatched types
191+
--> $DIR/coerce-loop-issue-122561.rs:85:5
192+
|
193+
LL | / for i in 0.. {
194+
LL | |
195+
LL | | }
196+
| |_____^ expected `i32`, found `()`
197+
|
198+
= note: `for` loops evaluate to unit type `()`
199+
help: consider returning a value here
200+
|
201+
LL ~ }
202+
LL + /* `i32` value */
203+
|
204+
205205
error[E0308]: mismatched types
206206
--> $DIR/coerce-loop-issue-122561.rs:92:9
207207
|

tests/ui/consts/effect_param.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
2-
--> $DIR/effect_param.rs:11:9
2+
--> $DIR/effect_param.rs:4:9
33
|
4-
LL | i8::checked_sub::<false>(42, 43);
5-
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
4+
LL | i8::checked_sub::<true>(42, 43);
5+
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
66
| |
77
| expected 0 generic arguments
88

99
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
10-
--> $DIR/effect_param.rs:13:9
10+
--> $DIR/effect_param.rs:6:9
1111
|
12-
LL | i8::checked_sub::<true>(42, 43);
13-
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
12+
LL | i8::checked_sub::<false>(42, 43);
13+
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
1414
| |
1515
| expected 0 generic arguments
1616

1717
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
18-
--> $DIR/effect_param.rs:4:9
18+
--> $DIR/effect_param.rs:11:9
1919
|
20-
LL | i8::checked_sub::<true>(42, 43);
21-
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
20+
LL | i8::checked_sub::<false>(42, 43);
21+
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
2222
| |
2323
| expected 0 generic arguments
2424

2525
error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
26-
--> $DIR/effect_param.rs:6:9
26+
--> $DIR/effect_param.rs:13:9
2727
|
28-
LL | i8::checked_sub::<false>(42, 43);
29-
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
28+
LL | i8::checked_sub::<true>(42, 43);
29+
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
3030
| |
3131
| expected 0 generic arguments
3232

tests/ui/did_you_mean/dont-suggest-hygienic-fields.stderr

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
error[E0560]: struct `Crate` has no field named `fiel`
2-
--> $DIR/dont-suggest-hygienic-fields.rs:44:34
3-
|
4-
LL | environment!();
5-
| -------------- in this macro invocation
6-
...
7-
LL | const CRATE: Crate = Crate { fiel: () };
8-
| ^^^^ unknown field
9-
|
10-
= note: this error originates in the macro `environment` (in Nightly builds, run with -Z macro-backtrace for more info)
11-
help: a field with a similar name exists
12-
|
13-
LL | const CRATE: Crate = Crate { field: () };
14-
| +
15-
161
error[E0609]: no field `field` on type `Compound`
172
--> $DIR/dont-suggest-hygienic-fields.rs:24:16
183
|
@@ -48,6 +33,21 @@ error[E0609]: no field `0` on type `Component`
4833
LL | let _ = ty.0;
4934
| ^ unknown field
5035

36+
error[E0560]: struct `Crate` has no field named `fiel`
37+
--> $DIR/dont-suggest-hygienic-fields.rs:44:34
38+
|
39+
LL | environment!();
40+
| -------------- in this macro invocation
41+
...
42+
LL | const CRATE: Crate = Crate { fiel: () };
43+
| ^^^^ unknown field
44+
|
45+
= note: this error originates in the macro `environment` (in Nightly builds, run with -Z macro-backtrace for more info)
46+
help: a field with a similar name exists
47+
|
48+
LL | const CRATE: Crate = Crate { field: () };
49+
| +
50+
5151
error: aborting due to 6 previous errors
5252

5353
Some errors have detailed explanations: E0026, E0560, E0609.

tests/ui/impl-trait/normalize-tait-in-const.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ LL | pub type Alias<'a> = impl T<Item = &'a ()>;
2525
|
2626
= note: `Alias` must be used in combination with a concrete type within the same crate
2727

28-
error[E0015]: cannot call non-const closure in constant functions
29-
--> $DIR/normalize-tait-in-const.rs:28:5
30-
|
31-
LL | fun(filter_positive());
32-
| ^^^^^^^^^^^^^^^^^^^^^^
33-
|
34-
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
35-
3628
error[E0308]: mismatched types
3729
--> $DIR/normalize-tait-in-const.rs:22:9
3830
|
@@ -52,6 +44,14 @@ note: this item must have a `#[define_opaque(foo::Alias)]` attribute to be able
5244
LL | pub const fn filter_positive<'a>() -> &'a Alias<'a> {
5345
| ^^^^^^^^^^^^^^^
5446

47+
error[E0015]: cannot call non-const closure in constant functions
48+
--> $DIR/normalize-tait-in-const.rs:28:5
49+
|
50+
LL | fun(filter_positive());
51+
| ^^^^^^^^^^^^^^^^^^^^^^
52+
|
53+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
54+
5555
error: aborting due to 5 previous errors
5656

5757
Some errors have detailed explanations: E0015, E0308.

tests/ui/parser/pat-lt-bracket-6.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ LL | let Test(&desc[..]) = x;
66
|
77
= note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
88

9-
error[E0308]: mismatched types
10-
--> $DIR/pat-lt-bracket-6.rs:10:30
11-
|
12-
LL | const RECOVERY_WITNESS: () = 0;
13-
| ^ expected `()`, found integer
14-
159
error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
1610
--> $DIR/pat-lt-bracket-6.rs:5:14
1711
|
@@ -26,6 +20,12 @@ help: use `_` to explicitly ignore each field
2620
LL | let Test(&desc[..], _) = x;
2721
| +++
2822

23+
error[E0308]: mismatched types
24+
--> $DIR/pat-lt-bracket-6.rs:10:30
25+
|
26+
LL | const RECOVERY_WITNESS: () = 0;
27+
| ^ expected `()`, found integer
28+
2929
error: aborting due to 3 previous errors
3030

3131
Some errors have detailed explanations: E0023, E0308.

tests/ui/proc-macro/bad-projection.stderr

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ help: this trait has no implementations, consider adding one
1010
LL | trait Project {
1111
| ^^^^^^^^^^^^^
1212

13+
error[E0277]: the trait bound `(): Project` is not satisfied
14+
--> $DIR/bad-projection.rs:14:17
15+
|
16+
LL | pub fn uwu() -> <() as Project>::Assoc {}
17+
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()`
18+
|
19+
help: this trait has no implementations, consider adding one
20+
--> $DIR/bad-projection.rs:9:1
21+
|
22+
LL | trait Project {
23+
| ^^^^^^^^^^^^^
24+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
25+
1326
error[E0593]: function is expected to take 1 argument, but it takes 0 arguments
1427
--> $DIR/bad-projection.rs:14:1
1528
|
@@ -47,19 +60,6 @@ help: this trait has no implementations, consider adding one
4760
LL | trait Project {
4861
| ^^^^^^^^^^^^^
4962

50-
error[E0277]: the trait bound `(): Project` is not satisfied
51-
--> $DIR/bad-projection.rs:14:17
52-
|
53-
LL | pub fn uwu() -> <() as Project>::Assoc {}
54-
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()`
55-
|
56-
help: this trait has no implementations, consider adding one
57-
--> $DIR/bad-projection.rs:9:1
58-
|
59-
LL | trait Project {
60-
| ^^^^^^^^^^^^^
61-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
62-
6363
error: aborting due to 5 previous errors
6464

6565
Some errors have detailed explanations: E0277, E0593.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/dont-suggest-through-inner-const.rs:4:9
3-
|
4-
LL | 0
5-
| ^ expected `()`, found integer
6-
71
error[E0308]: mismatched types
82
--> $DIR/dont-suggest-through-inner-const.rs:1:17
93
|
@@ -12,6 +6,12 @@ LL | const fn f() -> usize {
126
| |
137
| implicitly returns `()` as its body has no tail or `return` expression
148

9+
error[E0308]: mismatched types
10+
--> $DIR/dont-suggest-through-inner-const.rs:4:9
11+
|
12+
LL | 0
13+
| ^ expected `()`, found integer
14+
1515
error: aborting due to 2 previous errors
1616

1717
For more information about this error, try `rustc --explain E0308`.

tests/ui/traits/const-traits/no-explicit-const-params.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied
2-
--> $DIR/no-explicit-const-params.rs:22:5
2+
--> $DIR/no-explicit-const-params.rs:15:5
33
|
4-
LL | foo::<false>();
5-
| ^^^--------- help: remove the unnecessary generics
4+
LL | foo::<true>();
5+
| ^^^-------- help: remove the unnecessary generics
66
| |
77
| expected 0 generic arguments
88
|
@@ -13,10 +13,10 @@ LL | const fn foo() {}
1313
| ^^^
1414

1515
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
16-
--> $DIR/no-explicit-const-params.rs:24:12
16+
--> $DIR/no-explicit-const-params.rs:17:12
1717
|
18-
LL | <() as Bar<false>>::bar();
19-
| ^^^------- help: remove the unnecessary generics
18+
LL | <() as Bar<true>>::bar();
19+
| ^^^------ help: remove the unnecessary generics
2020
| |
2121
| expected 0 generic arguments
2222
|
@@ -26,17 +26,11 @@ note: trait defined here, with 0 generic parameters
2626
LL | trait Bar {
2727
| ^^^
2828

29-
error[E0277]: the trait bound `(): const Bar` is not satisfied
30-
--> $DIR/no-explicit-const-params.rs:24:6
31-
|
32-
LL | <() as Bar<false>>::bar();
33-
| ^^
34-
3529
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied
36-
--> $DIR/no-explicit-const-params.rs:15:5
30+
--> $DIR/no-explicit-const-params.rs:22:5
3731
|
38-
LL | foo::<true>();
39-
| ^^^-------- help: remove the unnecessary generics
32+
LL | foo::<false>();
33+
| ^^^--------- help: remove the unnecessary generics
4034
| |
4135
| expected 0 generic arguments
4236
|
@@ -47,10 +41,10 @@ LL | const fn foo() {}
4741
| ^^^
4842

4943
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
50-
--> $DIR/no-explicit-const-params.rs:17:12
44+
--> $DIR/no-explicit-const-params.rs:24:12
5145
|
52-
LL | <() as Bar<true>>::bar();
53-
| ^^^------ help: remove the unnecessary generics
46+
LL | <() as Bar<false>>::bar();
47+
| ^^^------- help: remove the unnecessary generics
5448
| |
5549
| expected 0 generic arguments
5650
|
@@ -60,6 +54,12 @@ note: trait defined here, with 0 generic parameters
6054
LL | trait Bar {
6155
| ^^^
6256

57+
error[E0277]: the trait bound `(): const Bar` is not satisfied
58+
--> $DIR/no-explicit-const-params.rs:24:6
59+
|
60+
LL | <() as Bar<false>>::bar();
61+
| ^^
62+
6363
error: aborting due to 5 previous errors
6464

6565
Some errors have detailed explanations: E0107, E0277.

0 commit comments

Comments
 (0)