Skip to content

Commit 6ad01e9

Browse files
committed
run wfcheck in parralel again, add test for 74950
1 parent 70dfe3f commit 6ad01e9

File tree

6 files changed

+92
-15
lines changed

6 files changed

+92
-15
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,8 @@ impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> {
729729
}
730730

731731
pub fn check_wf_new(tcx: TyCtxt<'_>) {
732-
let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx);
733-
tcx.hir().krate().visit_all_item_likes(&mut visit.as_deep_visitor());
732+
let visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx);
733+
tcx.hir().krate().par_visit_all_item_likes(&visit);
734734
}
735735

736736
fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {

src/librustc_typeck/check/wfcheck.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc_hir as hir;
88
use rustc_hir::def_id::{DefId, LocalDefId};
99
use rustc_hir::intravisit as hir_visit;
1010
use rustc_hir::intravisit::Visitor;
11+
use rustc_hir::itemlikevisit::ParItemLikeVisitor;
1112
use rustc_hir::lang_items;
1213
use rustc_hir::ItemKind;
1314
use rustc_middle::hir::map as hir_map;
@@ -1373,6 +1374,7 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, span: Span, id: hir::HirId) {
13731374
fcx.select_all_obligations_or_error();
13741375
}
13751376

1377+
#[derive(Clone, Copy)]
13761378
pub struct CheckTypeWellFormedVisitor<'tcx> {
13771379
tcx: TyCtxt<'tcx>,
13781380
}
@@ -1383,6 +1385,20 @@ impl CheckTypeWellFormedVisitor<'tcx> {
13831385
}
13841386
}
13851387

1388+
impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
1389+
fn visit_item(&self, i: &'tcx hir::Item<'tcx>) {
1390+
Visitor::visit_item(&mut self.clone(), i);
1391+
}
1392+
1393+
fn visit_trait_item(&self, trait_item: &'tcx hir::TraitItem<'tcx>) {
1394+
Visitor::visit_trait_item(&mut self.clone(), trait_item);
1395+
}
1396+
1397+
fn visit_impl_item(&self, impl_item: &'tcx hir::ImplItem<'tcx>) {
1398+
Visitor::visit_impl_item(&mut self.clone(), impl_item);
1399+
}
1400+
}
1401+
13861402
impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
13871403
type Map = hir_map::Map<'tcx>;
13881404

@@ -1413,8 +1429,7 @@ impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
14131429

14141430
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
14151431
check_param_wf(self.tcx, p);
1416-
// No need to walk further here, there is nothing interesting
1417-
// inside of generic params we don't already check in `check_param_wf`.
1432+
hir_visit::walk_generic_param(self, p);
14181433
}
14191434
}
14201435

src/test/ui/const-generics/issues/issue-56445.min.stderr

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
66
|
77
= note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
88

9-
error: using `&'static str` as const generic parameters is forbidden
10-
--> $DIR/issue-56445.rs:9:25
11-
|
12-
LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
13-
| ^^^^^^^
14-
|
15-
= note: the only supported types are integers, `bool` and `char`
16-
= note: more complex types are supported with `#[feature(const_generics)]`
17-
18-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1910

2011
For more information about this error, try `rustc --explain E0771`.

src/test/ui/const-generics/issues/issue-56445.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ use std::marker::PhantomData;
88

99
struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
1010
//~^ ERROR: use of non-static lifetime `'a` in const generic
11-
//[min]~| ERROR: using `&'static str` as const
1211

1312
impl Bug<'_, ""> {}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
error: using `Inner` as const generic parameters is forbidden
2+
--> $DIR/issue-74950.rs:18:23
3+
|
4+
LL | struct Outer<const I: Inner>;
5+
| ^^^^^
6+
|
7+
= note: the only supported types are integers, `bool` and `char`
8+
= note: more complex types are supported with `#[feature(const_generics)]`
9+
10+
error: using `Inner` as const generic parameters is forbidden
11+
--> $DIR/issue-74950.rs:18:23
12+
|
13+
LL | struct Outer<const I: Inner>;
14+
| ^^^^^
15+
|
16+
= note: the only supported types are integers, `bool` and `char`
17+
= note: more complex types are supported with `#[feature(const_generics)]`
18+
19+
error: using `Inner` as const generic parameters is forbidden
20+
--> $DIR/issue-74950.rs:18:23
21+
|
22+
LL | struct Outer<const I: Inner>;
23+
| ^^^^^
24+
|
25+
= note: the only supported types are integers, `bool` and `char`
26+
= note: more complex types are supported with `#[feature(const_generics)]`
27+
28+
error: using `Inner` as const generic parameters is forbidden
29+
--> $DIR/issue-74950.rs:18:23
30+
|
31+
LL | struct Outer<const I: Inner>;
32+
| ^^^^^
33+
|
34+
= note: the only supported types are integers, `bool` and `char`
35+
= note: more complex types are supported with `#[feature(const_generics)]`
36+
37+
error: using `Inner` as const generic parameters is forbidden
38+
--> $DIR/issue-74950.rs:18:23
39+
|
40+
LL | struct Outer<const I: Inner>;
41+
| ^^^^^
42+
|
43+
= note: the only supported types are integers, `bool` and `char`
44+
= note: more complex types are supported with `#[feature(const_generics)]`
45+
46+
error: aborting due to 5 previous errors
47+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// [full] build-pass
2+
// revisions: full min
3+
#![cfg_attr(full, feature(const_generics))]
4+
#![cfg_attr(full, allow(incomplete_features))]
5+
#![cfg_attr(min, feature(min_const_generics))]
6+
7+
8+
#[derive(PartialEq, Eq)]
9+
struct Inner;
10+
11+
// Note: We emit the error 5 times if we don't deduplicate:
12+
// - struct definition
13+
// - impl PartialEq
14+
// - impl Eq
15+
// - impl StructuralPartialEq
16+
// - impl StructuralEq
17+
#[derive(PartialEq, Eq)]
18+
struct Outer<const I: Inner>;
19+
//[min]~^ using `Inner` as const generic parameters is forbidden
20+
//[min]~| using `Inner` as const generic parameters is forbidden
21+
//[min]~| using `Inner` as const generic parameters is forbidden
22+
//[min]~| using `Inner` as const generic parameters is forbidden
23+
//[min]~| using `Inner` as const generic parameters is forbidden
24+
25+
fn main() {}

0 commit comments

Comments
 (0)