diff options
71 files changed, 298 insertions, 276 deletions
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index b33d90e..2f52931 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 3fefd8d..4bade5c 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 6d50c3f..03e3c2e 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-item.cc b/gcc/rust/backend/rust-compile-item.cc index d42cc1e..21cbb1c 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -73,6 +73,10 @@ CompileItem::visit (HIR::StaticItem &var) void CompileItem::visit (HIR::ConstantItem &constant) { + if (ctx->lookup_const_decl (constant.get_mappings ().get_hirid (), + &reference)) + return; + // resolve the type TyTy::BaseType *resolved_type = nullptr; bool ok diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index e41ee7f..09f3860 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/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index 0f69fb0..ad34253 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -81,6 +81,7 @@ public: bool ok = ctx->get_tyctx ()->lookup_type ( stmt.get_init_expr ()->get_mappings ().get_hirid (), &actual); rust_assert (ok); + tree stmt_type = TyTyResolveCompile::compile (ctx, ty); Location lvalue_locus = stmt.get_pattern ()->get_locus (); Location rvalue_locus = stmt.get_init_expr ()->get_locus (); @@ -90,8 +91,14 @@ public: auto fnctx = ctx->peek_fn (); if (ty->is_unit ()) { - // FIXME this feels wrong ctx->add_statement (init); + + auto unit_type_init_expr + = ctx->get_backend ()->constructor_expression (stmt_type, false, {}, + -1, rvalue_locus); + auto s = ctx->get_backend ()->init_statement (fnctx.fndecl, var, + unit_type_init_expr); + ctx->add_statement (s); } else { diff --git a/gcc/rust/backend/rust-compile-tyty.h b/gcc/rust/backend/rust-compile-tyty.h index a3720f8..52ad2f9 100644 --- a/gcc/rust/backend/rust-compile-tyty.h +++ b/gcc/rust/backend/rust-compile-tyty.h @@ -54,10 +54,10 @@ public: void visit (TyTy::TupleType &type) override { - if (type.num_fields () == 0) - translated = backend->unit_type (); - else - gcc_unreachable (); + // this interface is only for unit-type the -type interface takes into + // account the context + rust_assert (type.num_fields () == 0); + translated = backend->unit_type (); } void visit (TyTy::ArrayType &) override { gcc_unreachable (); } diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt index 794a667..86a063f 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-marklive.h b/gcc/rust/lint/rust-lint-marklive.h index 8a77661..d0ab2b4 100644 --- a/gcc/rust/lint/rust-lint-marklive.h +++ b/gcc/rust/lint/rust-lint-marklive.h @@ -262,6 +262,12 @@ public: stct.get_struct_base ()->base_struct->accept_vis (*this); } + void visit (HIR::Module &module) override + { + for (auto &item : module.get_items ()) + item->accept_vis (*this); + } + private: std::vector<HirId> worklist; std::set<HirId> liveSymbols; diff --git a/gcc/rust/lint/rust-lint-scan-deadcode.h b/gcc/rust/lint/rust-lint-scan-deadcode.h index 7bb166a..00114f2 100644 --- a/gcc/rust/lint/rust-lint-scan-deadcode.h +++ b/gcc/rust/lint/rust-lint-scan-deadcode.h @@ -81,9 +81,11 @@ public: HirId hirId = stct.get_mappings ().get_hirid (); if (should_warn (hirId)) { - rust_warning_at (stct.get_locus (), 0, - "struct is never constructed: %<%s%>", - stct.get_identifier ().c_str ()); + bool name_starts_underscore = stct.get_identifier ().at (0) == '_'; + if (!name_starts_underscore) + rust_warning_at (stct.get_locus (), 0, + "struct is never constructed: %<%s%>", + stct.get_identifier ().c_str ()); } else { @@ -124,6 +126,12 @@ public: } } + void visit (HIR::Module &mod) override + { + for (auto &item : mod.get_items ()) + item->accept_vis (*this); + } + private: std::set<HirId> live_symbols; Resolver::Resolver *resolver; 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 0000000..d4317e5 --- /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 0000000..6fabfef --- /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 6c0fc42..0000000 --- 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 dfdfe8a5..70c07c1 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, @@ -122,7 +128,7 @@ public: static tree unit_type; if (unit_type == nullptr) { - auto unit_type_node = integer_type (true, 0); + auto unit_type_node = struct_type ({}); unit_type = named_type ("()", unit_type_node, ::Linemap::predeclared_location ()); } @@ -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 54a6443..396f35f 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 a62c6ca..a56be9a 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 41c3b51..b7368ba 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 e5ed911..9f2f220 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 0d4b4c7..bf181df 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 bc02e2a..962d875 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 cc781d8..9eb598f 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 d6fbc0c..e51a407 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 924b30c..4c98b86 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 85ea2f7..0de45a8 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 ef40e18..fea8631 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 9aa00fe..2e5a81f 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 218095c..09a7226 100644 --- a/gcc/testsuite/rust/compile/torture/mod-nameresolve.rs +++ b/gcc/testsuite/rust/compile/torture/mod-nameresolve.rs @@ -1,5 +1,5 @@ -mod foo { // { dg-warning "unused name" } - struct A; // { dg-warning "unused name" } +mod foo { + 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 ca272f7..651678c 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 6a2d1ed..04722a9 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 4c6d660..466f7ee 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 d4b2de8..2b2746a 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 18e2779..9035773 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 a492ec3..a029270 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 77cc5c2..63319dd 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 6df369d..fc6eb60 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 2ab74e1..deeb81e 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 10d9479..67b012c 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 4a396a0..445b065 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 a69c6fd..260dde3 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 a6fe5a3..7bc3384 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 0e83a7d..459032f 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 075a219..89e4bf1 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 f65bd3b..d953e3d 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 26689e6..8da0a50 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 74297e0..db7eb8f 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 a282c73..ba9ec32 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 b25c517..b22590a 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 dff9809..2cdb9bb 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 e404954..12dd68f 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 4a018c1..02cedf2 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 37e7ce3..7003938 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 997ab04..5a28c5f 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 23ae778..f5d45db 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 8d6a073..a577718 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 50ff799..57f5807 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 5ca5c7a..ce9887b 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 5aac3ad..a525f74 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 f6ad5c4..fbd2a8f 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 6ff3a87..886a701 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 d853d71..862e29a 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 5c770e7..fd972e2 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 615df423..e581e32 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 53a8a8e..283c9ec 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 f14a966..68b0a40 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 76fb09c..3071da2 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 8c9b740..8c0d257 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 f25784a..49f11a6 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 54023d2..c83d666 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 059ba15..064f88d 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 da8a560..14392ff 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 1fe77e3..c0e6d36 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 } } |