]> git.lizzy.rs Git - rust.git/commitdiff
run wfcheck in parralel again, add test for 74950
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Thu, 13 Aug 2020 20:26:55 +0000 (22:26 +0200)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Tue, 18 Aug 2020 20:14:40 +0000 (22:14 +0200)
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/wfcheck.rs
src/test/ui/const-generics/issues/issue-56445.min.stderr
src/test/ui/const-generics/issues/issue-56445.rs
src/test/ui/const-generics/issues/issue-74950.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/issues/issue-74950.rs [new file with mode: 0644]

index dc4f181ec939b52708f505e2494ba9edae5bb786..824e81a974ca61f00b8dd7c6bf1d08a4fad52448 100644 (file)
@@ -729,8 +729,8 @@ fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem<'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) {
index 740f30f5224d0328dddc492c1e0b520aa4d06969..cbf302ad71005c5e4b7ab2f2a1cf39ee9f1b6dd4 100644 (file)
@@ -8,6 +8,7 @@
 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 @@ pub fn new(tcx: TyCtxt<'tcx>) -> 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 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'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);
     }
 }
 
index ca35ee5b2905d216e26ad1ea6ff406e29c77487c..bcb27d8d1e19740a4f1a3c975c01393077b354a2 100644 (file)
@@ -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`.
index 174eb16abfc5f44755243dce1a80cc719f0ee140..0bcde348b05d5d1ef52d007fe1941481162ae5a3 100644 (file)
@@ -8,6 +8,5 @@
 
 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 (file)
index 0000000..e98f1d9
--- /dev/null
@@ -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 (file)
index 0000000..bfa0630
--- /dev/null
@@ -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() {}