Skip to content

Commit dc4f948

Browse files
committed
Move StatementAsExpression to where it's actually used.
Also minimize some visibilities in the destination file.
1 parent 5986ff0 commit dc4f948

File tree

2 files changed

+13
-14
lines changed
  • compiler
    • rustc_middle/src/traits
    • rustc_trait_selection/src/error_reporting/infer

2 files changed

+13
-14
lines changed

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,6 @@ impl<'tcx> ObligationCauseCode<'tcx> {
514514
#[cfg(target_pointer_width = "64")]
515515
rustc_data_structures::static_assert_size!(ObligationCauseCode<'_>, 48);
516516

517-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
518-
pub enum StatementAsExpression {
519-
CorrectType,
520-
NeedsBoxing,
521-
}
522-
523517
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
524518
#[derive(TypeVisitable, TypeFoldable)]
525519
pub struct MatchExpressionArmCause<'tcx> {

compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_hir::def::Res;
1010
use rustc_hir::{MatchSource, Node};
1111
use rustc_middle::traits::{
1212
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
13-
StatementAsExpression,
1413
};
1514
use rustc_middle::ty::error::TypeError;
1615
use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -26,8 +25,14 @@ use crate::errors::{
2625
SuggestTuplePatternMany, SuggestTuplePatternOne, TypeErrorAdditionalDiags,
2726
};
2827

28+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
29+
enum StatementAsExpression {
30+
CorrectType,
31+
NeedsBoxing,
32+
}
33+
2934
#[derive(Clone, Copy)]
30-
pub enum SuggestAsRefKind {
35+
enum SuggestAsRefKind {
3136
Option,
3237
Result,
3338
}
@@ -382,7 +387,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
382387
}
383388
}
384389

385-
pub fn suggest_function_pointers_impl(
390+
pub(crate) fn suggest_function_pointers_impl(
386391
&self,
387392
span: Option<Span>,
388393
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
@@ -518,7 +523,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
518523
}
519524
}
520525

521-
pub fn should_suggest_as_ref_kind(
526+
fn should_suggest_as_ref_kind(
522527
&self,
523528
expected: Ty<'tcx>,
524529
found: Ty<'tcx>,
@@ -588,8 +593,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
588593
) -> Option<TypeErrorAdditionalDiags> {
589594
/// Find the if expression with given span
590595
struct IfVisitor {
591-
pub found_if: bool,
592-
pub err_span: Span,
596+
found_if: bool,
597+
err_span: Span,
593598
}
594599

595600
impl<'v> Visitor<'v> for IfVisitor {
@@ -736,7 +741,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
736741
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
737742
/// Be helpful when the user wrote `{... expr; }` and taking the `;` off
738743
/// is enough to fix the error.
739-
pub fn could_remove_semicolon(
744+
fn could_remove_semicolon(
740745
&self,
741746
blk: &'tcx hir::Block<'tcx>,
742747
expected_ty: Ty<'tcx>,
@@ -816,7 +821,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
816821

817822
/// Suggest returning a local binding with a compatible type if the block
818823
/// has no return expression.
819-
pub fn consider_returning_binding_diag(
824+
fn consider_returning_binding_diag(
820825
&self,
821826
blk: &'tcx hir::Block<'tcx>,
822827
expected_ty: Ty<'tcx>,

0 commit comments

Comments
 (0)