about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
diff options
context:
space:
mode:
authorr0cky <mu001999@outlook.com>2024-05-31 08:29:42 +0800
committerr0cky <mu001999@outlook.com>2024-05-31 08:29:42 +0800
commited5205fe66ccd49116e99e4244483caaa8cf933e (patch)
treea38d2c871e2fe707cc2ec1c1c1deecf4c0894c6f /compiler/rustc_infer/src
parent21e6de7eb64c09102de3f100420a09edc1a2a8d7 (diff)
downloadrust-ed5205fe66ccd49116e99e4244483caaa8cf933e.tar.gz
rust-ed5205fe66ccd49116e99e4244483caaa8cf933e.zip
Avoid unwrap diag.code directly
Diffstat (limited to 'compiler/rustc_infer/src')
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
index f4514c23508..19ef2d61fca 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
@@ -182,7 +182,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                             diag.span_label(p_span, format!("{expected}this type parameter"));
                         }
                         diag.help("type parameters must be constrained to match other types");
-                        if tcx.sess.teach(diag.code.unwrap()) {
+                        if diag.code.is_some_and(|code| tcx.sess.teach(code)) {
                             diag.help(
                                 "given a type parameter `T` and a method `foo`:
 ```
@@ -663,7 +663,7 @@ impl<T> Trait<T> for X {
                  https://doc.rust-lang.org/book/ch19-03-advanced-traits.html",
             );
         }
-        if tcx.sess.teach(diag.code.unwrap()) {
+        if diag.code.is_some_and(|code| tcx.sess.teach(code)) {
             diag.help(
                 "given an associated type `T` and a method `foo`:
 ```