diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-08-13 22:26:55 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-08-18 22:14:40 +0200 |
| commit | 6ad01e993272132b96e9f1f9c390c85816672ce3 (patch) | |
| tree | 7c1a167b890754ddf7cfb9563c221400bfbc7284 | |
| parent | 70dfe3fa746ac459747da30aca0bac11379088d5 (diff) | |
| download | rust-6ad01e993272132b96e9f1f9c390c85816672ce3.tar.gz rust-6ad01e993272132b96e9f1f9c390c85816672ce3.zip | |
run wfcheck in parralel again, add test for 74950
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc_typeck/check/wfcheck.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-56445.min.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-56445.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-74950.min.stderr | 47 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-74950.rs | 25 |
6 files changed, 92 insertions, 15 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index dc4f181ec93..824e81a974c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -729,8 +729,8 @@ impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> { } pub fn check_wf_new(tcx: TyCtxt<'_>) { - let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx); - tcx.hir().krate().visit_all_item_likes(&mut visit.as_deep_visitor()); + let visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx); + tcx.hir().krate().par_visit_all_item_likes(&visit); } fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 740f30f5224..cbf302ad710 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -8,6 +8,7 @@ use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit as hir_visit; use rustc_hir::intravisit::Visitor; +use rustc_hir::itemlikevisit::ParItemLikeVisitor; use rustc_hir::lang_items; use rustc_hir::ItemKind; use rustc_middle::hir::map as hir_map; @@ -1373,6 +1374,7 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, span: Span, id: hir::HirId) { fcx.select_all_obligations_or_error(); } +#[derive(Clone, Copy)] pub struct CheckTypeWellFormedVisitor<'tcx> { tcx: TyCtxt<'tcx>, } @@ -1383,6 +1385,20 @@ impl CheckTypeWellFormedVisitor<'tcx> { } } +impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { + fn visit_item(&self, i: &'tcx hir::Item<'tcx>) { + Visitor::visit_item(&mut self.clone(), i); + } + + fn visit_trait_item(&self, trait_item: &'tcx hir::TraitItem<'tcx>) { + Visitor::visit_trait_item(&mut self.clone(), trait_item); + } + + fn visit_impl_item(&self, impl_item: &'tcx hir::ImplItem<'tcx>) { + Visitor::visit_impl_item(&mut self.clone(), impl_item); + } +} + impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { type Map = hir_map::Map<'tcx>; @@ -1413,8 +1429,7 @@ impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> { fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) { check_param_wf(self.tcx, p); - // No need to walk further here, there is nothing interesting - // inside of generic params we don't already check in `check_param_wf`. + hir_visit::walk_generic_param(self, p); } } diff --git a/src/test/ui/const-generics/issues/issue-56445.min.stderr b/src/test/ui/const-generics/issues/issue-56445.min.stderr index ca35ee5b290..bcb27d8d1e1 100644 --- a/src/test/ui/const-generics/issues/issue-56445.min.stderr +++ b/src/test/ui/const-generics/issues/issue-56445.min.stderr @@ -6,15 +6,6 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> -error: using `&'static str` as const generic parameters is forbidden - --> $DIR/issue-56445.rs:9:25 - | -LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); - | ^^^^^^^ - | - = note: the only supported types are integers, `bool` and `char` - = note: more complex types are supported with `#[feature(const_generics)]` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445.rs b/src/test/ui/const-generics/issues/issue-56445.rs index 174eb16abfc..0bcde348b05 100644 --- a/src/test/ui/const-generics/issues/issue-56445.rs +++ b/src/test/ui/const-generics/issues/issue-56445.rs @@ -8,6 +8,5 @@ use std::marker::PhantomData; struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); //~^ ERROR: use of non-static lifetime `'a` in const generic -//[min]~| ERROR: using `&'static str` as const impl Bug<'_, ""> {} diff --git a/src/test/ui/const-generics/issues/issue-74950.min.stderr b/src/test/ui/const-generics/issues/issue-74950.min.stderr new file mode 100644 index 00000000000..e98f1d94a72 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74950.min.stderr @@ -0,0 +1,47 @@ +error: using `Inner` as const generic parameters is forbidden + --> $DIR/issue-74950.rs:18:23 + | +LL | struct Outer<const I: Inner>; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: using `Inner` as const generic parameters is forbidden + --> $DIR/issue-74950.rs:18:23 + | +LL | struct Outer<const I: Inner>; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: using `Inner` as const generic parameters is forbidden + --> $DIR/issue-74950.rs:18:23 + | +LL | struct Outer<const I: Inner>; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: using `Inner` as const generic parameters is forbidden + --> $DIR/issue-74950.rs:18:23 + | +LL | struct Outer<const I: Inner>; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: using `Inner` as const generic parameters is forbidden + --> $DIR/issue-74950.rs:18:23 + | +LL | struct Outer<const I: Inner>; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/const-generics/issues/issue-74950.rs b/src/test/ui/const-generics/issues/issue-74950.rs new file mode 100644 index 00000000000..bfa0630a936 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74950.rs @@ -0,0 +1,25 @@ +// [full] build-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] + + +#[derive(PartialEq, Eq)] +struct Inner; + +// Note: We emit the error 5 times if we don't deduplicate: +// - struct definition +// - impl PartialEq +// - impl Eq +// - impl StructuralPartialEq +// - impl StructuralEq +#[derive(PartialEq, Eq)] +struct Outer<const I: Inner>; +//[min]~^ using `Inner` as const generic parameters is forbidden +//[min]~| using `Inner` as const generic parameters is forbidden +//[min]~| using `Inner` as const generic parameters is forbidden +//[min]~| using `Inner` as const generic parameters is forbidden +//[min]~| using `Inner` as const generic parameters is forbidden + +fn main() {} |
