Suppress must_use in compiler and tools
This commit is contained in:
parent
2439623278
commit
380ce74401
13 changed files with 49 additions and 45 deletions
|
@ -2131,7 +2131,7 @@ fn add_library_search_dirs(
|
|||
}
|
||||
|
||||
let fallback = Some(NativeLibSearchFallback { self_contained_components, apple_sdk_root });
|
||||
walk_native_lib_search_dirs(sess, fallback, |dir, is_framework| {
|
||||
let _ = walk_native_lib_search_dirs(sess, fallback, |dir, is_framework| {
|
||||
if is_framework {
|
||||
cmd.framework_path(dir);
|
||||
} else {
|
||||
|
|
|
@ -533,7 +533,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
intravisit::walk_pat(self, p);
|
||||
let _ = intravisit::walk_pat(self, p);
|
||||
}
|
||||
}
|
||||
ControlFlow::Continue(())
|
||||
|
@ -556,7 +556,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
method_name,
|
||||
sugg_let: None,
|
||||
};
|
||||
let_visitor.visit_body(&body);
|
||||
let _ = let_visitor.visit_body(&body);
|
||||
if let Some(sugg_let) = let_visitor.sugg_let
|
||||
&& let Some(self_ty) = self.node_ty_opt(sugg_let.init_hir_id)
|
||||
{
|
||||
|
|
|
@ -1361,12 +1361,12 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
|
|||
GenericParamDefKind::Lifetime => {}
|
||||
GenericParamDefKind::Type { has_default, .. } => {
|
||||
if has_default {
|
||||
self.visit(self.tcx.type_of(param.def_id).instantiate_identity());
|
||||
let _ = self.visit(self.tcx.type_of(param.def_id).instantiate_identity());
|
||||
}
|
||||
}
|
||||
// FIXME(generic_const_exprs): May want to look inside const here
|
||||
GenericParamDefKind::Const { .. } => {
|
||||
self.visit(self.tcx.type_of(param.def_id).instantiate_identity());
|
||||
let _ = self.visit(self.tcx.type_of(param.def_id).instantiate_identity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1381,19 +1381,19 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
|
|||
// consider the ones that the user wrote. This is important
|
||||
// for the inferred outlives rules; see
|
||||
// `tests/ui/rfc-2093-infer-outlives/privacy.rs`.
|
||||
self.visit_predicates(self.tcx.explicit_predicates_of(self.item_def_id));
|
||||
let _ = self.visit_predicates(self.tcx.explicit_predicates_of(self.item_def_id));
|
||||
self
|
||||
}
|
||||
|
||||
fn bounds(&mut self) -> &mut Self {
|
||||
self.in_primary_interface = false;
|
||||
self.visit_clauses(self.tcx.explicit_item_bounds(self.item_def_id).skip_binder());
|
||||
let _ = self.visit_clauses(self.tcx.explicit_item_bounds(self.item_def_id).skip_binder());
|
||||
self
|
||||
}
|
||||
|
||||
fn ty(&mut self) -> &mut Self {
|
||||
self.in_primary_interface = true;
|
||||
self.visit(self.tcx.type_of(self.item_def_id).instantiate_identity());
|
||||
let _ = self.visit(self.tcx.type_of(self.item_def_id).instantiate_identity());
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -1785,7 +1785,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
|
|||
|
||||
let module = tcx.hir_module_items(module_def_id);
|
||||
for def_id in module.definitions() {
|
||||
rustc_ty_utils::sig_types::walk_types(tcx, def_id, &mut visitor);
|
||||
let _ = rustc_ty_utils::sig_types::walk_types(tcx, def_id, &mut visitor);
|
||||
|
||||
if let Some(body_id) = tcx.hir_maybe_body_owned_by(def_id) {
|
||||
visitor.visit_nested_body(body_id.id());
|
||||
|
@ -1798,7 +1798,11 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
|
|||
let trait_ref = tcx.impl_trait_ref(id.owner_id.def_id).unwrap();
|
||||
let trait_ref = trait_ref.instantiate_identity();
|
||||
visitor.span = item.path.span;
|
||||
visitor.visit_def_id(trait_ref.def_id, "trait", &trait_ref.print_only_trait_path());
|
||||
let _ = visitor.visit_def_id(
|
||||
trait_ref.def_id,
|
||||
"trait",
|
||||
&trait_ref.print_only_trait_path(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
|||
match arg.kind {
|
||||
hir::TyKind::BareFn(_) => {
|
||||
self.current_index.shift_in(1);
|
||||
intravisit::walk_ty(self, arg);
|
||||
let _ = intravisit::walk_ty(self, arg);
|
||||
self.current_index.shift_out(1);
|
||||
return ControlFlow::Continue(());
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
|||
hir::TyKind::TraitObject(bounds, ..) => {
|
||||
for bound in bounds {
|
||||
self.current_index.shift_in(1);
|
||||
self.visit_poly_trait_ref(bound);
|
||||
let _ = self.visit_poly_trait_ref(bound);
|
||||
self.current_index.shift_out(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -743,7 +743,7 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
|
|||
) {
|
||||
debug!("assemble_candidates_from_trait_def(..)");
|
||||
let mut ambiguous = false;
|
||||
selcx.for_each_item_bound(
|
||||
let _ = selcx.for_each_item_bound(
|
||||
obligation.predicate.self_ty(),
|
||||
|selcx, clause, _| {
|
||||
let Some(clause) = clause.as_projection_clause() else {
|
||||
|
|
|
@ -176,7 +176,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// normalization, so try to deduplicate when possible to avoid
|
||||
// unnecessary ambiguity.
|
||||
let mut distinct_normalized_bounds = FxHashSet::default();
|
||||
self.for_each_item_bound::<!>(
|
||||
let _ = self.for_each_item_bound::<!>(
|
||||
placeholder_trait_predicate.self_ty(),
|
||||
|selcx, bound, idx| {
|
||||
let Some(bound) = bound.as_trait_clause() else {
|
||||
|
|
|
@ -112,7 +112,7 @@ where
|
|||
pub fn bind_with_vars(value: T, bound_vars: I::BoundVarKinds) -> Binder<I, T> {
|
||||
if cfg!(debug_assertions) {
|
||||
let mut validator = ValidateBoundVars::new(bound_vars);
|
||||
value.visit_with(&mut validator);
|
||||
let _ = value.visit_with(&mut validator);
|
||||
}
|
||||
Binder { value, bound_vars }
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ impl<I: Interner, T> Binder<I, T> {
|
|||
let value = f(value);
|
||||
if cfg!(debug_assertions) {
|
||||
let mut validator = ValidateBoundVars::new(bound_vars);
|
||||
value.visit_with(&mut validator);
|
||||
let _ = value.visit_with(&mut validator);
|
||||
}
|
||||
Binder { value, bound_vars }
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ impl<I: Interner, T> Binder<I, T> {
|
|||
let value = f(value)?;
|
||||
if cfg!(debug_assertions) {
|
||||
let mut validator = ValidateBoundVars::new(bound_vars);
|
||||
value.visit_with(&mut validator);
|
||||
let _ = value.visit_with(&mut validator);
|
||||
}
|
||||
Ok(Binder { value, bound_vars })
|
||||
}
|
||||
|
|
|
@ -9,41 +9,41 @@ fn empty() {
|
|||
#[test]
|
||||
fn basic() {
|
||||
let mut buf = HtmlWithLimit::new(60);
|
||||
buf.push("Hello ");
|
||||
let _ = buf.push("Hello ");
|
||||
buf.open_tag("em");
|
||||
buf.push("world");
|
||||
let _ = buf.push("world");
|
||||
buf.close_tag();
|
||||
buf.push("!");
|
||||
let _ = buf.push("!");
|
||||
assert_eq!(buf.finish(), "Hello <em>world</em>!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_tags() {
|
||||
let mut buf = HtmlWithLimit::new(60);
|
||||
buf.push("Hello");
|
||||
buf.push(" world!");
|
||||
let _ = buf.push("Hello");
|
||||
let _ = buf.push(" world!");
|
||||
assert_eq!(buf.finish(), "Hello world!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn limit_0() {
|
||||
let mut buf = HtmlWithLimit::new(0);
|
||||
buf.push("Hello ");
|
||||
let _ = buf.push("Hello ");
|
||||
buf.open_tag("em");
|
||||
buf.push("world");
|
||||
let _ = buf.push("world");
|
||||
buf.close_tag();
|
||||
buf.push("!");
|
||||
let _ = buf.push("!");
|
||||
assert_eq!(buf.finish(), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exactly_limit() {
|
||||
let mut buf = HtmlWithLimit::new(12);
|
||||
buf.push("Hello ");
|
||||
let _ = buf.push("Hello ");
|
||||
buf.open_tag("em");
|
||||
buf.push("world");
|
||||
let _ = buf.push("world");
|
||||
buf.close_tag();
|
||||
buf.push("!");
|
||||
let _ = buf.push("!");
|
||||
assert_eq!(buf.finish(), "Hello <em>world</em>!");
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,11 @@ fn exactly_limit() {
|
|||
fn multiple_nested_tags() {
|
||||
let mut buf = HtmlWithLimit::new(60);
|
||||
buf.open_tag("p");
|
||||
buf.push("This is a ");
|
||||
let _ = buf.push("This is a ");
|
||||
buf.open_tag("em");
|
||||
buf.push("paragraph");
|
||||
let _ = buf.push("paragraph");
|
||||
buf.open_tag("strong");
|
||||
buf.push("!");
|
||||
let _ = buf.push("!");
|
||||
buf.close_tag();
|
||||
buf.close_tag();
|
||||
buf.close_tag();
|
||||
|
@ -66,11 +66,11 @@ fn multiple_nested_tags() {
|
|||
fn forgot_to_close_tags() {
|
||||
let mut buf = HtmlWithLimit::new(60);
|
||||
buf.open_tag("p");
|
||||
buf.push("This is a ");
|
||||
let _ = buf.push("This is a ");
|
||||
buf.open_tag("em");
|
||||
buf.push("paragraph");
|
||||
let _ = buf.push("paragraph");
|
||||
buf.open_tag("strong");
|
||||
buf.push("!");
|
||||
let _ = buf.push("!");
|
||||
assert_eq!(buf.finish(), "<p>This is a <em>paragraph<strong>!</strong></em></p>");
|
||||
}
|
||||
|
||||
|
@ -78,10 +78,10 @@ fn forgot_to_close_tags() {
|
|||
fn past_the_limit() {
|
||||
let mut buf = HtmlWithLimit::new(20);
|
||||
buf.open_tag("p");
|
||||
(0..10).try_for_each(|n| {
|
||||
let _ = (0..10).try_for_each(|n| {
|
||||
buf.open_tag("strong");
|
||||
buf.push("word#")?;
|
||||
buf.push(&n.to_string())?;
|
||||
let _ = buf.push("word#")?;
|
||||
let _ = buf.push(&n.to_string())?;
|
||||
buf.close_tag();
|
||||
ControlFlow::Continue(())
|
||||
});
|
||||
|
@ -100,8 +100,8 @@ fn past_the_limit() {
|
|||
fn quickly_past_the_limit() {
|
||||
let mut buf = HtmlWithLimit::new(6);
|
||||
buf.open_tag("p");
|
||||
buf.push("Hello");
|
||||
buf.push(" World");
|
||||
let _ = buf.push("Hello");
|
||||
let _ = buf.push(" World");
|
||||
// intentionally not closing <p> before finishing
|
||||
assert_eq!(buf.finish(), "<p>Hello</p>");
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ fn quickly_past_the_limit() {
|
|||
fn close_too_many() {
|
||||
let mut buf = HtmlWithLimit::new(60);
|
||||
buf.open_tag("p");
|
||||
buf.push("Hello");
|
||||
let _ = buf.push("Hello");
|
||||
buf.close_tag();
|
||||
// This call does not panic because there are valid cases
|
||||
// where `close_tag()` is called with no tags left to close.
|
||||
|
|
|
@ -1568,7 +1568,7 @@ fn markdown_summary_with_limit(
|
|||
|
||||
let mut buf = HtmlWithLimit::new(length_limit);
|
||||
let mut stopped_early = false;
|
||||
p.try_for_each(|event| {
|
||||
let _ = p.try_for_each(|event| {
|
||||
match &event {
|
||||
Event::Text(text) => {
|
||||
let r =
|
||||
|
|
|
@ -129,7 +129,7 @@ impl BreakAfterExprVisitor {
|
|||
};
|
||||
|
||||
get_enclosing_block(cx, hir_id).is_some_and(|block| {
|
||||
visitor.visit_block(block);
|
||||
let _ = visitor.visit_block(block);
|
||||
visitor.break_after_expr
|
||||
})
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ pub fn check(cx: &LateContext<'_>, call: &Expr<'_>, recv: &Expr<'_>, arg: &Expr<
|
|||
// We've checked that `call` is a call to `Stdin::read_line()` with the right receiver,
|
||||
// now let's check if the first use of the string passed to `::read_line()`
|
||||
// is used for operations that will always fail (e.g. parsing "6\n" into a number)
|
||||
for_each_local_use_after_expr(cx, local_id, call.hir_id, |expr| {
|
||||
let _ = for_each_local_use_after_expr(cx, local_id, call.hir_id, |expr| {
|
||||
if let Some(parent) = get_parent_expr(cx, expr) {
|
||||
let data = if let ExprKind::MethodCall(segment, recv, args, span) = parent.kind {
|
||||
if args.is_empty()
|
||||
|
|
|
@ -141,7 +141,7 @@ impl PassByRefOrValue {
|
|||
// Gather all the lifetimes found in the output type which may affect whether
|
||||
// `TRIVIALLY_COPY_PASS_BY_REF` should be linted.
|
||||
let mut output_regions = FxHashSet::default();
|
||||
for_each_top_level_late_bound_region(fn_sig.skip_binder().output(), |region| -> ControlFlow<!> {
|
||||
let _ = for_each_top_level_late_bound_region(fn_sig.skip_binder().output(), |region| -> ControlFlow<!> {
|
||||
output_regions.insert(region);
|
||||
ControlFlow::Continue(())
|
||||
});
|
||||
|
|
|
@ -381,7 +381,7 @@ impl UnconditionalRecursion {
|
|||
implemented_ty_id,
|
||||
method_span,
|
||||
};
|
||||
walk_body(&mut c, body);
|
||||
let _ = walk_body(&mut c, body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue