Skip to content

Commit 46ea798

Browse files
committed
Add warn(unreachable_pub) to rustc_next_trait_solver.
1 parent e306214 commit 46ea798

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

compiler/rustc_next_trait_solver/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
//! but were uplifted in the process of making the new trait solver generic.
55
//! So if you got to this crate from the old solver, it's totally normal.
66
7+
// tidy-alphabetical-start
8+
#![warn(unreachable_pub)]
9+
// tidy-alphabetical-end
10+
711
pub mod canonicalizer;
812
pub mod coherence;
913
pub mod delegate;

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
9393
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
9494
// FIXME: This can be made crate-private once `EvalCtxt` also lives in this crate.
95-
pub struct NestedGoals<I: Interner> {
95+
struct NestedGoals<I: Interner> {
9696
/// These normalizes-to goals are treated specially during the evaluation
9797
/// loop. In each iteration we take the RHS of the projection, replace it with
9898
/// a fresh inference variable, and only after evaluating that goal do we
@@ -109,11 +109,11 @@ pub struct NestedGoals<I: Interner> {
109109
}
110110

111111
impl<I: Interner> NestedGoals<I> {
112-
pub fn new() -> Self {
112+
fn new() -> Self {
113113
Self { normalizes_to_goals: Vec::new(), goals: Vec::new() }
114114
}
115115

116-
pub fn is_empty(&self) -> bool {
116+
fn is_empty(&self) -> bool {
117117
self.normalizes_to_goals.is_empty() && self.goals.is_empty()
118118
}
119119
}

compiler/rustc_next_trait_solver/src/solve/inspect/build.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
222222
self.state.as_deref_mut()
223223
}
224224

225-
pub fn take_and_enter_probe(&mut self) -> ProofTreeBuilder<D> {
225+
pub(crate) fn take_and_enter_probe(&mut self) -> ProofTreeBuilder<D> {
226226
let mut nested = ProofTreeBuilder { state: self.state.take(), _infcx: PhantomData };
227227
nested.enter_probe();
228228
nested
229229
}
230230

231-
pub fn finalize(self) -> Option<inspect::GoalEvaluation<I>> {
231+
pub(crate) fn finalize(self) -> Option<inspect::GoalEvaluation<I>> {
232232
match *self.state? {
233233
DebugSolver::GoalEvaluation(wip_goal_evaluation) => {
234234
Some(wip_goal_evaluation.finalize())
@@ -237,22 +237,22 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
237237
}
238238
}
239239

240-
pub fn new_maybe_root(generate_proof_tree: GenerateProofTree) -> ProofTreeBuilder<D> {
240+
pub(crate) fn new_maybe_root(generate_proof_tree: GenerateProofTree) -> ProofTreeBuilder<D> {
241241
match generate_proof_tree {
242242
GenerateProofTree::No => ProofTreeBuilder::new_noop(),
243243
GenerateProofTree::Yes => ProofTreeBuilder::new_root(),
244244
}
245245
}
246246

247-
pub fn new_root() -> ProofTreeBuilder<D> {
247+
fn new_root() -> ProofTreeBuilder<D> {
248248
ProofTreeBuilder::new(DebugSolver::Root)
249249
}
250250

251-
pub fn new_noop() -> ProofTreeBuilder<D> {
251+
fn new_noop() -> ProofTreeBuilder<D> {
252252
ProofTreeBuilder { state: None, _infcx: PhantomData }
253253
}
254254

255-
pub fn is_noop(&self) -> bool {
255+
pub(crate) fn is_noop(&self) -> bool {
256256
self.state.is_none()
257257
}
258258

@@ -272,7 +272,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
272272
})
273273
}
274274

275-
pub fn new_canonical_goal_evaluation(
275+
pub(crate) fn new_canonical_goal_evaluation(
276276
&mut self,
277277
goal: CanonicalInput<I>,
278278
) -> ProofTreeBuilder<D> {
@@ -284,7 +284,10 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
284284
})
285285
}
286286

287-
pub fn canonical_goal_evaluation(&mut self, canonical_goal_evaluation: ProofTreeBuilder<D>) {
287+
pub(crate) fn canonical_goal_evaluation(
288+
&mut self,
289+
canonical_goal_evaluation: ProofTreeBuilder<D>,
290+
) {
288291
if let Some(this) = self.as_mut() {
289292
match (this, *canonical_goal_evaluation.state.unwrap()) {
290293
(
@@ -299,7 +302,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
299302
}
300303
}
301304

302-
pub fn canonical_goal_evaluation_overflow(&mut self) {
305+
pub(crate) fn canonical_goal_evaluation_overflow(&mut self) {
303306
if let Some(this) = self.as_mut() {
304307
match this {
305308
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
@@ -310,7 +313,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
310313
}
311314
}
312315

313-
pub fn goal_evaluation(&mut self, goal_evaluation: ProofTreeBuilder<D>) {
316+
pub(crate) fn goal_evaluation(&mut self, goal_evaluation: ProofTreeBuilder<D>) {
314317
if let Some(this) = self.as_mut() {
315318
match this {
316319
DebugSolver::Root => *this = *goal_evaluation.state.unwrap(),
@@ -322,7 +325,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
322325
}
323326
}
324327

325-
pub fn new_goal_evaluation_step(
328+
pub(crate) fn new_goal_evaluation_step(
326329
&mut self,
327330
var_values: ty::CanonicalVarValues<I>,
328331
instantiated_goal: QueryInput<I, I::Predicate>,
@@ -340,7 +343,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
340343
})
341344
}
342345

343-
pub fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<D>) {
346+
pub(crate) fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<D>) {
344347
if let Some(this) = self.as_mut() {
345348
match (this, *goal_evaluation_step.state.unwrap()) {
346349
(
@@ -354,7 +357,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
354357
}
355358
}
356359

357-
pub fn add_var_value<T: Into<I::GenericArg>>(&mut self, arg: T) {
360+
pub(crate) fn add_var_value<T: Into<I::GenericArg>>(&mut self, arg: T) {
358361
match self.as_mut() {
359362
None => {}
360363
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@@ -364,7 +367,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
364367
}
365368
}
366369

367-
pub fn enter_probe(&mut self) {
370+
fn enter_probe(&mut self) {
368371
match self.as_mut() {
369372
None => {}
370373
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@@ -381,7 +384,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
381384
}
382385
}
383386

384-
pub fn probe_kind(&mut self, probe_kind: inspect::ProbeKind<I>) {
387+
pub(crate) fn probe_kind(&mut self, probe_kind: inspect::ProbeKind<I>) {
385388
match self.as_mut() {
386389
None => {}
387390
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@@ -392,7 +395,11 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
392395
}
393396
}
394397

395-
pub fn probe_final_state(&mut self, delegate: &D, max_input_universe: ty::UniverseIndex) {
398+
pub(crate) fn probe_final_state(
399+
&mut self,
400+
delegate: &D,
401+
max_input_universe: ty::UniverseIndex,
402+
) {
396403
match self.as_mut() {
397404
None => {}
398405
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@@ -409,7 +416,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
409416
}
410417
}
411418

412-
pub fn add_normalizes_to_goal(
419+
pub(crate) fn add_normalizes_to_goal(
413420
&mut self,
414421
delegate: &D,
415422
max_input_universe: ty::UniverseIndex,
@@ -423,7 +430,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
423430
);
424431
}
425432

426-
pub fn add_goal(
433+
pub(crate) fn add_goal(
427434
&mut self,
428435
delegate: &D,
429436
max_input_universe: ty::UniverseIndex,
@@ -469,7 +476,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
469476
}
470477
}
471478

472-
pub fn make_canonical_response(&mut self, shallow_certainty: Certainty) {
479+
pub(crate) fn make_canonical_response(&mut self, shallow_certainty: Certainty) {
473480
match self.as_mut() {
474481
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
475482
state
@@ -482,7 +489,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
482489
}
483490
}
484491

485-
pub fn finish_probe(mut self) -> ProofTreeBuilder<D> {
492+
pub(crate) fn finish_probe(mut self) -> ProofTreeBuilder<D> {
486493
match self.as_mut() {
487494
None => {}
488495
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@@ -497,7 +504,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
497504
self
498505
}
499506

500-
pub fn query_result(&mut self, result: QueryResult<I>) {
507+
pub(crate) fn query_result(&mut self, result: QueryResult<I>) {
501508
if let Some(this) = self.as_mut() {
502509
match this {
503510
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {

compiler/rustc_next_trait_solver/src/solve/normalizes_to/opaque_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ where
9797
/// Checks whether each generic argument is simply a unique generic placeholder.
9898
///
9999
/// FIXME: Interner argument is needed to constrain the `I` parameter.
100-
pub fn uses_unique_placeholders_ignoring_regions<I: Interner>(
100+
fn uses_unique_placeholders_ignoring_regions<I: Interner>(
101101
_cx: I,
102102
args: I::GenericArgs,
103103
) -> Result<(), NotUniqueParam<I>> {
@@ -130,7 +130,7 @@ pub fn uses_unique_placeholders_ignoring_regions<I: Interner>(
130130
}
131131

132132
// FIXME: This should check for dupes and non-params first, then infer vars.
133-
pub enum NotUniqueParam<I: Interner> {
133+
enum NotUniqueParam<I: Interner> {
134134
DuplicateParam(I::GenericArg),
135135
NotParam(I::GenericArg),
136136
}

0 commit comments

Comments
 (0)