about summary refs log tree commit diff
path: root/src/tools/clippy/clippy_lints
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-18 19:41:21 +0000
committerbors <bors@rust-lang.org>2023-09-18 19:41:21 +0000
commitcebb9cfd4f0052fbb5e98f9b6f3a61dae8fd96a7 (patch)
tree8cab476d937833d4744831c22fd1d5493e857455 /src/tools/clippy/clippy_lints
parentb1575cb72ef40459666f802af8636faf8428e3eb (diff)
parent9ac8b363e3227fdc08634ce445b7787aa0fa6bba (diff)
downloadrust-cebb9cfd4f0052fbb5e98f9b6f3a61dae8fd96a7.tar.gz
rust-cebb9cfd4f0052fbb5e98f9b6f3a61dae8fd96a7.zip
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function

This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants.

Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized.

I didn't expect this to change diagnostics, but it's just cycle errors that change.

r? `@oli-obk`
Diffstat (limited to 'src/tools/clippy/clippy_lints')
-rw-r--r--src/tools/clippy/clippy_lints/src/non_copy_const.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/clippy/clippy_lints/src/non_copy_const.rs b/src/tools/clippy/clippy_lints/src/non_copy_const.rs
index 243192385c2..88466333787 100644
--- a/src/tools/clippy/clippy_lints/src/non_copy_const.rs
+++ b/src/tools/clippy/clippy_lints/src/non_copy_const.rs
@@ -204,7 +204,7 @@ fn is_value_unfrozen_raw<'tcx>(
             // similar to 2., but with the a frozen variant) (e.g. borrowing
             // `borrow_interior_mutable_const::enums::AssocConsts::TO_BE_FROZEN_VARIANT`).
             // I chose this way because unfrozen enums as assoc consts are rare (or, hopefully, none).
-            err == ErrorHandled::TooGeneric
+            matches!(err, ErrorHandled::TooGeneric(..))
         },
         |val| val.map_or(true, |val| inner(cx, val, ty)),
     )
@@ -244,8 +244,8 @@ pub fn const_eval_resolve<'tcx>(
             };
             tcx.const_eval_global_id_for_typeck(param_env, cid, span)
         },
-        Ok(None) => Err(ErrorHandled::TooGeneric),
-        Err(err) => Err(ErrorHandled::Reported(err.into())),
+        Ok(None) => Err(ErrorHandled::TooGeneric(span.unwrap_or(rustc_span::DUMMY_SP))),
+        Err(err) => Err(ErrorHandled::Reported(err.into(), span.unwrap_or(rustc_span::DUMMY_SP))),
     }
 }