Skip to content

Commit 6e93cee

Browse files
Fix some unused fields in AST visitor
1 parent ccd6824 commit 6e93cee

File tree

7 files changed

+12
-3
lines changed

7 files changed

+12
-3
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ mod sealed {
3737

3838
/// This is for compatibility with the regular `Visitor`.
3939
pub trait MutVisitorResult {
40+
#[cfg_attr(not(bootstrap), must_use)]
4041
type Result: VisitorResult;
4142
}
4243

compiler/rustc_ast/src/visit.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub enum LifetimeCtxt {
130130
pub trait Visitor<'ast>: Sized {
131131
/// The result type of the `visit_*` methods. Can be either `()`,
132132
/// or `ControlFlow<T>`.
133+
#[cfg_attr(not(bootstrap), must_use)]
133134
type Result: VisitorResult = ();
134135

135136
fn visit_ident(&mut self, _ident: &'ast Ident) -> Self::Result {
@@ -884,7 +885,7 @@ macro_rules! common_visitor_and_walkers {
884885
TyKind::BareFn(function_declaration) => {
885886
let BareFnTy { safety, ext: _, generic_params, decl, decl_span } =
886887
&$($mut)? **function_declaration;
887-
visit_safety(vis, safety);
888+
try_visit!(visit_safety(vis, safety));
888889
try_visit!(visit_generic_params(vis, generic_params));
889890
try_visit!(vis.visit_fn_decl(decl));
890891
try_visit!(visit_span(vis, decl_span));
@@ -1235,7 +1236,7 @@ macro_rules! common_visitor_and_walkers {
12351236
bounds,
12361237
bound_generic_params,
12371238
}) => {
1238-
visit_generic_params(vis, bound_generic_params);
1239+
try_visit!(visit_generic_params(vis, bound_generic_params));
12391240
try_visit!(vis.visit_ty(bounded_ty));
12401241
walk_list!(vis, visit_param_bound, bounds, BoundKind::Bound);
12411242
}
@@ -1420,7 +1421,7 @@ macro_rules! common_visitor_and_walkers {
14201421
let StructExpr { qself, path, fields, rest } = &$($mut)?**se;
14211422
try_visit!(vis.visit_qself(qself));
14221423
try_visit!(vis.visit_path(path));
1423-
visit_expr_fields(vis, fields);
1424+
try_visit!(visit_expr_fields(vis, fields));
14241425
match rest {
14251426
StructRest::Base(expr) => try_visit!(vis.visit_expr(expr)),
14261427
StructRest::Rest(_span) => {}

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pub trait Visitor<'v>: Sized {
224224

225225
/// The result type of the `visit_*` methods. Can be either `()`,
226226
/// or `ControlFlow<T>`.
227+
#[cfg_attr(not(bootstrap), must_use)]
227228
type Result: VisitorResult = ();
228229

229230
/// If `type NestedFilter` is set to visit nested items, this method

compiler/rustc_privacy/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ impl<'tcx> fmt::Display for LazyDefPathStr<'tcx> {
6767
/// manually. Second, it doesn't visit some type components like signatures of fn types, or traits
6868
/// in `impl Trait`, see individual comments in `DefIdVisitorSkeleton::visit_ty`.
6969
pub trait DefIdVisitor<'tcx> {
70+
#[cfg_attr(not(bootstrap), must_use)]
7071
type Result: VisitorResult = ();
72+
7173
const SHALLOW: bool = false;
74+
7275
fn skip_assoc_tys(&self) -> bool {
7376
false
7477
}

compiler/rustc_trait_selection/src/solve/inspect/analyse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
461461

462462
/// The public API to interact with proof trees.
463463
pub trait ProofTreeVisitor<'tcx> {
464+
#[cfg_attr(not(bootstrap), must_use)]
464465
type Result: VisitorResult = ();
465466

466467
fn span(&self) -> Span;

compiler/rustc_ty_utils/src/sig_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_span::Span;
99
use tracing::{instrument, trace};
1010

1111
pub trait SpannedTypeVisitor<'tcx> {
12+
#[cfg_attr(not(bootstrap), must_use)]
1213
type Result: VisitorResult = ();
1314
fn visit(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) -> Self::Result;
1415
}

compiler/rustc_type_ir/src/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pub trait TypeSuperVisitable<I: Interner>: TypeVisitable<I> {
8989
/// that recurses into the type's fields in a non-custom fashion.
9090
pub trait TypeVisitor<I: Interner>: Sized {
9191
#[cfg(feature = "nightly")]
92+
#[cfg_attr(not(bootstrap), must_use)]
9293
type Result: VisitorResult = ();
9394

9495
#[cfg(not(feature = "nightly"))]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy