]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Remove Linemap::predeclared_location
authorOwen Avery <powerboat9.gamer@gmail.com>
Wed, 12 Jul 2023 17:36:15 +0000 (13:36 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:37 +0000 (18:49 +0100)
gcc/rust/ChangeLog:

* rust-linemap.h (Linemap::predeclared_location): Remove.
* backend/rust-compile-type.cc:
Replace Linemap::predeclared_location with BUILTINS_LOCATION.
* resolve/rust-name-resolver.cc: Likewise.
* typecheck/rust-hir-type-check-type.cc: Likewise.
* typecheck/rust-tyty.cc: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/backend/rust-compile-type.cc
gcc/rust/resolve/rust-name-resolver.cc
gcc/rust/rust-linemap.h
gcc/rust/typecheck/rust-hir-type-check-type.cc
gcc/rust/typecheck/rust-tyty.cc

index 76b38c58bb3805c467fc555465fafe36b4107835..0eaa7b787a05953fc7beaa04f87cd3aba7bbf3a0 100644 (file)
@@ -81,7 +81,7 @@ TyTyResolveCompile::get_implicit_enumeral_node_type (Context *ctx)
     {
       enum_node = ctx->get_backend ()->named_type (
        "enumeral", ctx->get_backend ()->integer_type (false, 64),
-       Linemap::predeclared_location ());
+       BUILTINS_LOCATION);
     }
   return enum_node;
 }
@@ -93,9 +93,8 @@ TyTyResolveCompile::get_unit_type (Context *ctx)
   if (unit_type == nullptr)
     {
       auto unit_type_node = ctx->get_backend ()->struct_type ({});
-      unit_type
-       = ctx->get_backend ()->named_type ("()", unit_type_node,
-                                          Linemap::predeclared_location ());
+      unit_type = ctx->get_backend ()->named_type ("()", unit_type_node,
+                                                  BUILTINS_LOCATION);
     }
   return unit_type;
 }
@@ -444,7 +443,7 @@ TyTyResolveCompile::visit (const TyTy::BoolType &)
   translated
     = ctx->get_backend ()->named_type ("bool",
                                       ctx->get_backend ()->bool_type (),
-                                      Linemap::predeclared_location ());
+                                      BUILTINS_LOCATION);
 }
 
 void
@@ -454,32 +453,31 @@ TyTyResolveCompile::visit (const TyTy::IntType &type)
     {
     case TyTy::IntType::I8:
       translated = ctx->get_backend ()->named_type (
-       "i8", ctx->get_backend ()->integer_type (false, 8),
-       Linemap::predeclared_location ());
+       "i8", ctx->get_backend ()->integer_type (false, 8), BUILTINS_LOCATION);
       return;
 
     case TyTy::IntType::I16:
       translated = ctx->get_backend ()->named_type (
        "i16", ctx->get_backend ()->integer_type (false, 16),
-       Linemap::predeclared_location ());
+       BUILTINS_LOCATION);
       return;
 
     case TyTy::IntType::I32:
       translated = ctx->get_backend ()->named_type (
        "i32", ctx->get_backend ()->integer_type (false, 32),
-       Linemap::predeclared_location ());
+       BUILTINS_LOCATION);
       return;
 
     case TyTy::IntType::I64:
       translated = ctx->get_backend ()->named_type (
        "i64", ctx->get_backend ()->integer_type (false, 64),
-       Linemap::predeclared_location ());
+       BUILTINS_LOCATION);
       return;
 
     case TyTy::IntType::I128:
       translated = ctx->get_backend ()->named_type (
        "i128", ctx->get_backend ()->integer_type (false, 128),
-       Linemap::predeclared_location ());
+       BUILTINS_LOCATION);
       return;
     }
 }
