about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-09-09 01:35:20 +0200
committerGitHub <noreply@github.com>2020-09-09 01:35:20 +0200
commit1083833b3ed12319d345b3c63b6473ae27eba64c (patch)
tree65232997d60ce4fd62fc33de7dd7c4c5500d72d6 /compiler
parentd45faff0bf5fb2634757e6b7326c7a7a1de3ab1b (diff)
parentee55c1f1d2c427fecedd68e28a7dc4e6c68738b5 (diff)
downloadrust-1083833b3ed12319d345b3c63b6473ae27eba64c.tar.gz
rust-1083833b3ed12319d345b3c63b6473ae27eba64c.zip
Rollup merge of #76401 - JulianKnodt:i68366, r=lcnr
Add help note to unconstrained const parameter

Resolves #68366, since it is currently intended behaviour.
If demonstrating `T -> U` is injective, there should be an additional word that it is not **yet** supported.

r? @lcnr
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_typeck/src/impl_wf_check.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/compiler/rustc_typeck/src/impl_wf_check.rs b/compiler/rustc_typeck/src/impl_wf_check.rs
index 891e482b431..4901d6041d6 100644
--- a/compiler/rustc_typeck/src/impl_wf_check.rs
+++ b/compiler/rustc_typeck/src/impl_wf_check.rs
@@ -187,7 +187,7 @@ fn enforce_impl_params_are_constrained(
     }
 
     // (*) This is a horrible concession to reality. I think it'd be
-    // better to just ban unconstrianed lifetimes outright, but in
+    // better to just ban unconstrained lifetimes outright, but in
     // practice people do non-hygenic macros like:
     //
     // ```
@@ -207,7 +207,7 @@ fn enforce_impl_params_are_constrained(
 }
 
 fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: &str) {
-    struct_span_err!(
+    let mut err = struct_span_err!(
         tcx.sess,
         span,
         E0207,
@@ -215,9 +215,17 @@ fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: &str)
         impl trait, self type, or predicates",
         kind,
         name
-    )
-    .span_label(span, format!("unconstrained {} parameter", kind))
-    .emit();
+    );
+    err.span_label(span, format!("unconstrained {} parameter", kind));
+    if kind == "const" {
+        err.note(
+            "expressions using a const parameter must map each value to a distinct output value",
+        );
+        err.note(
+            "proving the result of expressions other than the parameter are unique is not supported",
+        );
+    }
+    err.emit();
 }
 
 /// Enforce that we do not have two items in an impl with the same name.