Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More unreachable_pub #129648

Merged
merged 20 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e81fad2
Add `warn(unreachable_pub)` to `rustc_driver_impl`.
nnethercote Aug 27, 2024
d607cfb
Add `warn(unreachable_pub)` to `rustc_error_codes`.
nnethercote Aug 27, 2024
2b56212
Add `warn(unreachable_pub)` to `rustc_error_messages`.
nnethercote Aug 27, 2024
5fd503a
Add `warn(unreachable_pub)` to `rustc_errors`.
nnethercote Aug 27, 2024
df5fbf0
Add `warn(unreachable_pub)` to `rustc_expand`.
nnethercote Aug 27, 2024
0d8d05c
Add `warn(unreachable_pub)` to `rustc_feature`.
nnethercote Aug 27, 2024
a510813
Add `warn(unreachable_pub)` to `rustc_fluent_macro`.
nnethercote Aug 27, 2024
fa18140
Add `warn(unreachable_pub)` to `rustc_graphviz`.
nnethercote Aug 27, 2024
bffa224
Add `warn(unreachable_pub)` to `rustc_hir`.
nnethercote Aug 27, 2024
5acf4e7
Add `warn(unreachable_pub)` to `rustc_hir_analysis`.
nnethercote Aug 27, 2024
3aae994
Add `warn(unreachable_pub)` to `rustc_hir_pretty`.
nnethercote Aug 27, 2024
7fc0444
Add `warn(unreachable_pub)` to `rustc_hir_typeck`.
nnethercote Aug 27, 2024
37becf7
Add `warn(unreachable_pub)` to `rustc_incremental`.
nnethercote Aug 27, 2024
46fe09f
Add `warn(unreachable_pub)` to `rustc_index`.
nnethercote Aug 27, 2024
6887927
Add `warn(unreachable_pub)` to `rustc_infer`.
nnethercote Aug 27, 2024
a941a4b
Add `warn(unreachable_pub)` to `rustc_interface`.
nnethercote Aug 27, 2024
6c84c55
Add `warn(unreachable_pub)` to `rustc_lexer`.
nnethercote Aug 27, 2024
f102841
Add `warn(unreachable_pub)` to `rustc_lint`.
nnethercote Aug 27, 2024
e7f1922
Add `warn(unreachable_pub)` to `rustc_lint_defs`.
nnethercote Aug 27, 2024
22cdd63
Add `warn(unreachable_pub)` to `rustc_llvm`.
nnethercote Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add warn(unreachable_pub) to rustc_hir_typeck.
  • Loading branch information
nnethercote committed Aug 27, 2024
commit 7fc04443404914bb7c432c2269d94fd48d569244
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