@@ -491,32 +489,28 @@ TyTyResolveCompile::visit (const TyTy::UintType &type)
     {
     case TyTy::UintType::U8:
       translated = ctx->get_backend ()->named_type (
-       "u8", ctx->get_backend ()->integer_type (true, 8),
-       Linemap::predeclared_location ());
+       "u8", ctx->get_backend ()->integer_type (true, 8), BUILTINS_LOCATION);
       return;
 
     case TyTy::UintType::U16:
       translated = ctx->get_backend ()->named_type (
-       "u16", ctx->get_backend ()->integer_type (true, 16),
-       Linemap::predeclared_location ());
+       "u16", ctx->get_backend ()->integer_type (true, 16), BUILTINS_LOCATION);
       return;
 
     case TyTy::UintType::U32:
       translated = ctx->get_backend ()->named_type (
-       "u32", ctx->get_backend ()->integer_type (true, 32),
-       Linemap::predeclared_location ());
+       "u32", ctx->get_backend ()->integer_type (true, 32), BUILTINS_LOCATION);
       return;
 
     case TyTy::UintType::U64:
       translated = ctx->get_backend ()->named_type (
-       "u64", ctx->get_backend ()->integer_type (true, 64),
-       Linemap::predeclared_location ());
+       "u64", ctx->get_backend ()->integer_type (true, 64), BUILTINS_LOCATION);
       return;
 
     case TyTy::UintType::U128:
       translated = ctx->get_backend ()->named_type (
        "u128", ctx->get_backend ()->integer_type (true, 128),
-       Linemap::predeclared_location ());
+       BUILTINS_LOCATION);
       return;
     }
 }
@@ -530,14 +524,14 @@ TyTyResolveCompile::visit (const TyTy::FloatType &type)
       translated
        = ctx->get_backend ()->named_type ("f32",
                                           ctx->get_backend ()->float_type (32),
-                                          Linemap::predeclared_location ());
+                                          BUILTINS_LOCATION);
       return;
 
     case TyTy::FloatType::F64:
       translated
        = ctx->get_backend ()->named_type ("f64",
                                           ctx->get_backend ()->float_type (64),
-                                          Linemap::predeclared_location ());
+                                          BUILTINS_LOCATION);
       return;
     }
 }
@@ -549,7 +543,7 @@ TyTyResolveCompile::visit (const TyTy::USizeType &)
     "usize",
     ctx->get_backend ()->integer_type (
       true, ctx->get_backend ()->get_pointer_size ()),
-    Linemap::predeclared_location ());
+    BUILTINS_LOCATION);
 }
 
 void
@@ -559,7 +553,7 @@ TyTyResolveCompile::visit (const TyTy::ISizeType &)
     "isize",
     ctx->get_backend ()->integer_type (
       false, ctx->get_backend ()->get_pointer_size ()),
-    Linemap::predeclared_location ());
+    BUILTINS_LOCATION);
 }
 
 void
@@ -568,7 +562,7 @@ TyTyResolveCompile::visit (const TyTy::CharType &)
   translated
     = ctx->get_backend ()->named_type ("char",
                                       ctx->get_backend ()->wchar_type (),
-                                      Linemap::predeclared_location ());
+                                      BUILTINS_LOCATION);
 }
 
 void
@@ -691,8 +685,7 @@ TyTyResolveCompile::visit (const TyTy::StrType &type)
 {
   tree raw_str = create_str_type_record (type);
   translated
-    = ctx->get_backend ()->named_type ("str", raw_str,
-                                      Linemap::predeclared_location ());
+    = ctx->get_backend ()->named_type ("str", raw_str, BUILTINS_LOCATION);
 }
 
 void
index 94803a550b9cb1d8037a2a34e5b01ca29cd64ca7..b5792256a4c18c0861e883704829a72b3e1ed5d3 100644 (file)
@@ -366,9 +366,8 @@ Resolver::insert_builtin_types (Rib *r)
       CanonicalPath builtin_path
        = CanonicalPath::new_seg (builtin->get_node_id (),
                                  builtin->as_string ());
-      r->insert_name (builtin_path, builtin->get_node_id (),
-                     Linemap::predeclared_location (), false,
-                     Rib::ItemType::Type,
+      r->insert_name (builtin_path, builtin->get_node_id (), BUILTINS_LOCATION,
+                     false, Rib::ItemType::Type,
                      [] (const CanonicalPath &, NodeId, Location) -> void {});
     }
 }
@@ -436,7 +435,7 @@ Resolver::generate_builtins ()
     = TyTy::TupleType::get_unit_type (mappings->get_next_hir_id ());
   std::vector<std::unique_ptr<AST::Type> > elems;
   AST::TupleType *unit_type
