about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/errors
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-09-11 13:32:53 -0400
committerMichael Goulet <michael@errs.io>2024-09-11 13:45:23 -0400
commit954419aab01264707f116899e77be682b02764ea (patch)
tree9c66d40f49925803e11e7aebe913bf39297a9751 /compiler/rustc_hir_analysis/src/errors
parent5a2dd7d4f3210629e65879aeecbe643ba3b86bb4 (diff)
downloadrust-954419aab01264707f116899e77be682b02764ea.tar.gz
rust-954419aab01264707f116899e77be682b02764ea.zip
Simplify some nested if statements
Diffstat (limited to 'compiler/rustc_hir_analysis/src/errors')
-rw-r--r--compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs
index da89f5769d1..97402dd1109 100644
--- a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs
+++ b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs
@@ -827,20 +827,18 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
 
             if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args
                 == num_trait_generics_except_self
+                && let Some(span) = self.gen_args.span_ext()
+                && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
             {
-                if let Some(span) = self.gen_args.span_ext()
-                    && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
-                {
-                    let sugg = vec![
-                        (
-                            self.path_segment.ident.span,
-                            format!("{}::{}", snippet, self.path_segment.ident),
-                        ),
-                        (span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()),
-                    ];
+                let sugg = vec![
+                    (
+                        self.path_segment.ident.span,
+                        format!("{}::{}", snippet, self.path_segment.ident),
+                    ),
+                    (span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()),
+                ];
 
-                    err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
-                }
+                err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
             }
         }
     }