Skip to content

Commit 8291611

Browse files
authored
Unrolled build for #141968
Rollup merge of #141968 - oli-obk:wfck-everything-at-once, r=wesleywiser Run wfcheck in one big loop instead of per module Maybe we can merge this big loop in the future with the `par_hir_body_owners` call below and run typeck only on items that didn't fail wfcheck. For now let's just see if perf likes it, as it by itself should be beneficial to parallel rustc
2 parents ff223d3 + 82ed50c commit 8291611

File tree

8 files changed

+63
-68
lines changed

8 files changed

+63
-68
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
77
use rustc_errors::codes::*;
88
use rustc_errors::{Applicability, ErrorGuaranteed, pluralize, struct_span_code_err};
99
use rustc_hir::def::{DefKind, Res};
10-
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
10+
use rustc_hir::def_id::{DefId, LocalDefId};
1111
use rustc_hir::lang_items::LangItem;
1212
use rustc_hir::{AmbigArg, ItemKind};
1313
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
@@ -2402,8 +2402,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
24022402
}
24032403
}
24042404

2405-
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), ErrorGuaranteed> {
2406-
let items = tcx.hir_module_items(module);
2405+
fn check_type_wf(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> {
2406+
let items = tcx.hir_crate_items(());
24072407
let res = items
24082408
.par_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id))
24092409
.and(items.par_impl_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id)))
@@ -2412,9 +2412,8 @@ fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), Error
24122412
items.par_foreign_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id)),
24132413
)
24142414
.and(items.par_opaques(|item| tcx.ensure_ok().check_well_formed(item)));
2415-
if module == LocalModDefId::CRATE_DEF_ID {
2416-
super::entry::check_for_entry_fn(tcx);
2417-
}
2415+
super::entry::check_for_entry_fn(tcx);
2416+
24182417
res
24192418
}
24202419

@@ -2552,5 +2551,5 @@ struct RedundantLifetimeArgsLint<'tcx> {
25522551
}
25532552

25542553
pub fn provide(providers: &mut Providers) {
2555-
*providers = Providers { check_mod_type_wf, check_well_formed, ..*providers };
2554+
*providers = Providers { check_type_wf, check_well_formed, ..*providers };
25562555
}

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
182182
// what we are intending to discard, to help future type-based refactoring.
183183
type R = Result<(), ErrorGuaranteed>;
184184

185-
tcx.par_hir_for_each_module(|module| {
186-
let _: R = tcx.ensure_ok().check_mod_type_wf(module);
187-
});
185+
let _: R = tcx.ensure_ok().check_type_wf(());
188186

189187
for &trait_def_id in tcx.all_local_trait_impls(()).keys() {
190188
let _: R = tcx.ensure_ok().coherent_trait(trait_def_id);

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,8 +1148,8 @@ rustc_queries! {
11481148
desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) }
11491149
}
11501150