-    = new AST::TupleType (std::move (elems), Linemap::predeclared_location ());
+    = new AST::TupleType (std::move (elems), BUILTINS_LOCATION);
   builtins.push_back (unit_type);
   tyctx->insert_builtin (unit_tyty->get_ref (), unit_type->get_node_id (),
                         unit_tyty);
@@ -446,15 +445,13 @@ Resolver::generate_builtins ()
 void
 Resolver::setup_builtin (const std::string &name, TyTy::BaseType *tyty)
 {
-  AST::PathIdentSegment seg (name, Linemap::predeclared_location ());
+  AST::PathIdentSegment seg (name, BUILTINS_LOCATION);
   auto typePath = ::std::unique_ptr<AST::TypePathSegment> (
-    new AST::TypePathSegment (::std::move (seg), false,
-                             Linemap::predeclared_location ()));
+    new AST::TypePathSegment (::std::move (seg), false, BUILTINS_LOCATION));
   ::std::vector< ::std::unique_ptr<AST::TypePathSegment> > segs;
   segs.push_back (::std::move (typePath));
   auto builtin_type
-    = new AST::TypePath (::std::move (segs), Linemap::predeclared_location (),
-                        false);
+    = new AST::TypePath (::std::move (segs), BUILTINS_LOCATION, false);
   builtins.push_back (builtin_type);
   tyctx->insert_builtin (tyty->get_ref (), builtin_type->get_node_id (), tyty);
   mappings->insert_node_to_hir (builtin_type->get_node_id (), tyty->get_ref ());
index 6d159e77102f28e5d7fcea88376e36a071fb7af6..219bf1de1e6083a5a2b31bfd976f6dc725e79019 100644 (file)
@@ -60,9 +60,6 @@ public:
   // access some virtual functions without explicitly passing around
   // an instance of Linemap.
 
-  // Return the special Location used for predeclared identifiers.
-  static Location predeclared_location () { return BUILTINS_LOCATION; }
-
   // Produce a human-readable description of a Location, e.g.
   // "foo.rust:10". Returns an empty string for predeclared, builtin or
   // unknown locations.
index be4c47920acbe1c3374ad54630e6804df4dc9986..24ef25c88e988e144143a2519972b989dcc9bf11 100644 (file)
@@ -730,8 +730,7 @@ TypeResolveGenericParam::visit (HIR::TypeParam &param)
                                      implicit_id,
                                      param.get_mappings ().get_local_defid ());
       implicit_self_bound
-       = new HIR::TypePath (mappings, {}, Linemap::predeclared_location (),
-                            false);
+       = new HIR::TypePath (mappings, {}, BUILTINS_LOCATION, false);
     }
 
   // resolve the bounds