pub fn maybe_get_coercion_reason(
pub(crate) fn maybe_get_coercion_reason(
&self,
hir_id: hir::HirId,
sp: Span,
Expand Down Expand Up @@ -584,7 +584,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// (e.g. we're in the tail of a function body)
//
// Returns the `LocalDefId` of the RPIT, which is always identity-substituted.
pub fn return_position_impl_trait_from_match_expectation(
pub(crate) fn return_position_impl_trait_from_match_expectation(
&self,
expectation: Expectation<'tcx>,
) -> Option<LocalDefId> {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_typeck/src/autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use super::method::MethodCallee;
use super::{FnCtxt, PlaceOp};

impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'tcx> {
pub(crate) fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'tcx> {
Autoderef::new(self, self.param_env, self.body_id, span, base_ty)
}

pub fn try_overloaded_deref(
pub(crate) fn try_overloaded_deref(
&self,
span: Span,
base_ty: Ty<'tcx>,
Expand All @@ -26,11 +26,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

/// Returns the adjustment steps.
pub fn adjust_steps(&self, autoderef: &Autoderef<'a, 'tcx>) -> Vec<Adjustment<'tcx>> {
pub(crate) fn adjust_steps(&self, autoderef: &Autoderef<'a, 'tcx>) -> Vec<Adjustment<'tcx>> {
self.register_infer_ok_obligations(self.adjust_steps_as_infer_ok(autoderef))
}

pub fn adjust_steps_as_infer_ok(
pub(crate) fn adjust_steps_as_infer_ok(
&self,
autoderef: &Autoderef<'a, 'tcx>,
) -> InferOk<'tcx, Vec<Adjustment<'tcx>>> {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::errors;
/// Checks that it is legal to call methods of the trait corresponding
/// to `trait_id` (this only cares about the trait, not the specific
/// method that is called).
pub fn check_legal_trait_for_method_call(
pub(crate) fn check_legal_trait_for_method_call(
tcx: TyCtxt<'_>,
span: Span,
receiver: Option<Span>,
Expand Down Expand Up @@ -62,7 +62,7 @@ enum CallStep<'tcx> {
}

impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn check_call(
pub(crate) fn check_call(
&self,
call_expr: &'tcx hir::Expr<'tcx>,
callee_expr: &'tcx hir::Expr<'tcx>,
Expand Down Expand Up @@ -940,7 +940,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

#[derive(Debug)]
pub struct DeferredCallResolution<'tcx> {
pub(crate) struct DeferredCallResolution<'tcx> {
call_expr: &'tcx hir::Expr<'tcx>,
callee_expr: &'tcx hir::Expr<'tcx>,
closure_ty: Ty<'tcx>,
Expand All @@ -949,7 +949,7 @@ pub struct DeferredCallResolution<'tcx> {
}

impl<'a, 'tcx> DeferredCallResolution<'tcx> {
pub fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) {
pub(crate) fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) {
debug!("DeferredCallResolution::resolve() {:?}", self);

// we should not be invoked until the closure kind has been
Expand Down
28 changes: 14 additions & 14 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// adjusted type of the expression, if successful.
/// Adjustments are only recorded if the coercion succeeded.
/// The expressions *must not* have any preexisting adjustments.
pub fn coerce(
pub(crate) fn coerce(
&self,
expr: &hir::Expr<'_>,
expr_ty: Ty<'tcx>,
Expand Down Expand Up @@ -1011,7 +1011,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
///
/// Returns false if the coercion creates any obligations that result in
/// errors.
pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
pub(crate) fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
// FIXME(-Znext-solver): We need to structurally resolve both types here.
let source = self.resolve_vars_with_obligations(expr_ty);
debug!("coercion::can_with_predicates({:?} -> {:?})", source, target);
Expand All @@ -1032,7 +1032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Given a type and a target type, this function will calculate and return
/// how many dereference steps needed to achieve `expr_ty <: target`. If
/// it's not possible, return `None`.
pub fn deref_steps(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> Option<usize> {
pub(crate) fn deref_steps(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> Option<usize> {
let cause = self.cause(DUMMY_SP, ObligationCauseCode::ExprAssignable);
// We don't ever need two-phase here since we throw out the result of the coercion
let coerce = Coerce::new(self, cause, AllowTwoPhase::No);
Expand All @@ -1047,7 +1047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// This function is for diagnostics only, since it does not register
/// trait or region sub-obligations. (presumably we could, but it's not
/// particularly important for diagnostics...)
pub fn deref_once_mutably_for_diagnostic(&self, expr_ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
pub(crate) fn deref_once_mutably_for_diagnostic(&self, expr_ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
self.autoderef(DUMMY_SP, expr_ty).nth(1).and_then(|(deref_ty, _)| {
self.infcx
.type_implements_trait(
Expand Down Expand Up @@ -1341,7 +1341,7 @@ pub fn can_coerce<'tcx>(
/// }
/// let final_ty = coerce.complete(fcx);
/// ```
pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
pub(crate) struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
expected_ty: Ty<'tcx>,
final_ty: Option<Ty<'tcx>>,
expressions: Expressions<'tcx, 'exprs, E>,
Expand All @@ -1350,7 +1350,7 @@ pub struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {

/// The type of a `CoerceMany` that is storing up the expressions into
/// a buffer. We use this in `check/mod.rs` for things like `break`.
pub type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, &'tcx hir::Expr<'tcx>>;
pub(crate) type DynamicCoerceMany<'tcx> = CoerceMany<'tcx, 'tcx, &'tcx hir::Expr<'tcx>>;

enum Expressions<'tcx, 'exprs, E: AsCoercionSite> {
Dynamic(Vec<&'tcx hir::Expr<'tcx>>),
Expand All @@ -1361,7 +1361,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// The usual case; collect the set of expressions dynamically.
/// If the full set of coercion sites is known before hand,
/// consider `with_coercion_sites()` instead to avoid allocation.
pub fn new(expected_ty: Ty<'tcx>) -> Self {
pub(crate) fn new(expected_ty: Ty<'tcx>) -> Self {
Self::make(expected_ty, Expressions::Dynamic(vec![]))
}

Expand All @@ -1370,7 +1370,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// expected to pass each element in the slice to `coerce(...)` in
/// order. This is used with arrays in particular to avoid
/// needlessly cloning the slice.
pub fn with_coercion_sites(expected_ty: Ty<'tcx>, coercion_sites: &'exprs [E]) -> Self {
pub(crate) fn with_coercion_sites(expected_ty: Ty<'tcx>, coercion_sites: &'exprs [E]) -> Self {
Self::make(expected_ty, Expressions::UpFront(coercion_sites))
}

Expand All @@ -1386,15 +1386,15 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// Typically, this is used as the expected type when
/// type-checking each of the alternative expressions whose types
/// we are trying to merge.
pub fn expected_ty(&self) -> Ty<'tcx> {
pub(crate) fn expected_ty(&self) -> Ty<'tcx> {
self.expected_ty
}

/// Returns the current "merged type", representing our best-guess
/// at the LUB of the expressions we've seen so far (if any). This
/// isn't *final* until you call `self.complete()`, which will return
/// the merged type.
pub fn merged_ty(&self) -> Ty<'tcx> {
pub(crate) fn merged_ty(&self) -> Ty<'tcx> {
self.final_ty.unwrap_or(self.expected_ty)
}

Expand All @@ -1403,7 +1403,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// could coerce from. This will record `expression`, and later
/// calls to `coerce` may come back and add adjustments and things
/// if necessary.
pub fn coerce<'a>(
pub(crate) fn coerce<'a>(
&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
Expand All @@ -1425,7 +1425,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
/// The `augment_error` gives you a chance to extend the error
/// message, in case any results (e.g., we use this to suggest
/// removing a `;`).
pub fn coerce_forced_unit<'a>(
pub(crate) fn coerce_forced_unit<'a>(
&mut self,
fcx: &FnCtxt<'a, 'tcx>,
cause: &ObligationCause<'tcx>,
Expand Down Expand Up @@ -1920,7 +1920,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
}
}

pub fn complete<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> {
pub(crate) fn complete<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> {
if let Some(final_ty) = self.final_ty {
final_ty
} else {
Expand All @@ -1934,7 +1934,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {

/// Something that can be converted into an expression to which we can
/// apply a coercion.
pub trait AsCoercionSite {
pub(crate) trait AsCoercionSite {
fn as_coercion_site(&self) -> &hir::Expr<'_>;
}

Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::method::probe;
use crate::FnCtxt;

impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub fn emit_type_mismatch_suggestions(
pub(crate) fn emit_type_mismatch_suggestions(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'tcx>,
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

pub fn emit_coerce_suggestions(
pub(crate) fn emit_coerce_suggestions(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'tcx>,
Expand Down Expand Up @@ -165,13 +165,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

/// Requires that the two types unify, and prints an error message if
/// they don't.
pub fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
pub(crate) fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
if let Err(e) = self.demand_suptype_diag(sp, expected, actual) {
e.emit();
}
}

pub fn demand_suptype_diag(
pub(crate) fn demand_suptype_diag(
&'a self,
sp: Span,
expected: Ty<'tcx>,
Expand All @@ -193,13 +193,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
}

pub fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
pub(crate) fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
if let Err(err) = self.demand_eqtype_diag(sp, expected, actual) {
err.emit();
}
}

pub fn demand_eqtype_diag(
pub(crate) fn demand_eqtype_diag(
&'a self,
sp: Span,
expected: Ty<'tcx>,
Expand All @@ -208,7 +208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.demand_eqtype_with_origin(&self.misc(sp), expected, actual)
}

pub fn demand_eqtype_with_origin(
pub(crate) fn demand_eqtype_with_origin(
&'a self,
cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>,
Expand All @@ -220,7 +220,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
}

pub fn demand_coerce(
pub(crate) fn demand_coerce(
&self,
expr: &'tcx hir::Expr<'tcx>,
checked_ty: Ty<'tcx>,
Expand Down Expand Up @@ -279,7 +279,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

/// Notes the point at which a variable is constrained to some type incompatible
/// with some expectation given by `source`.
pub fn note_source_of_type_mismatch_constraint(
pub(crate) fn note_source_of_type_mismatch_constraint(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'_>,
Expand Down Expand Up @@ -558,7 +558,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// When encountering a type error on the value of a `break`, try to point at the reason for the
// expected type.
pub fn annotate_loop_expected_due_to_inference(
pub(crate) fn annotate_loop_expected_due_to_inference(
&self,
err: &mut Diag<'_>,
expr: &hir::Expr<'_>,
Expand Down Expand Up @@ -964,7 +964,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
}

pub fn get_conversion_methods_for_diagnostic(
pub(crate) fn get_conversion_methods_for_diagnostic(
&self,
span: Span,
expected: Ty<'tcx>,
Expand Down Expand Up @@ -1186,7 +1186,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

pub enum TypeMismatchSource<'tcx> {
pub(crate) enum TypeMismatchSource<'tcx> {
/// Expected the binding to have the given type, but it was found to have
/// a different type. Find out when that type first became incompatible.
Ty(Ty<'tcx>),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/diverges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_span::{Span, DUMMY_SP};
/// as diverging), with some manual adjustments for control-flow
/// primitives (approximating a CFG).
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Diverges {
pub(crate) enum Diverges {
/// Potentially unknown, some cases converge,
/// others require a CFG to determine them.
Maybe,
Expand Down
Loading