1151-
query check_mod_type_wf(key: LocalModDefId) -> Result<(), ErrorGuaranteed> {
1152-
desc { |tcx| "checking that types are well-formed in {}", describe_as_module(key, tcx) }
1151+
query check_type_wf(key: ()) -> Result<(), ErrorGuaranteed> {
1152+
desc { "checking that types are well-formed" }
11531153
return_result_from_ensure_ok
11541154
}
11551155

src/librustdoc/core.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,7 @@ pub(crate) fn run_global_ctxt(
345345
// (see `override_queries` in the `config`)
346346

347347
// NOTE: These are copy/pasted from typeck/lib.rs and should be kept in sync with those changes.
348-
let _ = tcx.sess.time("wf_checking", || {
349-
tcx.try_par_hir_for_each_module(|module| tcx.ensure_ok().check_mod_type_wf(module))
350-
});
348+
let _ = tcx.sess.time("wf_checking", || tcx.ensure_ok().check_type_wf(()));
351349

352350
tcx.dcx().abort_if_errors();
353351

tests/ui/impl-trait/in-assoc-type-unconstrained.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ note: required by a bound in `compare_ty::Trait::Ty`
1212
LL | type Ty: IntoIterator<Item = ()>;
1313
| ^^^^^^^^^ required by this bound in `Trait::Ty`
1414

15-
error: unconstrained opaque type
16-
--> $DIR/in-assoc-type-unconstrained.rs:8:26
17-
|
18-
LL | type Ty = Option<impl Sized>;
19-
| ^^^^^^^^^^
20-
|
21-
= note: `Ty` must be used in combination with a concrete type within the same impl
22-
2315
error[E0053]: method `method` has an incompatible type for trait
2416
--> $DIR/in-assoc-type-unconstrained.rs:22:24
2517
|
@@ -42,6 +34,14 @@ LL - fn method() -> () {}
4234
LL + fn method() -> <() as compare_method::Trait>::Ty {}
4335
|
4436

37+
error: unconstrained opaque type
38+
--> $DIR/in-assoc-type-unconstrained.rs:8:26
39+
|
40+
LL | type Ty = Option<impl Sized>;
41+
| ^^^^^^^^^^
42+
|
43+
= note: `Ty` must be used in combination with a concrete type within the same impl
44+
4545
error: unconstrained opaque type
4646
--> $DIR/in-assoc-type-unconstrained.rs:20:19
4747
|

tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@ LL - fn eq(&self, _other: &(Foo, i32)) -> bool {
1515
LL + fn eq(&self, _other: &(a::Bar, i32)) -> bool {
1616
|
1717

18-
error: item does not constrain `a::Foo::{opaque#0}`
19-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:12
20-
|
21-
LL | fn eq(&self, _other: &(Foo, i32)) -> bool {
22-
| ^^
23-
|
24-
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
25-
note: this opaque type is supposed to be constrained
26-
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16
27-
|
28-
LL | type Foo = impl PartialEq<(Foo, i32)>;
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
30-
3118
error[E0053]: method `eq` has an incompatible type for trait
3219
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:25:30
3320
|
@@ -50,6 +37,19 @@ LL - fn eq(&self, _other: &(Bar, i32)) -> bool {
5037
LL + fn eq(&self, _other: &(b::Foo, i32)) -> bool {
5138
|
5239

40+
error: item does not constrain `a::Foo::{opaque#0}`
41+
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:12
42+
|
43+
LL | fn eq(&self, _other: &(Foo, i32)) -> bool {
44+
| ^^
45+
|
46+
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
47+
note: this opaque type is supposed to be constrained
48+
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16
49+
|
50+
LL | type Foo = impl PartialEq<(Foo, i32)>;
51+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
52+
5353
error: unconstrained opaque type
5454
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:19:16
5555
|

tests/ui/privacy/privacy3.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ error[E0432]: unresolved import `bar::gpriv`
44
LL | use bar::gpriv;
55
| ^^^^^^^^^^ no `gpriv` in `bar`
66

7+
error: requires `sized` lang_item
8+
--> $DIR/privacy3.rs:13:20
9+
|
10+
LL | fn gpriv() {}
11+
| ^^
12+
713
error: requires `sized` lang_item
814
--> $DIR/privacy3.rs:18:14
915
|
@@ -28,12 +34,6 @@ error: requires `sized` lang_item
2834
LL | fn main() {}
2935
| ^^
3036

31-
error: requires `sized` lang_item
32-
--> $DIR/privacy3.rs:13:20
33-
|
34-
LL | fn gpriv() {}
35-
| ^^
36-
3737
error: aborting due to 5 previous errors
3838

3939
For more information about this error, try `rustc --explain E0432`.

tests/ui/type-alias-impl-trait/constrain_inputs.stderr

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@ LL | type BadTraitRef = dyn Fn(Ty<'_>) -> &str;
2525
= note: lifetimes appearing in an associated or opaque type are not considered constrained
2626
= note: consider introducing a named lifetime parameter
2727

28-
error: item does not constrain `lifetime_params::Ty::{opaque#0}`
29-
--> $DIR/constrain_inputs.rs:8:8
30-
|
31-
LL | fn execute(ty: Ty<'_>) -> &str { todo!() }
32-
| ^^^^^^^
33-
|
34-
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
35-
note: this opaque type is supposed to be constrained
36-
--> $DIR/constrain_inputs.rs:4:19
37-
|
38-
LL | type Ty<'a> = impl Sized;
39-
| ^^^^^^^^^^
40-
4128
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
4229
--> $DIR/constrain_inputs.rs:23:31
4330
|
@@ -47,19 +34,6 @@ LL | fn execute(ty: Ty<'_>) -> &str { ty() }
4734
= note: lifetimes appearing in an associated or opaque type are not considered constrained
4835
= note: consider introducing a named lifetime parameter
4936

50-
error: item does not constrain `lifetime_params_2::Ty::{opaque#0}`
51-
--> $DIR/constrain_inputs.rs:23:8
52-
|
53-
LL | fn execute(ty: Ty<'_>) -> &str { ty() }
54-
| ^^^^^^^
55-
|
56-
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
57-
note: this opaque type is supposed to be constrained
58-
--> $DIR/constrain_inputs.rs:19:19
59-
|
60-
LL | type Ty<'a> = impl FnOnce() -> &'a str;
61-
| ^^^^^^^^^^^^^^^^^^^^^^^^
62-
6337
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
6438
--> $DIR/constrain_inputs.rs:34:37
6539
|
@@ -78,6 +52,32 @@ LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str;
7852
= note: lifetimes appearing in an associated or opaque type are not considered constrained
7953
= note: consider introducing a named lifetime parameter
8054

55+
error: item does not constrain `lifetime_params::Ty::{opaque#0}`
56+
--> $DIR/constrain_inputs.rs:8:8
57+
|
58+
LL | fn execute(ty: Ty<'_>) -> &str { todo!() }
59+
| ^^^^^^^
60+
|
61+
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
62+
note: this opaque type is supposed to be constrained
63+
--> $DIR/constrain_inputs.rs:4:19
64+
|
65+
LL | type Ty<'a> = impl Sized;
66+
| ^^^^^^^^^^
67+
68+
error: item does not constrain `lifetime_params_2::Ty::{opaque#0}`
69+
--> $DIR/constrain_inputs.rs:23:8
70+
|
71+
LL | fn execute(ty: Ty<'_>) -> &str { ty() }
72+
| ^^^^^^^
73+
|
74+
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
75+
note: this opaque type is supposed to be constrained
76+
--> $DIR/constrain_inputs.rs:19:19
77+
|
78+
LL | type Ty<'a> = impl FnOnce() -> &'a str;
79+
| ^^^^^^^^^^^^^^^^^^^^^^^^
80+
8181
error: aborting due to 8 previous errors
8282

8383
Some errors have detailed explanations: E0581, E0582.

0 commit comments

Comments
 (0)