index b64d0cccac80a6ee38a3dd325a114eef0e8f3fb9..848d0c718a7a1c5c7ce26dd0ec6e482378d14eea 100644 (file)
@@ -1822,7 +1822,7 @@ TupleType::TupleType (HirId ref, HirId ty_ref, Location locus,
 TupleType *
 TupleType::get_unit_type (HirId ref)
 {
-  return new TupleType (ref, Linemap::predeclared_location ());
+  return new TupleType (ref, BUILTINS_LOCATION);
 }
 
 size_t
@@ -2481,15 +2481,13 @@ SliceType::handle_substitions (SubstitutionArgumentMappings &mappings)
 
 BoolType::BoolType (HirId ref, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::BOOL,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
 BoolType::BoolType (HirId ref, HirId ty_ref, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::BOOL,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
@@ -2534,16 +2532,14 @@ BoolType::clone () const
 
 IntType::IntType (HirId ref, IntKind kind, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::INT,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     int_kind (kind)
 {}
 
 IntType::IntType (HirId ref, HirId ty_ref, IntKind kind, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::INT,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     int_kind (kind)
 {}
@@ -2620,8 +2616,7 @@ IntType::is_equal (const BaseType &other) const
 
 UintType::UintType (HirId ref, UintKind kind, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::UINT,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     uint_kind (kind)
 {}
@@ -2629,8 +2624,7 @@ UintType::UintType (HirId ref, UintKind kind, std::set<HirId> refs)
 UintType::UintType (HirId ref, HirId ty_ref, UintKind kind,
                    std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::UINT,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     uint_kind (kind)
 {}
@@ -2707,8 +2701,7 @@ UintType::is_equal (const BaseType &other) const
 
 FloatType::FloatType (HirId ref, FloatKind kind, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::FLOAT,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     float_kind (kind)
 {}
@@ -2716,8 +2709,7 @@ FloatType::FloatType (HirId ref, FloatKind kind, std::set<HirId> refs)
 FloatType::FloatType (HirId ref, HirId ty_ref, FloatKind kind,
                      std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::FLOAT,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     float_kind (kind)
 {}
@@ -2788,15 +2780,13 @@ FloatType::is_equal (const BaseType &other) const
 
 USizeType::USizeType (HirId ref, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::USIZE,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
 USizeType::USizeType (HirId ref, HirId ty_ref, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::USIZE,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
@@ -2841,15 +2831,13 @@ USizeType::clone () const
 
 ISizeType::ISizeType (HirId ref, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::ISIZE,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
 ISizeType::ISizeType (HirId ref, HirId ty_ref, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::ISIZE,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
@@ -2894,15 +2882,13 @@ ISizeType::clone () const
 
 CharType::CharType (HirId ref, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::CHAR,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
 CharType::CharType (HirId ref, HirId ty_ref, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::CHAR,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
@@ -2948,8 +2934,7 @@ CharType::clone () const
 ReferenceType::ReferenceType (HirId ref, TyVar base, Mutability mut,
                              std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::REF,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     base (base), mut (mut)
 {}
@@ -2957,8 +2942,7 @@ ReferenceType::ReferenceType (HirId ref, TyVar base, Mutability mut,
 ReferenceType::ReferenceType (HirId ref, HirId ty_ref, TyVar base,
                              Mutability mut, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::REF,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     base (base), mut (mut)
 {}
@@ -3106,8 +3090,7 @@ ReferenceType::handle_substitions (SubstitutionArgumentMappings &mappings)
 PointerType::PointerType (HirId ref, TyVar base, Mutability mut,
                          std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::POINTER,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     base (base), mut (mut)
 {}
@@ -3115,8 +3098,7 @@ PointerType::PointerType (HirId ref, TyVar base, Mutability mut,
 PointerType::PointerType (HirId ref, HirId ty_ref, TyVar base, Mutability mut,
                          std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::POINTER,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     base (base), mut (mut)
 {}
@@ -3446,15 +3428,13 @@ ParamType::is_implicit_self_trait () const
 
 StrType::StrType (HirId ref, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::STR,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
 StrType::StrType (HirId ref, HirId ty_ref, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::STR,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
@@ -3505,15 +3485,13 @@ StrType::is_equal (const BaseType &other) const
 
 NeverType::NeverType (HirId ref, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::NEVER,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
 NeverType::NeverType (HirId ref, HirId ty_ref, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::NEVER,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs)
 {}
 
@@ -3559,8 +3537,7 @@ NeverType::clone () const
 PlaceholderType::PlaceholderType (std::string symbol, HirId ref,
                                  std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::PLACEHOLDER,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     symbol (symbol)
 {}
@@ -3568,8 +3545,7 @@ PlaceholderType::PlaceholderType (std::string symbol, HirId ref,
 PlaceholderType::PlaceholderType (std::string symbol, HirId ref, HirId ty_ref,
                                  std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::PLACEHOLDER,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     symbol (symbol)
 {}
@@ -3674,8 +3650,7 @@ ProjectionType::ProjectionType (
   std::vector<SubstitutionParamMapping> subst_refs,
   SubstitutionArgumentMappings generic_arguments, std::set<HirId> refs)
   : BaseType (ref, ref, TypeKind::PROJECTION,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     SubstitutionRef (std::move (subst_refs), std::move (generic_arguments)),
     base (base), trait (trait), item (item)
@@ -3687,8 +3662,7 @@ ProjectionType::ProjectionType (
   std::vector<SubstitutionParamMapping> subst_refs,
   SubstitutionArgumentMappings generic_arguments, std::set<HirId> refs)
   : BaseType (ref, ty_ref, TypeKind::PROJECTION,
-             {Resolver::CanonicalPath::create_empty (),
-              Linemap::predeclared_location ()},
+             {Resolver::CanonicalPath::create_empty (), BUILTINS_LOCATION},
              refs),
     SubstitutionRef (std::move (subst_refs), std::move (generic_arguments)),
     base (base), trait (trait), item (item)