public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Remove old unused code pass this was too generic
@ 2022-06-08 12:16 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7820ff8b8b14e1309aade205e50ef30bb08cb3e5
commit 7820ff8b8b14e1309aade205e50ef30bb08cb3e5
Author: Philip Herron <philip.herron@embecosm.com>
Date: Fri Mar 4 15:14:12 2022 +0000
Remove old unused code pass this was too generic
This now uses the TREE_USED fields on GCC tree's to track the usage of
VAR_DECLS, PARM_DECLS and CONST_DECLS. The code does a pass over the body
and parameters of functions as a lint pass.
Fixes #676
Diff:
---
gcc/rust/Make-lang.in | 1 +
gcc/rust/backend/rust-compile-context.h | 5 ++
gcc/rust/backend/rust-compile-expr.cc | 9 ++
gcc/rust/backend/rust-compile-resolve-path.cc | 22 ++++-
gcc/rust/lang.opt | 12 +++
gcc/rust/lint/rust-lint-unused-var.cc | 98 ++++++++++++++++++++++
gcc/rust/lint/rust-lint-unused-var.h | 36 ++++++++
gcc/rust/resolve/rust-ast-resolve-unused.h | 61 --------------
gcc/rust/rust-gcc.cc | 20 +++--
gcc/rust/rust-session-manager.cc | 29 +++----
gcc/testsuite/rust/compile/array3.rs | 1 -
| 70 ++++++++--------
| 10 +--
.../rust/compile/torture/associated_types1.rs | 2 -
gcc/testsuite/rust/compile/torture/cfg_attr.rs | 1 -
gcc/testsuite/rust/compile/torture/generics13.rs | 3 +-
gcc/testsuite/rust/compile/torture/generics14.rs | 3 +-
gcc/testsuite/rust/compile/torture/generics18.rs | 1 -
gcc/testsuite/rust/compile/torture/generics24.rs | 1 -
.../rust/compile/torture/impl_block_unused.rs | 10 +--
gcc/testsuite/rust/compile/torture/issue-808.rs | 2 -
.../rust/compile/torture/mod-nameresolve.rs | 3 +-
gcc/testsuite/rust/compile/torture/mod1.rs | 1 -
gcc/testsuite/rust/compile/torture/mod2.rs | 10 +--
gcc/testsuite/rust/compile/torture/must_use2.rs | 1 -
.../rust/compile/torture/struct_init_4.rs | 5 +-
gcc/testsuite/rust/compile/torture/traits1.rs | 1 -
gcc/testsuite/rust/compile/torture/traits10.rs | 1 -
gcc/testsuite/rust/compile/torture/traits18.rs | 3 -
gcc/testsuite/rust/compile/torture/traits2.rs | 1 -
gcc/testsuite/rust/compile/torture/traits3.rs | 3 -
gcc/testsuite/rust/compile/torture/traits4.rs | 3 -
gcc/testsuite/rust/compile/torture/traits5.rs | 3 -
gcc/testsuite/rust/compile/torture/traits6.rs | 2 -
gcc/testsuite/rust/compile/torture/traits7.rs | 3 -
gcc/testsuite/rust/compile/torture/traits8.rs | 1 -
gcc/testsuite/rust/compile/torture/traits9.rs | 3 -
.../rust/compile/torture/tuple_enum_variants.rs | 9 +-
.../rust/compile/torture/tuple_struct_unused.rs | 4 +-
gcc/testsuite/rust/compile/torture/unused1.rs | 1 -
.../rust/compile/torture/unused_struct.rs | 1 -
gcc/testsuite/rust/compile/traits8.rs | 2 -
gcc/testsuite/rust/execute/torture/coercion1.rs | 2 -
gcc/testsuite/rust/execute/torture/coercion2.rs | 2 -
gcc/testsuite/rust/execute/torture/match2.rs | 1 -
gcc/testsuite/rust/execute/torture/mod1.rs | 16 ++--
.../rust/execute/torture/operator_overload_1.rs | 3 -
.../rust/execute/torture/operator_overload_10.rs | 4 -
.../rust/execute/torture/operator_overload_2.rs | 3 -
.../rust/execute/torture/operator_overload_3.rs | 3 -
.../rust/execute/torture/operator_overload_4.rs | 2 -
.../rust/execute/torture/operator_overload_5.rs | 2 -
.../rust/execute/torture/operator_overload_6.rs | 3 -
.../rust/execute/torture/operator_overload_7.rs | 2 -
.../rust/execute/torture/operator_overload_8.rs | 3 -
.../rust/execute/torture/operator_overload_9.rs | 3 -
gcc/testsuite/rust/execute/torture/trait10.rs | 2 -
gcc/testsuite/rust/execute/torture/trait11.rs | 3 -
gcc/testsuite/rust/execute/torture/trait12.rs | 3 -
gcc/testsuite/rust/execute/torture/trait13.rs | 2 -
gcc/testsuite/rust/execute/torture/trait4.rs | 2 -
gcc/testsuite/rust/execute/torture/trait5.rs | 2 -
gcc/testsuite/rust/execute/torture/trait6.rs | 2 -
gcc/testsuite/rust/execute/torture/trait7.rs | 2 -
gcc/testsuite/rust/execute/torture/trait8.rs | 2 -
gcc/testsuite/rust/execute/torture/trait9.rs | 3 -
66 files changed, 263 insertions(+), 267 deletions(-)
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index b33d90ea6c6..2f529313138 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -101,6 +101,7 @@ GRS_OBJS = \
rust/rust-autoderef.o \
rust/rust-substitution-mapper.o \
rust/rust-lint-marklive.o \
+ rust/rust-lint-unused-var.o \
rust/rust-hir-type-check-path.o \
rust/rust-compile-intrinsic.o \
rust/rust-compile-pattern.o \
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index 3fefd8d5c7c..4bade5c7d60 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -307,6 +307,11 @@ public:
return mangler.mangle_item (ty, path);
}
+ std::vector<tree> &get_type_decls () { return type_decls; }
+ std::vector<::Bvariable *> &get_var_decls () { return var_decls; }
+ std::vector<tree> &get_const_decls () { return const_decls; }
+ std::vector<tree> &get_func_decls () { return func_decls; }
+
private:
::Backend *backend;
Resolver::Resolver *resolver;
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 6d50c3fcf9f..03e3c2efea3 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1339,18 +1339,22 @@ CompileExpr::visit (HIR::IdentifierExpr &expr)
Bvariable *var = nullptr;
if (ctx->lookup_const_decl (ref, &translated))
{
+ TREE_USED (translated) = 1;
return;
}
else if (ctx->lookup_function_decl (ref, &fn))
{
+ TREE_USED (fn) = 1;
translated = address_expression (fn, expr.get_locus ());
}
else if (ctx->lookup_var_decl (ref, &var))
{
+ // TREE_USED is setup in the gcc abstraction here
translated = ctx->get_backend ()->var_expression (var, expr.get_locus ());
}
else if (ctx->lookup_pattern_binding (ref, &translated))
{
+ TREE_USED (translated) = 1;
return;
}
else
@@ -1371,6 +1375,11 @@ CompileExpr::visit (HIR::IdentifierExpr &expr)
else
translated = CompileItem::compile (resolved_item, ctx, lookup, true,
expr.get_locus ());
+
+ if (translated != error_mark_node)
+ {
+ TREE_USED (translated) = 1;
+ }
}
}
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index e41ee7f1493..09f3860efed 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -23,6 +23,8 @@
#include "rust-hir-trait-resolve.h"
#include "rust-hir-path-probe.h"
+#include "print-tree.h"
+
namespace Rust {
namespace Compile {
@@ -117,12 +119,18 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
// might be a constant
tree constant_expr;
if (ctx->lookup_const_decl (ref, &constant_expr))
- return constant_expr;
+ {
+ TREE_USED (constant_expr) = 1;
+ return constant_expr;
+ }
// this might be a variable reference or a function reference
Bvariable *var = nullptr;
if (ctx->lookup_var_decl (ref, &var))
- return ctx->get_backend ()->var_expression (var, expr_locus);
+ {
+ // TREE_USED is setup in the gcc abstraction here
+ return ctx->get_backend ()->var_expression (var, expr_locus);
+ }
// it might be a function call
if (lookup->get_kind () == TyTy::TypeKind::FNDEF)
@@ -131,13 +139,19 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
tree fn = NULL_TREE;
if (ctx->lookup_function_decl (fntype->get_ty_ref (), &fn))
{
+ TREE_USED (fn) = 1;
return address_expression (fn, expr_locus);
}
}
// let the query system figure it out
- return query_compile (ref, lookup, final_segment, mappings, expr_locus,
- is_qualified_path);
+ tree resolved_item = query_compile (ref, lookup, final_segment, mappings,
+ expr_locus, is_qualified_path);
+ if (resolved_item != error_mark_node)
+ {
+ TREE_USED (resolved_item) = 1;
+ }
+ return resolved_item;
}
tree
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt
index 794a667c0eb..86a063f000c 100644
--- a/gcc/rust/lang.opt
+++ b/gcc/rust/lang.opt
@@ -38,6 +38,18 @@ Wall
Rust
; Documented in c.opt
+Wunused-variable
+Rust Var(warn_unused_variable) Init(1) Warning
+; documented in common.opt
+
+Wunused-const-variable
+Rust Warning Alias(Wunused-const-variable=, 2, 0)
+Warn when a const variable is unused.
+
+Wunused-const-variable=
+Rust Joined RejectNegative UInteger Var(warn_unused_const_variable) Init(1) Warning LangEnabledBy(Rust,Wunused-variable, 1, 0) IntegerRange(0, 2)
+Warn when a const variable is unused.
+
Wunused-result
Rust Var(warn_unused_result) Init(1) Warning
Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value.
diff --git a/gcc/rust/lint/rust-lint-unused-var.cc b/gcc/rust/lint/rust-lint-unused-var.cc
new file mode 100644
index 00000000000..d4317e53280
--- /dev/null
+++ b/gcc/rust/lint/rust-lint-unused-var.cc
@@ -0,0 +1,98 @@
+// Copyright (C) 2021-2022 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include "rust-lint-unused-var.h"
+#include "print-tree.h"
+
+namespace Rust {
+namespace Analysis {
+
+static void
+check_decl (tree *t)
+{
+ rust_assert (TREE_CODE (*t) == VAR_DECL || TREE_CODE (*t) == PARM_DECL
+ || TREE_CODE (*t) == CONST_DECL);
+
+ tree var_name = DECL_NAME (*t);
+ const char *var_name_ptr = IDENTIFIER_POINTER (var_name);
+ bool starts_with_under_score = strncmp (var_name_ptr, "_", 1) == 0;
+
+ bool is_constant = TREE_CODE (*t) == CONST_DECL;
+ // if (!is_constant)
+ // {
+ // debug_tree (*t);
+ // rust_debug ("found var-decl: used %s artifical %s underscore %s name
+ // %s",
+ // TREE_USED (*t) ? "true" : "false",
+ // DECL_ARTIFICIAL (*t) ? "true" : "false",
+ // starts_with_under_score ? "true" : "false", var_name_ptr);
+ // }
+
+ if (!TREE_USED (*t) && !DECL_ARTIFICIAL (*t) && !starts_with_under_score)
+ {
+ warning_at (DECL_SOURCE_LOCATION (*t),
+ is_constant ? OPT_Wunused_const_variable_
+ : OPT_Wunused_variable,
+ "unused name %qE", *t);
+ }
+}
+
+static tree
+unused_var_walk_fn (tree *t, int *walk_subtrees, void *closure)
+{
+ switch (TREE_CODE (*t))
+ {
+ case VAR_DECL:
+ case CONST_DECL:
+ check_decl (t);
+ break;
+
+ default:
+ break;
+ }
+ return NULL_TREE;
+}
+
+void
+UnusedVariables::Lint (Compile::Context &ctx)
+{
+ for (auto &fndecl : ctx.get_func_decls ())
+ {
+ for (tree p = DECL_ARGUMENTS (fndecl); p != NULL_TREE; p = DECL_CHAIN (p))
+ {
+ check_decl (&p);
+ }
+
+ walk_tree_without_duplicates (&DECL_SAVED_TREE (fndecl),
+ &unused_var_walk_fn, &ctx);
+ }
+
+ for (auto &var : ctx.get_var_decls ())
+ {
+ tree t = ctx.get_backend ()->var_expression (var, Location ());
+ check_decl (&t);
+ }
+
+ for (auto &const_decl : ctx.get_const_decls ())
+ {
+ check_decl (&const_decl);
+ }
+}
+
+} // namespace Analysis
+} // namespace Rust
diff --git a/gcc/rust/lint/rust-lint-unused-var.h b/gcc/rust/lint/rust-lint-unused-var.h
new file mode 100644
index 00000000000..6fabfeff01b
--- /dev/null
+++ b/gcc/rust/lint/rust-lint-unused-var.h
@@ -0,0 +1,36 @@
+// Copyright (C) 2021-2022 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#ifndef RUST_LINT_UNUSED_VAR
+#define RUST_LINT_UNUSED_VAR
+
+#include "rust-compile-context.h"
+
+namespace Rust {
+namespace Analysis {
+
+class UnusedVariables
+{
+public:
+ static void Lint (Compile::Context &ctx);
+};
+
+} // namespace Analysis
+} // namespace Rust
+
+#endif // RUST_LINT_UNUSED_VAR
diff --git a/gcc/rust/resolve/rust-ast-resolve-unused.h b/gcc/rust/resolve/rust-ast-resolve-unused.h
deleted file mode 100644
index 6c0fc42ba64..00000000000
--- a/gcc/rust/resolve/rust-ast-resolve-unused.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2020-2022 Free Software Foundation, Inc.
-
-// This file is part of GCC.
-
-// GCC is free software; you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 3, or (at your option) any later
-// version.
-
-// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-// for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with GCC; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-#ifndef RUST_AST_RESOLVE_UNUSED_H
-#define RUST_AST_RESOLVE_UNUSED_H
-
-#include "rust-ast-resolve-base.h"
-
-namespace Rust {
-namespace Resolver {
-
-class ScanUnused
-{
-public:
- static bool ScanRib (Rib *r)
- {
- r->iterate_decls ([&] (NodeId decl_node_id, Location locus) -> bool {
- CanonicalPath ident = CanonicalPath::create_empty ();
-
- bool ok = r->lookup_canonical_path (decl_node_id, &ident);
- rust_assert (ok);
-
- bool name_starts_with_underscore = ident.get ().at (0) == '_';
- if (!r->have_references_for_node (decl_node_id)
- && !name_starts_with_underscore)
- {
- rust_warning_at (locus, 0, "unused name '%s'", ident.get ().c_str ());
- }
- return true;
- });
- return true;
- }
-
- static void Scan ()
- {
- auto resolver = Resolver::get ();
- resolver->iterate_name_ribs ([&] (Rib *r) -> bool { return ScanRib (r); });
- resolver->iterate_type_ribs ([&] (Rib *r) -> bool { return ScanRib (r); });
- resolver->iterate_label_ribs ([&] (Rib *r) -> bool { return ScanRib (r); });
- }
-};
-
-} // namespace Resolver
-} // namespace Rust
-
-#endif // RUST_AST_RESOLVE_UNUSED_H
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 60923d13ec4..70c07c15256 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -86,9 +86,15 @@ private:
tree
Bvariable::get_tree (Location location) const
{
- if (this->orig_type_ == NULL || this->t_ == error_mark_node
- || TREE_TYPE (this->t_) == this->orig_type_)
- return this->t_;
+ if (this->t_ == error_mark_node)
+ return error_mark_node;
+
+ TREE_USED (this->t_) = 1;
+ if (this->orig_type_ == NULL || TREE_TYPE (this->t_) == this->orig_type_)
+ {
+ return this->t_;
+ }
+
// Return *(orig_type*)&decl. */
tree t = build_fold_addr_expr_loc (location.gcc_location (), this->t_);
t = fold_build1_loc (location.gcc_location (), NOP_EXPR,
@@ -1063,10 +1069,7 @@ Gcc_backend::zero_expression (tree t)
tree
Gcc_backend::var_expression (Bvariable *var, Location location)
{
- tree ret = var->get_tree (location);
- if (ret == error_mark_node)
- return error_mark_node;
- return ret;
+ return var->get_tree (location);
}
// An expression that indirectly references an expression.
@@ -2394,7 +2397,6 @@ Gcc_backend::local_variable (tree function, const std::string &name,
tree decl = build_decl (location.gcc_location (), VAR_DECL,
get_identifier_from_string (name), type_tree);
DECL_CONTEXT (decl) = function;
- TREE_USED (decl) = 1;
if (decl_var != NULL)
{
@@ -2417,7 +2419,7 @@ Gcc_backend::parameter_variable (tree function, const std::string &name,
get_identifier_from_string (name), type_tree);
DECL_CONTEXT (decl) = function;
DECL_ARG_TYPE (decl) = type_tree;
- TREE_USED (decl) = 1;
+
rust_preserve_from_gc (decl);
return new Bvariable (decl);
}
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 54a64435a60..396f35f3011 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -25,11 +25,11 @@
#include "rust-ast-resolve.h"
#include "rust-ast-lower.h"
#include "rust-hir-type-check.h"
-#include "rust-lint-scan-deadcode.h"
#include "rust-tycheck-dump.h"
-#include "rust-ast-resolve-unused.h"
#include "rust-compile.h"
#include "rust-cfg-parser.h"
+#include "rust-lint-scan-deadcode.h"
+#include "rust-lint-unused-var.h"
#include "diagnostic.h"
#include "input.h"
@@ -599,27 +599,18 @@ Session::parse_file (const char *filename)
if (saw_errors ())
return;
- // scan dead code
- Analysis::ScanDeadcode::Scan (hir);
-
- if (saw_errors ())
- return;
-
- // scan unused has to be done after type resolution since methods are
- // resolved at that point
- Resolver::ScanUnused::Scan ();
-
- if (saw_errors ())
- return;
-
- // do compile
+ // do compile to gcc generic
Compile::Context ctx (backend);
Compile::CompileCrate::Compile (hir, &ctx);
- if (saw_errors ())
- return;
+ // we can't do static analysis if there are errors to worry about
+ if (!saw_errors ())
+ {
+ Analysis::ScanDeadcode::Scan (hir);
+ Analysis::UnusedVariables::Lint (ctx);
+ }
- // pass to GCC
+ // pass to GCC middle-end
ctx.write_to_backend ();
}
diff --git a/gcc/testsuite/rust/compile/array3.rs b/gcc/testsuite/rust/compile/array3.rs
index a62c6ca69c7..a56be9a0e8b 100644
--- a/gcc/testsuite/rust/compile/array3.rs
+++ b/gcc/testsuite/rust/compile/array3.rs
@@ -1,5 +1,4 @@
fn foo(state: &mut [u32; 16], a: usize) {
// { dg-warning "function is never used: .foo." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .foo." "" { target *-*-* } .-2 }
state[a] = 1;
}
diff --git a/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks.rs b/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks.rs
index 41c3b510dec..b7368ba29ee 100644
--- a/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks.rs
+++ b/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks.rs
@@ -9,41 +9,37 @@
/// outer doc line for module
/** outer doc block for module */
-pub mod module // { dg-warning "unused name" }
-{
- //! inner line doc
- //!! inner line doc!
- /*! inner block doc */
- /*!! inner block doc! */
-
- // line comment
- /// outer line doc
- //// line comment
-
- /* block comment */
- /** outer block doc */
- /*** block comment */
-
- mod block_doc_comments // { dg-warning "unused name" }
- {
- /* /* */ /** */ /*! */ */
- /*! /* */ /** */ /*! */ */
- /** /* */ /** */ /*! */ */
- mod item { } // { dg-warning "unused name" }
- }
-
- pub mod empty // { dg-warning "unused name" }
- {
- //!
- /*!*/
- //
-
- ///
- // the following warning is issued one line earlier
- // { dg-warning "unused name" }
- mod doc { }
- /**/
- /***/
- }
+pub mod module {
+ //! inner line doc
+ //!! inner line doc!
+ /*! inner block doc */
+ /*!! inner block doc! */
+
+ // line comment
+ /// outer line doc
+ //// line comment
+
+ /* block comment */
+ /** outer block doc */
+ /*** block comment */
+
+ mod block_doc_comments {
+ /* /* */ /** */ /*! */ */
+ /*! /* */ /** */ /*! */ */
+ /** /* */ /** */ /*! */ */
+ mod item {}
+ }
+
+ pub mod empty {
+ //!
+ /*!*/
+ //
+
+ ///
+ // the following warning is issued one line earlier
+ mod doc {}
+ /**/
+ /***/
+ }
}
-pub fn main () { }
+pub fn main() {}
diff --git a/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks_crlf.rs b/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks_crlf.rs
index e5ed91189c5..9f2f2207397 100644
--- a/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks_crlf.rs
+++ b/gcc/testsuite/rust/compile/torture/all_doc_comment_line_blocks_crlf.rs
@@ -9,7 +9,7 @@
/// outer doc line for module
/** outer doc block for module */
-pub mod module // { dg-warning "unused name" }
+pub mod module
{
//! inner line doc
//!! inner line doc!
@@ -24,22 +24,22 @@ pub mod module // { dg-warning "unused name" }
/** outer block doc */
/*** block comment */
- mod block_doc_comments // { dg-warning "unused name" }
+ mod block_doc_comments
{
/* /* */ /** */ /*! */ */
/*! /* */ /** */ /*! */ */
/** /* */ /** */ /*! */ */
- mod item { } // { dg-warning "unused name" }
+ mod item { }
}
- pub mod empty // { dg-warning "unused name" }
+ pub mod empty
{
//!
/*!*/
//
///
- mod doc { } // { dg-warning "unused name" }
+ mod doc { }
/**/
/***/
diff --git a/gcc/testsuite/rust/compile/torture/associated_types1.rs b/gcc/testsuite/rust/compile/torture/associated_types1.rs
index 0d4b4c7923f..bf181df7045 100644
--- a/gcc/testsuite/rust/compile/torture/associated_types1.rs
+++ b/gcc/testsuite/rust/compile/torture/associated_types1.rs
@@ -2,12 +2,10 @@ pub trait Foo {
type A;
fn boo(&self) -> <Self as Foo>::A;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
}
fn foo2<I: Foo>(x: I) {
// { dg-warning "function is never used: .foo2." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .foo2." "" { target *-*-* } .-2 }
x.boo();
}
diff --git a/gcc/testsuite/rust/compile/torture/cfg_attr.rs b/gcc/testsuite/rust/compile/torture/cfg_attr.rs
index bc02e2ade0f..962d875ab56 100644
--- a/gcc/testsuite/rust/compile/torture/cfg_attr.rs
+++ b/gcc/testsuite/rust/compile/torture/cfg_attr.rs
@@ -3,6 +3,5 @@ use std::env; // Add one line so gccrs doesn't believe we're parsing a shebang
#[cfg_attr(feature = "somefeature", attribute = "someattr")]
struct Feature;
// { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }
-// { dg-warning "unused name" "" { target *-*-* } .-2 }
fn main() {}
diff --git a/gcc/testsuite/rust/compile/torture/generics13.rs b/gcc/testsuite/rust/compile/torture/generics13.rs
index cc781d8e626..9eb598f02a8 100644
--- a/gcc/testsuite/rust/compile/torture/generics13.rs
+++ b/gcc/testsuite/rust/compile/torture/generics13.rs
@@ -1,6 +1,6 @@
struct Foo<A> {
a: A,
-// { dg-warning "field is never read" "" { target *-*-* } .-1 }
+ // { dg-warning "field is never read" "" { target *-*-* } .-1 }
}
struct GenericStruct<T> {
@@ -15,7 +15,6 @@ impl Foo<isize> {
fn bar(self) -> isize {
// { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
self.a
}
}
diff --git a/gcc/testsuite/rust/compile/torture/generics14.rs b/gcc/testsuite/rust/compile/torture/generics14.rs
index d6fbc0cb52a..e51a4079e30 100644
--- a/gcc/testsuite/rust/compile/torture/generics14.rs
+++ b/gcc/testsuite/rust/compile/torture/generics14.rs
@@ -1,6 +1,6 @@
struct Foo<A> {
a: A,
-// { dg-warning "field is never read" "" { target *-*-* } .-1 }
+ // { dg-warning "field is never read" "" { target *-*-* } .-1 }
}
impl Foo<isize> {
@@ -10,7 +10,6 @@ impl Foo<isize> {
fn bar(self) -> isize {
// { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
self.a
}
}
diff --git a/gcc/testsuite/rust/compile/torture/generics18.rs b/gcc/testsuite/rust/compile/torture/generics18.rs
index 924b30cef90..4c98b86a1b9 100644
--- a/gcc/testsuite/rust/compile/torture/generics18.rs
+++ b/gcc/testsuite/rust/compile/torture/generics18.rs
@@ -3,7 +3,6 @@ struct Foo<T>(T);
impl<X> Foo<X> {
fn new(a: X) -> Self {
// { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
Self(a)
}
diff --git a/gcc/testsuite/rust/compile/torture/generics24.rs b/gcc/testsuite/rust/compile/torture/generics24.rs
index 85ea2f74b7c..0de45a8c404 100644
--- a/gcc/testsuite/rust/compile/torture/generics24.rs
+++ b/gcc/testsuite/rust/compile/torture/generics24.rs
@@ -11,7 +11,6 @@ impl Foo<isize> {
impl Foo<char> {
fn bar(self) -> char {
// { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
self.a
}
}
diff --git a/gcc/testsuite/rust/compile/torture/impl_block_unused.rs b/gcc/testsuite/rust/compile/torture/impl_block_unused.rs
index ef40e18932e..fea86319243 100644
--- a/gcc/testsuite/rust/compile/torture/impl_block_unused.rs
+++ b/gcc/testsuite/rust/compile/torture/impl_block_unused.rs
@@ -2,18 +2,16 @@ struct Foo(i32, bool);
impl Foo {
fn new(a: i32, b: bool) -> Foo {
- // { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
+ // { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
Foo(a, b)
}
fn test2() -> i32 {
- // { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
- 1
+ // { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
+ 1
}
}
fn main() {
- let _a = Foo(1, true);
+ let _a = Foo(1, true);
}
diff --git a/gcc/testsuite/rust/compile/torture/issue-808.rs b/gcc/testsuite/rust/compile/torture/issue-808.rs
index 9aa00fe0d08..2e5a81fe516 100644
--- a/gcc/testsuite/rust/compile/torture/issue-808.rs
+++ b/gcc/testsuite/rust/compile/torture/issue-808.rs
@@ -2,8 +2,6 @@ pub trait Foo {
type Target;
fn bar(&self) -> &Self::Target;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Foo::bar." "" { target *-*-* } .-2 }
}
impl<T> Foo for &T {
diff --git a/gcc/testsuite/rust/compile/torture/mod-nameresolve.rs b/gcc/testsuite/rust/compile/torture/mod-nameresolve.rs
index a5e214b0daa..09a722681b0 100644
--- a/gcc/testsuite/rust/compile/torture/mod-nameresolve.rs
+++ b/gcc/testsuite/rust/compile/torture/mod-nameresolve.rs
@@ -1,6 +1,5 @@
-// { dg-additional-options "-w" }
mod foo {
- struct A;
+ struct A; // { dg-warning "struct is never constructed" }
}
fn main() {}
diff --git a/gcc/testsuite/rust/compile/torture/mod1.rs b/gcc/testsuite/rust/compile/torture/mod1.rs
index ca272f711de..651678c6a34 100644
--- a/gcc/testsuite/rust/compile/torture/mod1.rs
+++ b/gcc/testsuite/rust/compile/torture/mod1.rs
@@ -9,4 +9,3 @@ mod _bar {
struct _B;
}
}
-
diff --git a/gcc/testsuite/rust/compile/torture/mod2.rs b/gcc/testsuite/rust/compile/torture/mod2.rs
index 6a2d1ed5901..04722a94bb1 100644
--- a/gcc/testsuite/rust/compile/torture/mod2.rs
+++ b/gcc/testsuite/rust/compile/torture/mod2.rs
@@ -1,15 +1,13 @@
mod foomod {
- pub struct Foo { // { dg-warning "unused name" }
- }
+ pub struct Foo {}
}
impl foomod::Foo {
pub fn new() -> Self {
- foomod::Foo {
- }
+ foomod::Foo {}
}
}
-
+
fn main() {
- let _a = foomod::Foo::new();
+ let _a = foomod::Foo::new();
}
diff --git a/gcc/testsuite/rust/compile/torture/must_use2.rs b/gcc/testsuite/rust/compile/torture/must_use2.rs
index 4c6d6601311..466f7ee7a14 100644
--- a/gcc/testsuite/rust/compile/torture/must_use2.rs
+++ b/gcc/testsuite/rust/compile/torture/must_use2.rs
@@ -1,7 +1,6 @@
trait A {
#[must_use]
fn test() -> i32;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct S;
diff --git a/gcc/testsuite/rust/compile/torture/struct_init_4.rs b/gcc/testsuite/rust/compile/torture/struct_init_4.rs
index d4b2de8f2a8..2b2746aba7a 100644
--- a/gcc/testsuite/rust/compile/torture/struct_init_4.rs
+++ b/gcc/testsuite/rust/compile/torture/struct_init_4.rs
@@ -1,12 +1,13 @@
struct Foo {
a: i32,
-// { dg-warning "field is never read" "" { target *-*-* } .-1 }
+ // { dg-warning "field is never read" "" { target *-*-* } .-1 }
b: i32,
-// { dg-warning "field is never read" "" { target *-*-* } .-1 }
+ // { dg-warning "field is never read" "" { target *-*-* } .-1 }
}
fn main() {
let a = Foo { a: 1, b: 2 };
+ // { dg-warning "unused name" "" { target *-*-* } .-1 }
let b = Foo { a: 3, b: 4, ..a };
// { dg-warning "unused name" "" { target *-*-* } .-1 }
}
diff --git a/gcc/testsuite/rust/compile/torture/traits1.rs b/gcc/testsuite/rust/compile/torture/traits1.rs
index 18e2779baf2..90357738a81 100644
--- a/gcc/testsuite/rust/compile/torture/traits1.rs
+++ b/gcc/testsuite/rust/compile/torture/traits1.rs
@@ -1,6 +1,5 @@
trait Foo {
fn bar() -> i32;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct Test(i32, f32);
diff --git a/gcc/testsuite/rust/compile/torture/traits10.rs b/gcc/testsuite/rust/compile/torture/traits10.rs
index a492ec35736..a02927007b3 100644
--- a/gcc/testsuite/rust/compile/torture/traits10.rs
+++ b/gcc/testsuite/rust/compile/torture/traits10.rs
@@ -2,7 +2,6 @@ trait Foo // where
// Self: Sized,
{
fn get(self) -> i32;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
fn test(self) -> i32 {
self.get()
diff --git a/gcc/testsuite/rust/compile/torture/traits18.rs b/gcc/testsuite/rust/compile/torture/traits18.rs
index 77cc5c2aefe..63319dd2daa 100644
--- a/gcc/testsuite/rust/compile/torture/traits18.rs
+++ b/gcc/testsuite/rust/compile/torture/traits18.rs
@@ -1,8 +1,5 @@
trait Foo<'a> {}
trait Bar {
- // { dg-warning "unused name .Bar." "" { target *-*-* } .-1 }
-
type Item: for<'a> Foo<'a>;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
diff --git a/gcc/testsuite/rust/compile/torture/traits2.rs b/gcc/testsuite/rust/compile/torture/traits2.rs
index 6df369de59a..fc6eb6002e0 100644
--- a/gcc/testsuite/rust/compile/torture/traits2.rs
+++ b/gcc/testsuite/rust/compile/torture/traits2.rs
@@ -1,6 +1,5 @@
trait Foo {
fn bar() -> i32;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct Test<T>(T);
diff --git a/gcc/testsuite/rust/compile/torture/traits3.rs b/gcc/testsuite/rust/compile/torture/traits3.rs
index 2ab74e1e181..deeb81e0946 100644
--- a/gcc/testsuite/rust/compile/torture/traits3.rs
+++ b/gcc/testsuite/rust/compile/torture/traits3.rs
@@ -1,7 +1,5 @@
pub trait Foo {
fn Bar(self) -> i32;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Foo::Bar." "" { target *-*-* } .-2 }
}
struct Baz;
@@ -10,7 +8,6 @@ struct Baz;
impl Foo for Baz {
fn Bar(self) -> i32 {
// { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .<Baz as Foo>::Bar." "" { target *-*-* } .-2 }
123
}
}
diff --git a/gcc/testsuite/rust/compile/torture/traits4.rs b/gcc/testsuite/rust/compile/torture/traits4.rs
index 10d9479fb0d..67b012c11f5 100644
--- a/gcc/testsuite/rust/compile/torture/traits4.rs
+++ b/gcc/testsuite/rust/compile/torture/traits4.rs
@@ -3,9 +3,6 @@ trait Foo {
type B;
fn new(a: Self::A, b: Self::B) -> Self;
- // { dg-warning "unused name .a." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .b." "" { target *-*-* } .-2 }
- // { dg-warning "unused name .Foo::new." "" { target *-*-* } .-3 }
}
struct Baz(i32, f32);
diff --git a/gcc/testsuite/rust/compile/torture/traits5.rs b/gcc/testsuite/rust/compile/torture/traits5.rs
index 4a396a0ffa5..445b0658f5c 100644
--- a/gcc/testsuite/rust/compile/torture/traits5.rs
+++ b/gcc/testsuite/rust/compile/torture/traits5.rs
@@ -3,9 +3,6 @@ trait Foo {
type B;
fn new(a: Self::A, b: Self::B) -> Self;
- // { dg-warning "unused name .a." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .b." "" { target *-*-* } .-2 }
- // { dg-warning "unused name .Foo::new." "" { target *-*-* } .-3 }
}
struct Baz(i32, f32);
diff --git a/gcc/testsuite/rust/compile/torture/traits6.rs b/gcc/testsuite/rust/compile/torture/traits6.rs
index a69c6fd14a6..260dde3f465 100644
--- a/gcc/testsuite/rust/compile/torture/traits6.rs
+++ b/gcc/testsuite/rust/compile/torture/traits6.rs
@@ -2,8 +2,6 @@ trait Foo {
type A;
fn baz(a: Self::A) -> Self::A;
- // { dg-warning "unused name .a." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Foo::baz." "" { target *-*-* } .-2 }
}
struct Bar<T>(T);
diff --git a/gcc/testsuite/rust/compile/torture/traits7.rs b/gcc/testsuite/rust/compile/torture/traits7.rs
index a6fe5a34b6f..7bc3384ab41 100644
--- a/gcc/testsuite/rust/compile/torture/traits7.rs
+++ b/gcc/testsuite/rust/compile/torture/traits7.rs
@@ -1,10 +1,7 @@
trait Foo {
const A: i32;
- // { dg-warning "unused name .Foo::A." "" { target *-*-* } .-1 }
fn test(self);
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Foo::test." "" { target *-*-* } .-2 }
}
struct Bar;
diff --git a/gcc/testsuite/rust/compile/torture/traits8.rs b/gcc/testsuite/rust/compile/torture/traits8.rs
index 0e83a7d3163..459032fb4a2 100644
--- a/gcc/testsuite/rust/compile/torture/traits8.rs
+++ b/gcc/testsuite/rust/compile/torture/traits8.rs
@@ -7,7 +7,6 @@ struct Bar(i32);
impl Foo for Bar {
fn default() -> i32 {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
123
}
}
diff --git a/gcc/testsuite/rust/compile/torture/traits9.rs b/gcc/testsuite/rust/compile/torture/traits9.rs
index 075a2192033..89e4bf19b0c 100644
--- a/gcc/testsuite/rust/compile/torture/traits9.rs
+++ b/gcc/testsuite/rust/compile/torture/traits9.rs
@@ -1,18 +1,15 @@
trait Foo {
fn default() -> i32;
fn get(self) -> i32;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct Bar(i32);
impl Foo for Bar {
fn default() -> i32 {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
123
}
fn get(self) -> i32 {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
self.0
}
}
diff --git a/gcc/testsuite/rust/compile/torture/tuple_enum_variants.rs b/gcc/testsuite/rust/compile/torture/tuple_enum_variants.rs
index f65bd3b5c69..d953e3d89a1 100644
--- a/gcc/testsuite/rust/compile/torture/tuple_enum_variants.rs
+++ b/gcc/testsuite/rust/compile/torture/tuple_enum_variants.rs
@@ -1,8 +1,7 @@
-enum E // { dg-warning "unused name" }
-{
- T0(), // { dg-warning "unused name" }
- T1(i32), // { dg-warning "unused name" }
- T2(i32,u32) // { dg-warning "unused name" }
+enum E {
+ T0(),
+ T1(i32),
+ T2(i32, u32),
}
/* The following doesn't parse yet...
diff --git a/gcc/testsuite/rust/compile/torture/tuple_struct_unused.rs b/gcc/testsuite/rust/compile/torture/tuple_struct_unused.rs
index 26689e6d74c..8da0a50632b 100644
--- a/gcc/testsuite/rust/compile/torture/tuple_struct_unused.rs
+++ b/gcc/testsuite/rust/compile/torture/tuple_struct_unused.rs
@@ -1,6 +1,4 @@
struct Foo(i32, i32);
// { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }
-// { dg-warning "unused name" "" { target *-*-* } .-2 }
-fn main() {
-}
\ No newline at end of file
+fn main() {}
diff --git a/gcc/testsuite/rust/compile/torture/unused1.rs b/gcc/testsuite/rust/compile/torture/unused1.rs
index 74297e03c7d..db7eb8fc1fc 100644
--- a/gcc/testsuite/rust/compile/torture/unused1.rs
+++ b/gcc/testsuite/rust/compile/torture/unused1.rs
@@ -4,7 +4,6 @@ fn test() -> i32 {
fn unused() -> i32 {
// { dg-warning "function is never used: 'unused'" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
2
}
diff --git a/gcc/testsuite/rust/compile/torture/unused_struct.rs b/gcc/testsuite/rust/compile/torture/unused_struct.rs
index a282c73f186..ba9ec3250cf 100644
--- a/gcc/testsuite/rust/compile/torture/unused_struct.rs
+++ b/gcc/testsuite/rust/compile/torture/unused_struct.rs
@@ -1,6 +1,5 @@
struct Foo {
// { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
one: i32,
two: i32,
}
diff --git a/gcc/testsuite/rust/compile/traits8.rs b/gcc/testsuite/rust/compile/traits8.rs
index b25c517cac2..b22590a52bb 100644
--- a/gcc/testsuite/rust/compile/traits8.rs
+++ b/gcc/testsuite/rust/compile/traits8.rs
@@ -1,11 +1,9 @@
trait A {
fn get(self) -> f64;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
trait B {
fn get(self) -> u8;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct Foo(u8, f64);
diff --git a/gcc/testsuite/rust/execute/torture/coercion1.rs b/gcc/testsuite/rust/execute/torture/coercion1.rs
index dff98098a42..2cdb9bbca38 100644
--- a/gcc/testsuite/rust/execute/torture/coercion1.rs
+++ b/gcc/testsuite/rust/execute/torture/coercion1.rs
@@ -6,12 +6,10 @@ extern "C" {
struct Foo(i32);
trait Bar {
fn baz(&self);
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
impl Bar for Foo {
fn baz(&self) {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "%i\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/coercion2.rs b/gcc/testsuite/rust/execute/torture/coercion2.rs
index e4049546787..12dd68ff5f7 100644
--- a/gcc/testsuite/rust/execute/torture/coercion2.rs
+++ b/gcc/testsuite/rust/execute/torture/coercion2.rs
@@ -6,12 +6,10 @@ extern "C" {
struct Foo(i32);
trait Bar {
fn baz(&self);
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
impl Bar for Foo {
fn baz(&self) {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "%i\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/match2.rs b/gcc/testsuite/rust/execute/torture/match2.rs
index 4a018c13cd2..02cedf29b3c 100644
--- a/gcc/testsuite/rust/execute/torture/match2.rs
+++ b/gcc/testsuite/rust/execute/torture/match2.rs
@@ -12,7 +12,6 @@ fn inspect(f: Foo) -> i32 {
match f {
Foo::C(x) => x,
Foo::D { x, y } => y,
- // { dg-warning "unused name .x." "" { target *-*-* } .-1 }
}
}
diff --git a/gcc/testsuite/rust/execute/torture/mod1.rs b/gcc/testsuite/rust/execute/torture/mod1.rs
index 37e7ce33162..700393850af 100644
--- a/gcc/testsuite/rust/execute/torture/mod1.rs
+++ b/gcc/testsuite/rust/execute/torture/mod1.rs
@@ -1,25 +1,21 @@
mod A {
- pub mod B { // { dg-warning "unused name" }
- pub mod C { // { dg-warning "unused name" }
+ pub mod B {
+ pub mod C {
pub struct Foo {
pub f: i32,
}
impl Foo {
- pub fn new() -> Self { // { dg-warning "unused name" }
- Foo {
- f: 23i32,
- }
+ pub fn new() -> Self {
+ Foo { f: 23i32 }
}
}
}
}
}
-fn main() ->i32 {
+fn main() -> i32 {
let a = A::B::C::Foo::new();
- let b = A::B::C::Foo {
- f: -23i32,
- };
+ let b = A::B::C::Foo { f: -23i32 };
a.f + b.f
}
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_1.rs b/gcc/testsuite/rust/execute/torture/operator_overload_1.rs
index 997ab04f5f1..5a28c5f4e93 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_1.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_1.rs
@@ -8,9 +8,6 @@ pub trait Add<Rhs = Self> {
type Output;
fn add(self, rhs: Rhs) -> Self::Output;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .rhs." "" { target *-*-* } .-2 }
- // { dg-warning "unused name .Add::add." "" { target *-*-* } .-3 }
}
impl Add for i32 {
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_10.rs b/gcc/testsuite/rust/execute/torture/operator_overload_10.rs
index 23ae778a3a2..f5d45db5338 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_10.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_10.rs
@@ -8,15 +8,12 @@ pub trait Deref {
type Target;
fn deref(&self) -> &Self::Target;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Deref::deref." "" { target *-*-* } .-2 }
}
impl<T> Deref for &T {
type Target = T;
fn deref(&self) -> &T {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "imm_deref\n\0";
let b = a as *const str;
@@ -33,7 +30,6 @@ impl<T> Deref for &mut T {
type Target = T;
fn deref(&self) -> &T {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "mut_deref\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_2.rs b/gcc/testsuite/rust/execute/torture/operator_overload_2.rs
index 8d6a0739ff0..a577718451d 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_2.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_2.rs
@@ -8,9 +8,6 @@ pub trait Add<Rhs = Self> {
type Output;
fn add(self, rhs: Rhs) -> Self::Output;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .rhs." "" { target *-*-* } .-2 }
- // { dg-warning "unused name .Add::add." "" { target *-*-* } .-3 }
}
struct Foo(i32);
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_3.rs b/gcc/testsuite/rust/execute/torture/operator_overload_3.rs
index 50ff7991a30..57f58076c3e 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_3.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_3.rs
@@ -8,9 +8,6 @@ pub trait Add<Rhs = Self> {
type Output;
fn add(self, rhs: Rhs) -> Self::Output;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .rhs." "" { target *-*-* } .-2 }
- // { dg-warning "unused name .Add::add." "" { target *-*-* } .-3 }
}
impl Add for i32 {
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_4.rs b/gcc/testsuite/rust/execute/torture/operator_overload_4.rs
index 5ca5c7aec50..ce9887b2ead 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_4.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_4.rs
@@ -8,8 +8,6 @@ pub trait Neg {
type Output;
fn neg(self) -> Self::Output;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Neg::neg." "" { target *-*-* } .-2 }
}
impl Neg for i32 {
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_5.rs b/gcc/testsuite/rust/execute/torture/operator_overload_5.rs
index 5aac3ad0589..a525f743680 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_5.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_5.rs
@@ -8,8 +8,6 @@ pub trait Not {
type Output;
fn not(self) -> Self::Output;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Not::not." "" { target *-*-* } .-2 }
}
impl Not for i32 {
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_6.rs b/gcc/testsuite/rust/execute/torture/operator_overload_6.rs
index f6ad5c41316..fbd2a8fa9d3 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_6.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_6.rs
@@ -6,9 +6,6 @@ extern "C" {
#[lang = "add_assign"]
pub trait AddAssign<Rhs = Self> {
fn add_assign(&mut self, rhs: Rhs);
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .rhs." "" { target *-*-* } .-2 }
- // { dg-warning "unused name .AddAssign::add_assign." "" { target *-*-* } .-3 }
}
impl AddAssign for i32 {
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_7.rs b/gcc/testsuite/rust/execute/torture/operator_overload_7.rs
index 6ff3a8711d2..886a7010efc 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_7.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_7.rs
@@ -8,8 +8,6 @@ pub trait Deref {
type Target;
fn deref(&self) -> &Self::Target;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Deref::deref." "" { target *-*-* } .-2 }
}
impl<T> Deref for &T {
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_8.rs b/gcc/testsuite/rust/execute/torture/operator_overload_8.rs
index d853d715874..862e29a4bc6 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_8.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_8.rs
@@ -8,8 +8,6 @@ pub trait Deref {
type Target;
fn deref(&self) -> &Self::Target;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Deref::deref." "" { target *-*-* } .-2 }
}
impl<T> Deref for &T {
@@ -32,7 +30,6 @@ impl<T> Deref for &mut T {
type Target = T;
fn deref(&self) -> &T {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "mut_deref\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/operator_overload_9.rs b/gcc/testsuite/rust/execute/torture/operator_overload_9.rs
index 5c770e7a772..fd972e28ab3 100644
--- a/gcc/testsuite/rust/execute/torture/operator_overload_9.rs
+++ b/gcc/testsuite/rust/execute/torture/operator_overload_9.rs
@@ -8,15 +8,12 @@ pub trait Deref {
type Target;
fn deref(&self) -> &Self::Target;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .Deref::deref." "" { target *-*-* } .-2 }
}
impl<T> Deref for &T {
type Target = T;
fn deref(&self) -> &T {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "imm_deref\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/trait10.rs b/gcc/testsuite/rust/execute/torture/trait10.rs
index 615df42344c..e581e324bbf 100644
--- a/gcc/testsuite/rust/execute/torture/trait10.rs
+++ b/gcc/testsuite/rust/execute/torture/trait10.rs
@@ -6,12 +6,10 @@ extern "C" {
struct Foo(i32);
trait Bar {
fn baz(&self);
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
impl Bar for Foo {
fn baz(&self) {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "%i\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/trait11.rs b/gcc/testsuite/rust/execute/torture/trait11.rs
index 53a8a8e9481..283c9ecd0ed 100644
--- a/gcc/testsuite/rust/execute/torture/trait11.rs
+++ b/gcc/testsuite/rust/execute/torture/trait11.rs
@@ -5,15 +5,12 @@ extern "C" {
trait FnLike<A, R> {
fn call(&self, arg: A) -> R;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .arg." "" { target *-*-* } .-2 }
}
struct S;
impl<'a, T> FnLike<&'a T, &'a T> for S {
fn call(&self, arg: &'a T) -> &'a T {
// { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
arg
}
}
diff --git a/gcc/testsuite/rust/execute/torture/trait12.rs b/gcc/testsuite/rust/execute/torture/trait12.rs
index f14a966bfba..68b0a4014ad 100644
--- a/gcc/testsuite/rust/execute/torture/trait12.rs
+++ b/gcc/testsuite/rust/execute/torture/trait12.rs
@@ -5,8 +5,6 @@ extern "C" {
trait FnLike<A, R> {
fn call(&self, arg: A) -> R;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .arg." "" { target *-*-* } .-2 }
}
type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b;
@@ -16,7 +14,6 @@ struct Identity;
impl<'a, T> FnLike<&'a T, &'a T> for Identity {
fn call(&self, arg: &'a T) -> &'a T {
// { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name" "" { target *-*-* } .-2 }
arg
}
}
diff --git a/gcc/testsuite/rust/execute/torture/trait13.rs b/gcc/testsuite/rust/execute/torture/trait13.rs
index 76fb09cae82..3071da27a6a 100644
--- a/gcc/testsuite/rust/execute/torture/trait13.rs
+++ b/gcc/testsuite/rust/execute/torture/trait13.rs
@@ -6,7 +6,6 @@ extern "C" {
struct Foo(i32);
trait Bar {
fn baz(&self);
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
fn qux(&self) {
// { dg-warning "unused name" "" { target *-*-* } .-1 }
@@ -22,7 +21,6 @@ trait Bar {
impl Bar for Foo {
fn baz(&self) {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "%i\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/trait4.rs b/gcc/testsuite/rust/execute/torture/trait4.rs
index 8c9b7409c20..8c0d257cd7e 100644
--- a/gcc/testsuite/rust/execute/torture/trait4.rs
+++ b/gcc/testsuite/rust/execute/torture/trait4.rs
@@ -6,12 +6,10 @@ extern "C" {
struct Foo(i32);
trait Bar {
fn baz(&self);
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
impl Bar for Foo {
fn baz(&self) {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "%i\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/trait5.rs b/gcc/testsuite/rust/execute/torture/trait5.rs
index f25784a1ebb..49f11a6085a 100644
--- a/gcc/testsuite/rust/execute/torture/trait5.rs
+++ b/gcc/testsuite/rust/execute/torture/trait5.rs
@@ -6,12 +6,10 @@ extern "C" {
struct Foo(i32);
trait Bar {
fn baz(&self);
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
impl Bar for Foo {
fn baz(&self) {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
unsafe {
let a = "%i\n\0";
let b = a as *const str;
diff --git a/gcc/testsuite/rust/execute/torture/trait6.rs b/gcc/testsuite/rust/execute/torture/trait6.rs
index 54023d291fe..c83d6666c87 100644
--- a/gcc/testsuite/rust/execute/torture/trait6.rs
+++ b/gcc/testsuite/rust/execute/torture/trait6.rs
@@ -7,7 +7,6 @@ pub trait Foo {
type A;
fn bar(self) -> Self::A;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct S(i32);
@@ -15,7 +14,6 @@ impl Foo for S {
type A = i32;
fn bar(self) -> Self::A {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
self.0
}
}
diff --git a/gcc/testsuite/rust/execute/torture/trait7.rs b/gcc/testsuite/rust/execute/torture/trait7.rs
index 059ba15b69d..064f88d5de9 100644
--- a/gcc/testsuite/rust/execute/torture/trait7.rs
+++ b/gcc/testsuite/rust/execute/torture/trait7.rs
@@ -7,7 +7,6 @@ pub trait Foo {
type A;
fn bar(self) -> Self::A;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct S(i32);
@@ -15,7 +14,6 @@ impl Foo for S {
type A = i32;
fn bar(self) -> Self::A {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
self.0
}
}
diff --git a/gcc/testsuite/rust/execute/torture/trait8.rs b/gcc/testsuite/rust/execute/torture/trait8.rs
index da8a560388e..14392ff0cca 100644
--- a/gcc/testsuite/rust/execute/torture/trait8.rs
+++ b/gcc/testsuite/rust/execute/torture/trait8.rs
@@ -7,7 +7,6 @@ pub trait Foo {
type A;
fn bar(&self) -> Self::A;
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
}
struct S(i32);
@@ -15,7 +14,6 @@ impl Foo for S {
type A = i32;
fn bar(&self) -> Self::A {
- // { dg-warning "unused name" "" { target *-*-* } .-1 }
self.0
}
}
diff --git a/gcc/testsuite/rust/execute/torture/trait9.rs b/gcc/testsuite/rust/execute/torture/trait9.rs
index 1fe77e3a60c..c0e6d36f183 100644
--- a/gcc/testsuite/rust/execute/torture/trait9.rs
+++ b/gcc/testsuite/rust/execute/torture/trait9.rs
@@ -5,15 +5,12 @@ extern "C" {
trait FnLike<A, R> {
fn call(&self, arg: A) -> R;
- // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .arg." "" { target *-*-* } .-2 }
}
struct S;
impl<T> FnLike<&T, &T> for S {
fn call(&self, arg: &T) -> &T {
// { dg-warning "unused name .self." "" { target *-*-* } .-1 }
- // { dg-warning "unused name .<S as FnLike>::call." "" { target *-*-* } .-2 }
arg
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:16 [gcc/devel/rust/master] Remove old unused code pass this was too generic Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).