diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index 46343c2796eb..fe0eecb1f29a 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -44,8 +44,9 @@ class ResolveToplevelImplItem : public ResolverBase resolver->get_name_scope ().insert ( path, constant.get_node_id (), constant.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (constant.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (constant.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); resolver->insert_new_definition (constant.get_node_id (), Definition{constant.get_node_id (), @@ -59,8 +60,9 @@ class ResolveToplevelImplItem : public ResolverBase resolver->get_name_scope ().insert ( path, function.get_node_id (), function.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (function.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (function.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); resolver->insert_new_definition (function.get_node_id (), Definition{function.get_node_id (), @@ -74,8 +76,9 @@ class ResolveToplevelImplItem : public ResolverBase resolver->get_name_scope ().insert ( path, method.get_node_id (), method.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (method.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (method.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); resolver->insert_new_definition (method.get_node_id (), Definition{method.get_node_id (), diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index 2550c3953622..fa3f8a52cc51 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -45,8 +45,9 @@ class ResolveTopLevel : public ResolverBase CanonicalPath (alias.get_new_type_name ()), alias.get_node_id (), alias.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (alias.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (alias.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); } @@ -56,8 +57,9 @@ class ResolveTopLevel : public ResolverBase CanonicalPath (struct_decl.get_identifier ()), struct_decl.get_node_id (), struct_decl.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (struct_decl.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (struct_decl.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); } @@ -67,8 +69,9 @@ class ResolveTopLevel : public ResolverBase CanonicalPath (struct_decl.get_identifier ()), struct_decl.get_node_id (), struct_decl.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (struct_decl.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (struct_decl.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); } @@ -78,8 +81,9 @@ class ResolveTopLevel : public ResolverBase CanonicalPath (var.get_identifier ()), var.get_node_id (), var.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (var.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (var.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); resolver->insert_new_definition (var.get_node_id (), Definition{var.get_node_id (), @@ -94,8 +98,9 @@ class ResolveTopLevel : public ResolverBase resolver->get_name_scope ().insert ( path, constant.get_node_id (), constant.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (constant.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (constant.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); resolver->insert_new_definition (constant.get_node_id (), Definition{constant.get_node_id (), @@ -109,8 +114,9 @@ class ResolveTopLevel : public ResolverBase resolver->get_name_scope ().insert ( path, function.get_node_id (), function.get_locus (), false, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - rust_error_at (function.get_locus (), "redefined multiple times"); - rust_error_at (locus, "was defined here"); + RichLocation r (function.get_locus ()); + r.add_range (locus); + rust_error_at (r, "redefined multiple times"); }); resolver->insert_new_definition (function.get_node_id (), Definition{function.get_node_id (), diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc index ab498c9159c7..8ec78570b497 100644 --- a/gcc/rust/rust-diagnostics.cc +++ b/gcc/rust/rust-diagnostics.cc @@ -186,6 +186,17 @@ rust_inform (const Location location, const char *fmt, ...) va_end (ap); } +// Rich Locations +void +rust_error_at (const RichLocation location, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + rust_be_error_at (location, expand_message (fmt, ap)); + va_end (ap); +} + // rust_debug uses normal printf formatting, not GCC diagnostic formatting. void diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index c67e3d4d4859..d861267fc3f0 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -48,6 +48,7 @@ // All other format specifiers are as defined by 'sprintf'. The final resulting // message is then sent to the back end via rust_be_error_at/rust_be_warning_at. +// simple location extern void rust_error_at (const Location, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); @@ -61,6 +62,11 @@ extern void rust_inform (const Location, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); +// rich locations +extern void +rust_error_at (const RichLocation, const char *fmt, ...) + RUST_ATTRIBUTE_GCC_DIAG (2, 3); + // These interfaces provide a way for the front end to ask for // the open/close quote characters it should use when formatting // diagnostics (warnings, errors). @@ -78,6 +84,8 @@ rust_close_quote (); extern void rust_be_error_at (const Location, const std::string &errmsg); extern void +rust_be_error_at (const RichLocation, const std::string &errmsg); +extern void rust_be_warning_at (const Location, int opt, const std::string &warningmsg); extern void rust_be_fatal_error (const Location, const std::string &errmsg); diff --git a/gcc/rust/rust-gcc-diagnostics.cc b/gcc/rust/rust-gcc-diagnostics.cc index 37e5066001b8..11da6a3d4cce 100644 --- a/gcc/rust/rust-gcc-diagnostics.cc +++ b/gcc/rust/rust-gcc-diagnostics.cc @@ -50,6 +50,13 @@ rust_be_inform (const Location location, const std::string &infomsg) inform (gcc_loc, "%s", infomsg.c_str ()); } +void +rust_be_error_at (const RichLocation location, const std::string &errmsg) +{ + rich_location gcc_loc = location.get (); + error_at (&gcc_loc, "%s", errmsg.c_str ()); +} + void rust_be_get_quotechars (const char **open_qu, const char **close_qu) { diff --git a/gcc/rust/rust-linemap.cc b/gcc/rust/rust-linemap.cc index 606e8069277f..79c97acff79f 100644 --- a/gcc/rust/rust-linemap.cc +++ b/gcc/rust/rust-linemap.cc @@ -175,3 +175,46 @@ rust_get_linemap () { return new Gcc_linemap; } + +RichLocation::RichLocation (Location root) + : gcc_rich_loc (line_table, root.gcc_location ()) +{ + /*rich_location (line_maps *set, location_t loc, + const range_label *label = NULL);*/ +} + +RichLocation::~RichLocation () {} + +void +RichLocation::add_range (Location loc) +{ + gcc_rich_loc.add_range (loc.gcc_location ()); +} + +void +RichLocation::add_fixit_insert_before (const std::string &new_parent) +{ + gcc_rich_loc.add_fixit_insert_before (new_parent.c_str ()); +} + +void +RichLocation::add_fixit_insert_before (Location where, + const std::string &new_parent) +{ + gcc_rich_loc.add_fixit_insert_before (where.gcc_location (), + new_parent.c_str ()); +} + +void +RichLocation::add_fixit_insert_after (const std::string &new_parent) +{ + gcc_rich_loc.add_fixit_insert_after (new_parent.c_str ()); +} + +void +RichLocation::add_fixit_insert_after (Location where, + const std::string &new_parent) +{ + gcc_rich_loc.add_fixit_insert_after (where.gcc_location (), + new_parent.c_str ()); +} diff --git a/gcc/rust/rust-location.h b/gcc/rust/rust-location.h index 934576242d2c..4fd61cc01390 100644 --- a/gcc/rust/rust-location.h +++ b/gcc/rust/rust-location.h @@ -80,4 +80,26 @@ operator- (Location lhs, location_t rhs) return lhs; } +class RichLocation +{ +public: + RichLocation (Location root); + ~RichLocation (); + + void add_range (Location loc); + + void add_fixit_insert_before (const std::string &new_parent); + + void add_fixit_insert_before (Location where, const std::string &new_parent); + + void add_fixit_insert_after (const std::string &new_parent); + + void add_fixit_insert_after (Location where, const std::string &new_parent); + + rich_location get () const { return gcc_rich_loc; } + +private: + rich_location gcc_rich_loc; +}; + #endif // !defined(RUST_LOCATION_H) diff --git a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h index b0071c3ee6f0..63095949d2d3 100644 --- a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h +++ b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h @@ -189,18 +189,17 @@ class OverlappingImplItemPass : public TypeCheckBase void collision_detected (HIR::InherentImplItem *query, HIR::InherentImplItem *dup, const std::string &name) { - Location qlocus; + Location qlocus; // query bool ok = GetLocusFromImplItem::Resolve (query, qlocus); rust_assert (ok); - Location dlocus; + Location dlocus; // dup ok = GetLocusFromImplItem::Resolve (dup, dlocus); rust_assert (ok); - // this needs GCC Rich locations see - // https://github.com/Rust-GCC/gccrs/issues/97 - rust_error_at (qlocus, "duplicate definitions with name %s", name.c_str ()); - rust_error_at (dlocus, "duplicate def associated with"); + RichLocation r (qlocus); + r.add_range (dlocus); + rust_error_at (r, "duplicate definitions with name %s", name.c_str ()); } private: @@ -209,9 +208,6 @@ class OverlappingImplItemPass : public TypeCheckBase std::map > > impl_mappings; - - std::map > - possible_colliding_impls; }; } // namespace Resolver diff --git a/gcc/rust/typecheck/rust-hir-path-probe.h b/gcc/rust/typecheck/rust-hir-path-probe.h index a83856516136..5dda90a2e092 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.h +++ b/gcc/rust/typecheck/rust-hir-path-probe.h @@ -129,31 +129,34 @@ class ReportMultipleCandidateError : private TypeCheckBase static void Report (std::vector &candidates, const HIR::PathIdentSegment &query, Location query_locus) { - rust_error_at (query_locus, "multiple applicable items in scope for: %s", - query.as_string ().c_str ()); - - ReportMultipleCandidateError visitor; + RichLocation r (query_locus); + ReportMultipleCandidateError visitor (r); for (auto &c : candidates) c.impl_item->accept_vis (visitor); + + rust_error_at (r, "multiple applicable items in scope for: %s", + query.as_string ().c_str ()); } void visit (HIR::ConstantItem &constant) override { - rust_error_at (constant.get_locus (), "possible candidate"); + r.add_range (constant.get_locus ()); } void visit (HIR::Function &function) override { - rust_error_at (function.get_locus (), "possible candidate"); + r.add_range (function.get_locus ()); } void visit (HIR::Method &method) override { - rust_error_at (method.get_locus (), "possible candidate"); + r.add_range (method.get_locus ()); } private: - ReportMultipleCandidateError () : TypeCheckBase () {} + ReportMultipleCandidateError (RichLocation &r) : TypeCheckBase (), r (r) {} + + RichLocation &r; }; } // namespace Resolver diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h index bdc6df30e7b2..6b6eed07df89 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.h +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h @@ -290,11 +290,7 @@ class TypeCheckExpr : public TypeCheckBase auto result = lhs->unify (rhs); if (result->get_kind () == TyTy::TypeKind::ERROR) - { - rust_error_at (expr.get_locus (), - "type resolution failure in AssignmentExpr"); - return; - } + return; // in the case of declare first for an ADT Type: // diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.h b/gcc/rust/typecheck/rust-hir-type-check-stmt.h index e52368a67657..e0e7adcd75c6 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-stmt.h +++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.h @@ -76,11 +76,7 @@ class TypeCheckStmt : public TypeCheckBase { auto unified_ty = specified_ty->unify (init_expr_ty); if (unified_ty->get_kind () == TyTy::TypeKind::ERROR) - { - rust_fatal_error (stmt.get_locus (), - "failure in setting up let stmt type"); - return; - } + return; context->insert_type (stmt.get_mappings (), unified_ty); } diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h index c23cbc1a749d..03fe0d85abca 100644 --- a/gcc/rust/typecheck/rust-tyty-rules.h +++ b/gcc/rust/typecheck/rust-tyty-rules.h @@ -109,7 +109,10 @@ class BaseRules : public TyVisitor virtual void visit (TupleType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -117,7 +120,10 @@ class BaseRules : public TyVisitor virtual void visit (ADTType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -125,7 +131,10 @@ class BaseRules : public TyVisitor virtual void visit (InferType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -133,7 +142,10 @@ class BaseRules : public TyVisitor virtual void visit (FnType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -141,7 +153,10 @@ class BaseRules : public TyVisitor virtual void visit (FnPtr &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -149,7 +164,10 @@ class BaseRules : public TyVisitor virtual void visit (ArrayType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -157,7 +175,10 @@ class BaseRules : public TyVisitor virtual void visit (BoolType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -165,7 +186,10 @@ class BaseRules : public TyVisitor virtual void visit (IntType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -173,7 +197,10 @@ class BaseRules : public TyVisitor virtual void visit (UintType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -181,7 +208,10 @@ class BaseRules : public TyVisitor virtual void visit (USizeType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -189,7 +219,10 @@ class BaseRules : public TyVisitor virtual void visit (ISizeType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -197,7 +230,10 @@ class BaseRules : public TyVisitor virtual void visit (FloatType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -205,7 +241,10 @@ class BaseRules : public TyVisitor virtual void visit (ErrorType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -213,7 +252,10 @@ class BaseRules : public TyVisitor virtual void visit (CharType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -221,7 +263,10 @@ class BaseRules : public TyVisitor virtual void visit (ReferenceType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -229,7 +274,10 @@ class BaseRules : public TyVisitor virtual void visit (ParamType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } @@ -237,7 +285,10 @@ class BaseRules : public TyVisitor virtual void visit (StrType &type) override { Location ref_locus = mappings->lookup_location (type.get_ref ()); - rust_error_at (ref_locus, "expected [%s] got [%s]", + Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); + RichLocation r (ref_locus); + r.add_range (base_locus); + rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), type.as_string ().c_str ()); } diff --git a/gcc/testsuite/rust.test/xfail_compile/arrays1.rs b/gcc/testsuite/rust.test/xfail_compile/arrays1.rs index ee844a60182a..714a6be7afb5 100644 --- a/gcc/testsuite/rust.test/xfail_compile/arrays1.rs +++ b/gcc/testsuite/rust.test/xfail_compile/arrays1.rs @@ -1,5 +1,4 @@ fn main() { let xs: [i32; 5] = [1, 2, 3, 4, 5]; let a: bool = xs[0]; // { dg-error "expected .bool. got .i32." } - // { dg-error "failure in setting up let stmt type" "" { target { *-*-* } } .-1 } } diff --git a/gcc/testsuite/rust.test/xfail_compile/arrays2.rs b/gcc/testsuite/rust.test/xfail_compile/arrays2.rs index 69d362d8c8f0..31ae1e230945 100644 --- a/gcc/testsuite/rust.test/xfail_compile/arrays2.rs +++ b/gcc/testsuite/rust.test/xfail_compile/arrays2.rs @@ -1,5 +1,4 @@ fn main() { let array: [i32; 5] = [1, 2, 3]; // { dg-error "mismatch in array capacity" } - // { dg-error "expected ..i32:5.. got ..i32:3.." "" { target { *-*-* } } .-1 } - // { dg-error "failure in setting up let stmt type" "" { target { *-*-* } } .-2 } + // { dg-error "expected ..i32:5.. got ..i32:3.." "" { target { *-*-* } } .-1 } } diff --git a/gcc/testsuite/rust.test/xfail_compile/bad_type1.rs b/gcc/testsuite/rust.test/xfail_compile/bad_type1.rs index 336661ee028d..93de439704fd 100644 --- a/gcc/testsuite/rust.test/xfail_compile/bad_type1.rs +++ b/gcc/testsuite/rust.test/xfail_compile/bad_type1.rs @@ -1,4 +1,3 @@ fn main() { let logical: bool = 123; // { dg-error "expected .bool. got .." } - // { dg-error "failure in setting up let stmt type" "" { target { *-*-* } } .-1 } } diff --git a/gcc/testsuite/rust.test/xfail_compile/bad_type2.rs b/gcc/testsuite/rust.test/xfail_compile/bad_type2.rs index b596189061ed..e47b8aac0e7c 100644 --- a/gcc/testsuite/rust.test/xfail_compile/bad_type2.rs +++ b/gcc/testsuite/rust.test/xfail_compile/bad_type2.rs @@ -9,7 +9,6 @@ fn main() { let mut x; x = 1; x = true; // { dg-error "expected .. got .bool." } - // { dg-error "type resolution failure in AssignmentExpr" "" { target { *-*-* } } .-1 } let call_test = test(1); } diff --git a/gcc/testsuite/rust.test/xfail_compile/generics1.rs b/gcc/testsuite/rust.test/xfail_compile/generics1.rs index 7f2493ded45d..7042099b4593 100644 --- a/gcc/testsuite/rust.test/xfail_compile/generics1.rs +++ b/gcc/testsuite/rust.test/xfail_compile/generics1.rs @@ -6,6 +6,6 @@ fn main() { let a2: GenericStruct; a2 = GenericStruct::<_>(1, 456); - let b2: i32 = a2.0; // { dg-error "failure in setting up let stmt type" } + let b2: i32 = a2.0; let c2: usize = a2.1; } diff --git a/gcc/testsuite/rust.test/xfail_compile/generics2.rs b/gcc/testsuite/rust.test/xfail_compile/generics2.rs index d7a1b50ff321..eb53c2415eeb 100644 --- a/gcc/testsuite/rust.test/xfail_compile/generics2.rs +++ b/gcc/testsuite/rust.test/xfail_compile/generics2.rs @@ -6,6 +6,6 @@ fn main() { let a2: GenericStruct; a2 = GenericStruct(1, 456); - let b2: i32 = a2.0; // { dg-error "failure in setting up let stmt type" } + let b2: i32 = a2.0; let c2: usize = a2.1; } diff --git a/gcc/testsuite/rust.test/xfail_compile/generics3.rs b/gcc/testsuite/rust.test/xfail_compile/generics3.rs index 14bcc59bd139..bc49a656356c 100644 --- a/gcc/testsuite/rust.test/xfail_compile/generics3.rs +++ b/gcc/testsuite/rust.test/xfail_compile/generics3.rs @@ -5,6 +5,6 @@ fn main() { let a2; a2 = GenericStruct::(1, 456); - let b2: i32 = a2.0; // { dg-error "failure in setting up let stmt type" } + let b2: i32 = a2.0; let c2: usize = a2.1; } diff --git a/gcc/testsuite/rust.test/xfail_compile/generics7.rs b/gcc/testsuite/rust.test/xfail_compile/generics7.rs index d8a9e93e13f2..78b6149437cf 100644 --- a/gcc/testsuite/rust.test/xfail_compile/generics7.rs +++ b/gcc/testsuite/rust.test/xfail_compile/generics7.rs @@ -1,4 +1,3 @@ -// { dg-excess-errors "Noisy error and debug" } struct Foo { a: A, } @@ -16,7 +15,7 @@ impl Foo { } impl Foo { - fn bar(self) -> T { + fn bar(self) -> T { // { dg-error "duplicate definitions with name bar" } self.a } } diff --git a/gcc/testsuite/rust.test/xfail_compile/redef_error1.rs b/gcc/testsuite/rust.test/xfail_compile/redef_error1.rs index bb9d19cb5c1c..ae51e36c87f4 100644 --- a/gcc/testsuite/rust.test/xfail_compile/redef_error1.rs +++ b/gcc/testsuite/rust.test/xfail_compile/redef_error1.rs @@ -1,4 +1,4 @@ -struct S1 { // { dg-error "was defined here" } +struct S1 { x: f64, y: f64, } diff --git a/gcc/testsuite/rust.test/xfail_compile/redef_error2.rs b/gcc/testsuite/rust.test/xfail_compile/redef_error2.rs index 013404861fb3..65793bcda8a2 100644 --- a/gcc/testsuite/rust.test/xfail_compile/redef_error2.rs +++ b/gcc/testsuite/rust.test/xfail_compile/redef_error2.rs @@ -1,4 +1,4 @@ -const TEST: i32 = 2; // { dg-error "was defined here" } -const TEST: f32 = 3.0; // { dg-error "redefined multiple times" } +const TEST: i32 = 2; +const TEST: f32 = 3.0; // { dg-error "redefined multiple times" } fn main() {} diff --git a/gcc/testsuite/rust.test/xfail_compile/redef_error3.rs b/gcc/testsuite/rust.test/xfail_compile/redef_error3.rs index 32cea6ef8dcb..a4bf1ed3d8ce 100644 --- a/gcc/testsuite/rust.test/xfail_compile/redef_error3.rs +++ b/gcc/testsuite/rust.test/xfail_compile/redef_error3.rs @@ -1,4 +1,4 @@ -fn test() -> bool { // { dg-error "was defined here" } +fn test() -> bool { true } diff --git a/gcc/testsuite/rust.test/xfail_compile/redef_error4.rs b/gcc/testsuite/rust.test/xfail_compile/redef_error4.rs index 648534676b77..a250c0ac00e2 100644 --- a/gcc/testsuite/rust.test/xfail_compile/redef_error4.rs +++ b/gcc/testsuite/rust.test/xfail_compile/redef_error4.rs @@ -5,7 +5,7 @@ impl Foo { Foo(a, b) } - fn test() -> i32 { // { dg-error "was defined here" } + fn test() -> i32 { test() } diff --git a/gcc/testsuite/rust.test/xfail_compile/redef_error5.rs b/gcc/testsuite/rust.test/xfail_compile/redef_error5.rs index 4ca37c675a73..dc6ad50e1045 100644 --- a/gcc/testsuite/rust.test/xfail_compile/redef_error5.rs +++ b/gcc/testsuite/rust.test/xfail_compile/redef_error5.rs @@ -1,7 +1,7 @@ struct Foo(i32, bool); impl Foo { - const TEST: i32 = 123; // { dg-error "was defined here" } + const TEST: i32 = 123; const TEST: bool = false; // { dg-error "redefined multiple times" } } diff --git a/gcc/testsuite/rust.test/xfail_compile/redef_error6.rs b/gcc/testsuite/rust.test/xfail_compile/redef_error6.rs index ef7e35763492..664c6ae9894c 100644 --- a/gcc/testsuite/rust.test/xfail_compile/redef_error6.rs +++ b/gcc/testsuite/rust.test/xfail_compile/redef_error6.rs @@ -1,4 +1,3 @@ -// { dg-excess-errors "Noisy error and debug" } struct Foo(T, usize); impl Foo { @@ -6,8 +5,7 @@ impl Foo { 123 } - fn test(self) -> i32 { - // { dg-error "redefined multiple times" "" { target *-*-* } .-1 } + fn test(self) -> i32 { // { dg-error "redefined multiple times" } self.0 } } diff --git a/gcc/testsuite/rust.test/xfail_compile/tuple1.rs b/gcc/testsuite/rust.test/xfail_compile/tuple1.rs index 67a33f41295f..84179b137272 100644 --- a/gcc/testsuite/rust.test/xfail_compile/tuple1.rs +++ b/gcc/testsuite/rust.test/xfail_compile/tuple1.rs @@ -1,4 +1,3 @@ -// { dg-excess-errors "Noisy error and debug" } fn main() { let a: (i32, bool) = (123, 123); // { dg-error "expected .bool. got .." } let b; diff --git a/gcc/testsuite/rust.test/xfail_compile/type-alias1.rs b/gcc/testsuite/rust.test/xfail_compile/type-alias1.rs index 53b49234b6a5..c7d7048246a9 100644 --- a/gcc/testsuite/rust.test/xfail_compile/type-alias1.rs +++ b/gcc/testsuite/rust.test/xfail_compile/type-alias1.rs @@ -1,4 +1,3 @@ -// { dg-excess-errors "Noisy error and debug" } type TypeAlias = (i32, u32); fn main() {