}
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) {
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;
fcx.select_all_obligations_or_error();
}
+#[derive(Clone, Copy)]
pub struct CheckTypeWellFormedVisitor<'tcx> {
tcx: TyCtxt<'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>;
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);
}
}
|
= 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`.
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<'_, ""> {}
--- /dev/null
+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
+
--- /dev/null
+// [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() {}