diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-02-05 15:39:15 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-02-20 13:48:37 +1100 |
| commit | dc4f948299b58e1d34c0267c17eea09a1119e8c7 (patch) | |
| tree | 4dcb5590ca01de4085fc1dbf26227c3a934882a5 | |
| parent | 5986ff05d8480da038dd161b3a6aa79ff364a851 (diff) | |
| download | rust-dc4f948299b58e1d34c0267c17eea09a1119e8c7.tar.gz rust-dc4f948299b58e1d34c0267c17eea09a1119e8c7.zip | |
Move `StatementAsExpression` to where it's actually used.
Also minimize some visibilities in the destination file.
| -rw-r--r-- | compiler/rustc_middle/src/traits/mod.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs | 21 |
2 files changed, 13 insertions, 14 deletions
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index f039da772fd..23c06f71232 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -514,12 +514,6 @@ impl<'tcx> ObligationCauseCode<'tcx> { #[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(ObligationCauseCode<'_>, 48); -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub enum StatementAsExpression { - CorrectType, - NeedsBoxing, -} - #[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] #[derive(TypeVisitable, TypeFoldable)] pub struct MatchExpressionArmCause<'tcx> { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs index 628888c8d45..a87a449daf1 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs @@ -10,7 +10,6 @@ use rustc_hir::def::Res; use rustc_hir::{MatchSource, Node}; use rustc_middle::traits::{ IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode, - StatementAsExpression, }; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::print::with_no_trimmed_paths; @@ -26,8 +25,14 @@ use crate::errors::{ SuggestTuplePatternMany, SuggestTuplePatternOne, TypeErrorAdditionalDiags, }; +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +enum StatementAsExpression { + CorrectType, + NeedsBoxing, +} + #[derive(Clone, Copy)] -pub enum SuggestAsRefKind { +enum SuggestAsRefKind { Option, Result, } @@ -382,7 +387,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } - pub fn suggest_function_pointers_impl( + pub(crate) fn suggest_function_pointers_impl( &self, span: Option<Span>, exp_found: &ty::error::ExpectedFound<Ty<'tcx>>, @@ -518,7 +523,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } - pub fn should_suggest_as_ref_kind( + fn should_suggest_as_ref_kind( &self, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -588,8 +593,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ) -> Option<TypeErrorAdditionalDiags> { /// Find the if expression with given span struct IfVisitor { - pub found_if: bool, - pub err_span: Span, + found_if: bool, + err_span: Span, } impl<'v> Visitor<'v> for IfVisitor { @@ -736,7 +741,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// Be helpful when the user wrote `{... expr; }` and taking the `;` off /// is enough to fix the error. - pub fn could_remove_semicolon( + fn could_remove_semicolon( &self, blk: &'tcx hir::Block<'tcx>, expected_ty: Ty<'tcx>, @@ -816,7 +821,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// Suggest returning a local binding with a compatible type if the block /// has no return expression. - pub fn consider_returning_binding_diag( + fn consider_returning_binding_diag( &self, blk: &'tcx hir::Block<'tcx>, expected_ty: Ty<'tcx>, |
