summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_typeck/src/outlives/test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_typeck/src/outlives/test.rs')
-rw-r--r--compiler/rustc_typeck/src/outlives/test.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/outlives/test.rs b/compiler/rustc_typeck/src/outlives/test.rs
new file mode 100644
index 000000000..eb0e12034
--- /dev/null
+++ b/compiler/rustc_typeck/src/outlives/test.rs
@@ -0,0 +1,21 @@
+use rustc_errors::struct_span_err;
+use rustc_middle::ty::TyCtxt;
+use rustc_span::symbol::sym;
+
+pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
+ for id in tcx.hir().items() {
+ // For unit testing: check for a special "rustc_outlives"
+ // attribute and report an error with various results if found.
+ if tcx.has_attr(id.def_id.to_def_id(), sym::rustc_outlives) {
+ let inferred_outlives_of = tcx.inferred_outlives_of(id.def_id);
+ struct_span_err!(
+ tcx.sess,
+ tcx.def_span(id.def_id),
+ E0640,
+ "{:?}",
+ inferred_outlives_of
+ )
+ .emit();
+ }
+ }
+}