]> git.lizzy.rs Git - rust.git/commitdiff
Turn `IllegalSizedBound` into struct variant
authorEsteban Küber <esteban@kuber.com.ar>
Thu, 5 Jan 2023 07:12:04 +0000 (07:12 +0000)
committerEsteban Küber <esteban@kuber.com.ar>
Fri, 6 Jan 2023 21:03:26 +0000 (21:03 +0000)
compiler/rustc_hir_typeck/src/method/mod.rs
compiler/rustc_hir_typeck/src/method/suggest.rs

index f3c43e3f4973b0ab9bf3ee3b41a7797d51af9fec..d276bcdb81e3e68e726397420be8d55b0b77d5c5 100644 (file)
@@ -57,7 +57,12 @@ pub enum MethodError<'tcx> {
     PrivateMatch(DefKind, DefId, Vec<DefId>),
 
     // Found a `Self: Sized` bound where `Self` is a trait object.
-    IllegalSizedBound(Vec<DefId>, bool, Span, &'tcx hir::Expr<'tcx>),
+    IllegalSizedBound {
+        candidates: Vec<DefId>,
+        needs_mut: bool,
+        bound_span: Span,
+        self_expr: &'tcx hir::Expr<'tcx>,
+    },
 
     // Found a match, but the return type is wrong
     BadReturnType,
@@ -112,7 +117,7 @@ pub fn method_exists(
             Err(NoMatch(..)) => false,
             Err(Ambiguity(..)) => true,
             Err(PrivateMatch(..)) => allow_private,
-            Err(IllegalSizedBound(..)) => true,
+            Err(IllegalSizedBound { .. }) => true,
             Err(BadReturnType) => bug!("no return type expectations but got BadReturnType"),
         }
     }
@@ -236,7 +241,7 @@ pub fn lookup_method(
                     _ => Vec::new(),
                 };
 
-            return Err(IllegalSizedBound(candidates, needs_mut, span, self_expr));
+            return Err(IllegalSizedBound { candidates, needs_mut, bound_span: span, self_expr });
         }
 
         Ok(result.callee)
index fedffe3d81ea4d7ed26c311725ee9d7732ae2678..bcdb557be2176639a613cc36134e40cc642803ef 100644 (file)
@@ -176,7 +176,7 @@ pub fn report_method_error(
                 err.emit();
             }
 
-            MethodError::IllegalSizedBound(candidates, needs_mut, bound_span, self_expr) => {
+            MethodError::IllegalSizedBound { candidates, needs_mut, bound_span, self_expr } => {
                 let msg = if needs_mut {
                     with_forced_trimmed_paths!(format!(
                         "the `{item_name}` method cannot be invoked on `{rcvr_ty}`"