Browse Source

Implement proposal #3927. (#3963)

Change syntax for package declaration to put the `impl` keyword at the
start and remove the `api` keyword.

To support this, rearrange processing of package, library, and import
declarations to use the general modifier handling support in declaration
parsing rather than special-case logic.

There is an ambiguity in `impl package.Foo as Bar`, which we resolve by
treating `package` as an introducer after a modifier only if it's not
followed by `.`.
Richard Smith 1 year ago
parent
commit
23f9065949
100 changed files with 346 additions and 342 deletions
  1. 1 1
      core/prelude.carbon
  2. 1 1
      core/prelude/operators.carbon
  3. 1 1
      core/prelude/operators/arithmetic.carbon
  4. 1 1
      core/prelude/operators/bitwise.carbon
  5. 1 1
      core/prelude/operators/comparison.carbon
  6. 1 1
      core/prelude/types.carbon
  7. 1 1
      core/prelude/types/i32.carbon
  8. 3 5
      toolchain/check/check.cpp
  9. 12 5
      toolchain/check/decl_state.h
  10. 20 21
      toolchain/check/handle_import_and_package.cpp
  11. 6 6
      toolchain/check/testdata/alias/no_prelude/export_name.carbon
  12. 6 6
      toolchain/check/testdata/alias/no_prelude/import.carbon
  13. 2 2
      toolchain/check/testdata/alias/no_prelude/import_order.carbon
  14. 5 5
      toolchain/check/testdata/as/adapter_conversion.carbon
  15. 2 2
      toolchain/check/testdata/basics/multifile.carbon
  16. 2 2
      toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon
  17. 2 2
      toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon
  18. 6 6
      toolchain/check/testdata/basics/type_literals.carbon
  19. 2 2
      toolchain/check/testdata/builtins/bool/make_type.carbon
  20. 1 1
      toolchain/check/testdata/builtins/float/add.carbon
  21. 1 1
      toolchain/check/testdata/builtins/float/div.carbon
  22. 1 1
      toolchain/check/testdata/builtins/float/eq.carbon
  23. 3 3
      toolchain/check/testdata/builtins/float/make_type.carbon
  24. 1 1
      toolchain/check/testdata/builtins/float/mul.carbon
  25. 1 1
      toolchain/check/testdata/builtins/float/negate.carbon
  26. 1 1
      toolchain/check/testdata/builtins/float/neq.carbon
  27. 1 1
      toolchain/check/testdata/builtins/float/sub.carbon
  28. 1 1
      toolchain/check/testdata/builtins/int/eq.carbon
  29. 1 1
      toolchain/check/testdata/builtins/int/left_shift.carbon
  30. 2 2
      toolchain/check/testdata/builtins/int/make_type_32.carbon
  31. 5 5
      toolchain/check/testdata/builtins/int/make_type_signed.carbon
  32. 5 5
      toolchain/check/testdata/builtins/int/make_type_unsigned.carbon
  33. 2 2
      toolchain/check/testdata/builtins/int/right_shift.carbon
  34. 2 2
      toolchain/check/testdata/builtins/int/sadd.carbon
  35. 2 2
      toolchain/check/testdata/builtins/int/sdiv.carbon
  36. 2 2
      toolchain/check/testdata/builtins/int/smod.carbon
  37. 1 1
      toolchain/check/testdata/builtins/int/smul.carbon
  38. 2 2
      toolchain/check/testdata/builtins/int/snegate.carbon
  39. 1 1
      toolchain/check/testdata/builtins/int/ssub.carbon
  40. 2 2
      toolchain/check/testdata/builtins/int/uadd.carbon
  41. 2 2
      toolchain/check/testdata/builtins/int/udiv.carbon
  42. 2 2
      toolchain/check/testdata/builtins/int/umod.carbon
  43. 1 1
      toolchain/check/testdata/builtins/int/umul.carbon
  44. 2 2
      toolchain/check/testdata/builtins/int/unegate.carbon
  45. 1 1
      toolchain/check/testdata/builtins/int/usub.carbon
  46. 2 2
      toolchain/check/testdata/class/adapt.carbon
  47. 7 7
      toolchain/check/testdata/class/cross_package_import.carbon
  48. 4 4
      toolchain/check/testdata/class/extend_adapt.carbon
  49. 20 20
      toolchain/check/testdata/class/extern.carbon
  50. 4 4
      toolchain/check/testdata/class/fail_adapt_bad_decl.carbon
  51. 1 1
      toolchain/check/testdata/class/fail_adapt_bad_type.carbon
  52. 3 3
      toolchain/check/testdata/class/fail_adapt_with_subobjects.carbon
  53. 2 2
      toolchain/check/testdata/class/fail_import_misuses.carbon
  54. 6 6
      toolchain/check/testdata/class/fail_redeclaration_introducer.carbon
  55. 4 4
      toolchain/check/testdata/class/generic/call.carbon
  56. 3 3
      toolchain/check/testdata/class/generic/import.carbon
  57. 6 6
      toolchain/check/testdata/class/generic/redeclare.carbon
  58. 2 2
      toolchain/check/testdata/class/import.carbon
  59. 2 2
      toolchain/check/testdata/class/import_base.carbon
  60. 2 2
      toolchain/check/testdata/class/import_forward_decl.carbon
  61. 7 7
      toolchain/check/testdata/class/import_indirect.carbon
  62. 2 2
      toolchain/check/testdata/class/import_member_cycle.carbon
  63. 2 2
      toolchain/check/testdata/class/import_struct_cyle.carbon
  64. 2 2
      toolchain/check/testdata/class/init_adapt.carbon
  65. 3 3
      toolchain/check/testdata/class/no_prelude/export_name.carbon
  66. 17 17
      toolchain/check/testdata/class/no_prelude/implicit_import.carbon
  67. 2 2
      toolchain/check/testdata/const/import.carbon
  68. 1 1
      toolchain/check/testdata/function/builtin/call_from_operator.carbon
  69. 1 1
      toolchain/check/testdata/function/builtin/import.carbon
  70. 13 13
      toolchain/check/testdata/function/declaration/import.carbon
  71. 3 3
      toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon
  72. 3 3
      toolchain/check/testdata/function/declaration/no_prelude/extern.carbon
  73. 2 2
      toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon
  74. 12 12
      toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon
  75. 6 6
      toolchain/check/testdata/function/definition/import.carbon
  76. 4 4
      toolchain/check/testdata/function/definition/no_prelude/extern.carbon
  77. 24 24
      toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon
  78. 4 4
      toolchain/check/testdata/function/generic/redeclare.carbon
  79. 2 2
      toolchain/check/testdata/if_expr/fail_partial_constant.carbon
  80. 1 1
      toolchain/check/testdata/impl/lookup/import.carbon
  81. 1 1
      toolchain/check/testdata/impl/lookup/no_prelude/import.carbon
  82. 2 2
      toolchain/check/testdata/impl/no_prelude/import_self.carbon
  83. 3 3
      toolchain/check/testdata/interface/no_prelude/export_name.carbon
  84. 2 2
      toolchain/check/testdata/interface/no_prelude/import.carbon
  85. 2 2
      toolchain/check/testdata/let/fail_generic_import.carbon
  86. 2 2
      toolchain/check/testdata/let/generic_import.carbon
  87. 2 2
      toolchain/check/testdata/let/import.carbon
  88. 2 2
      toolchain/check/testdata/namespace/add_to_import.carbon
  89. 2 2
      toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon
  90. 2 2
      toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon
  91. 2 2
      toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon
  92. 3 3
      toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon
  93. 3 3
      toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon
  94. 2 2
      toolchain/check/testdata/namespace/imported.carbon
  95. 5 5
      toolchain/check/testdata/namespace/imported_indirect.carbon
  96. 3 3
      toolchain/check/testdata/namespace/merging.carbon
  97. 2 2
      toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon
  98. 2 2
      toolchain/check/testdata/operators/overloaded/add.carbon
  99. 2 2
      toolchain/check/testdata/operators/overloaded/bit_and.carbon
  100. 2 2
      toolchain/check/testdata/operators/overloaded/bit_complement.carbon

+ 1 - 1
core/prelude.carbon

@@ -4,7 +4,7 @@
 //
 // AUTOUPDATE
 
-package Core library "prelude" api;
+package Core library "prelude";
 
 import library "prelude/operators";
 import library "prelude/types";

+ 1 - 1
core/prelude/operators.carbon

@@ -2,7 +2,7 @@
 // Exceptions. See /LICENSE for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-package Core library "prelude/operators" api;
+package Core library "prelude/operators";
 
 // TODO: Add a mechanism to re-export the names declared here.
 import library "prelude/operators/arithmetic";

+ 1 - 1
core/prelude/operators/arithmetic.carbon

@@ -2,7 +2,7 @@
 // Exceptions. See /LICENSE for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-package Core library "prelude/operators/arithmetic" api;
+package Core library "prelude/operators/arithmetic";
 
 // Addition: `a + b`.
 interface Add {

+ 1 - 1
core/prelude/operators/bitwise.carbon

@@ -2,7 +2,7 @@
 // Exceptions. See /LICENSE for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-package Core library "prelude/operators/bitwise" api;
+package Core library "prelude/operators/bitwise";
 
 // Bit complement: `^a`.
 interface BitComplement {

+ 1 - 1
core/prelude/operators/comparison.carbon

@@ -2,7 +2,7 @@
 // Exceptions. See /LICENSE for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-package Core library "prelude/operators/comparison" api;
+package Core library "prelude/operators/comparison";
 
 // Equality comparison: `a == b` and `a != b`.
 interface Eq {

+ 1 - 1
core/prelude/types.carbon

@@ -2,7 +2,7 @@
 // Exceptions. See /LICENSE for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-package Core library "prelude/types" api;
+package Core library "prelude/types";
 
 // TODO: Add a mechanism to re-export the names declared here.
 

+ 1 - 1
core/prelude/types/i32.carbon

@@ -2,7 +2,7 @@
 // Exceptions. See /LICENSE for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-package Core library "prelude/types/i32" api;
+package Core library "prelude/types/i32";
 
 import library "prelude/operators";
 

+ 3 - 5
toolchain/check/check.cpp

@@ -963,8 +963,7 @@ static auto TrackImport(
                         "Explicit import of `api` from `impl` file is "
                         "redundant with implicit import.");
       CARBON_DIAGNOSTIC(ImportSelf, Error, "File cannot import itself.");
-      bool is_impl =
-          !packaging || packaging->api_or_impl == Parse::Tree::ApiOrImpl::Impl;
+      bool is_impl = !packaging || packaging->is_impl;
       unit_info.emitter.Emit(import.node_id,
                              is_impl ? ExplicitImportApi : ImportSelf);
       return;
@@ -1073,8 +1072,7 @@ static auto BuildApiMapAndDiagnosePackaging(
       continue;
     }
 
-    bool is_impl =
-        packaging && packaging->api_or_impl == Parse::Tree::ApiOrImpl::Impl;
+    bool is_impl = packaging && packaging->is_impl;
 
     // Add to the `api` map and diagnose duplicates. This occurs before the
     // file extension check because we might emit both diagnostics in situations
@@ -1153,7 +1151,7 @@ auto CheckParseTrees(llvm::MutableArrayRef<Unit> units, bool prelude_import,
   ready_to_check.reserve(units.size());
   for (auto& unit_info : unit_infos) {
     const auto& packaging = unit_info.unit->parse_tree->packaging_decl();
-    if (packaging && packaging->api_or_impl == Parse::Tree::ApiOrImpl::Impl) {
+    if (packaging && packaging->is_impl) {
       // An `impl` has an implicit import of its `api`.
       auto implicit_names = packaging->names;
       implicit_names.package_id = IdentifierId::Invalid;

+ 12 - 5
toolchain/check/decl_state.h

@@ -30,10 +30,11 @@ enum class KeywordModifierSet : uint32_t {
   Abstract = 1 << 3,
   Base = 1 << 4,
   Default = 1 << 5,
-  Extend = 1 << 6,
-  Final = 1 << 7,
-  Impl = 1 << 8,
-  Virtual = 1 << 9,
+  Export = 1 << 6,
+  Extend = 1 << 7,
+  Final = 1 << 8,
+  Impl = 1 << 9,
+  Virtual = 1 << 10,
 
   // Sets of modifiers:
   Access = Private | Protected,
@@ -41,7 +42,7 @@ enum class KeywordModifierSet : uint32_t {
   Method = Abstract | Impl | Virtual,
   ImplDecl = Extend | Final,
   Interface = Default | Final,
-  Decl = Class | Method | ImplDecl | Interface,
+  Decl = Class | Method | ImplDecl | Interface | Export,
   None = 0,
 
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Virtual)
@@ -59,6 +60,10 @@ static_assert(!(KeywordModifierSet::Access & KeywordModifierSet::Extern) &&
                   !((KeywordModifierSet::Access | KeywordModifierSet::Extern) &
                     KeywordModifierSet::Decl),
               "Order-related sets must not overlap");
+static_assert(~KeywordModifierSet::None ==
+                  (KeywordModifierSet::Access | KeywordModifierSet::Extern |
+                   KeywordModifierSet::Decl),
+              "Modifier missing from all modifier sets");
 
 // State stored for each declaration we are currently in: the kind of
 // declaration and the keyword modifiers that apply to that declaration.
@@ -74,9 +79,11 @@ struct DeclState {
     Export,
     Fn,
     Impl,
+    Import,
     Interface,
     Let,
     Namespace,
+    PackageOrLibrary,
     Var
   };
 

+ 20 - 21
toolchain/check/handle_import_and_package.cpp

@@ -3,44 +3,53 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 #include "toolchain/check/context.h"
+#include "toolchain/check/decl_state.h"
+#include "toolchain/check/modifiers.h"
 
 namespace Carbon::Check {
 
 // `import` and `package` are structured by parsing. As a consequence, no
 // checking logic is needed here.
 
-auto HandleImportIntroducer(Context& /*context*/,
+auto HandleImportIntroducer(Context& context,
                             Parse::ImportIntroducerId /*node_id*/) -> bool {
+  context.decl_state_stack().Push(DeclState::Import);
   return true;
 }
 
-auto HandleImportExport(Context& /*context*/, Parse::ImportExportId /*node_id*/)
+auto HandleImportDecl(Context& context, Parse::ImportDeclId /*node_id*/)
     -> bool {
+  LimitModifiersOnDecl(context, KeywordModifierSet::Export,
+                       Lex::TokenKind::Import);
+  context.decl_state_stack().Pop(DeclState::Import);
   return true;
 }
 
-auto HandleImportDecl(Context& /*context*/, Parse::ImportDeclId /*node_id*/)
-    -> bool {
-  return true;
-}
-
-auto HandleLibraryIntroducer(Context& /*context*/,
+auto HandleLibraryIntroducer(Context& context,
                              Parse::LibraryIntroducerId /*node_id*/) -> bool {
+  context.decl_state_stack().Push(DeclState::PackageOrLibrary);
   return true;
 }
 
-auto HandleLibraryDecl(Context& /*context*/, Parse::LibraryDeclId /*node_id*/)
+auto HandleLibraryDecl(Context& context, Parse::LibraryDeclId /*node_id*/)
     -> bool {
+  LimitModifiersOnDecl(context, KeywordModifierSet::Impl,
+                       Lex::TokenKind::Library);
+  context.decl_state_stack().Pop(DeclState::PackageOrLibrary);
   return true;
 }
 
-auto HandlePackageIntroducer(Context& /*context*/,
+auto HandlePackageIntroducer(Context& context,
                              Parse::PackageIntroducerId /*node_id*/) -> bool {
+  context.decl_state_stack().Push(DeclState::PackageOrLibrary);
   return true;
 }
 
-auto HandlePackageDecl(Context& /*context*/, Parse::PackageDeclId /*node_id*/)
+auto HandlePackageDecl(Context& context, Parse::PackageDeclId /*node_id*/)
     -> bool {
+  LimitModifiersOnDecl(context, KeywordModifierSet::Impl,
+                       Lex::TokenKind::Package);
+  context.decl_state_stack().Pop(DeclState::PackageOrLibrary);
   return true;
 }
 
@@ -64,14 +73,4 @@ auto HandleDefaultLibrary(Context& /*context*/,
   return true;
 }
 
-auto HandlePackageApi(Context& /*context*/, Parse::PackageApiId /*node_id*/)
-    -> bool {
-  return true;
-}
-
-auto HandlePackageImpl(Context& /*context*/, Parse::PackageImplId /*node_id*/)
-    -> bool {
-  return true;
-}
-
 }  // namespace Carbon::Check

+ 6 - 6
toolchain/check/testdata/alias/no_prelude/export_name.carbon

@@ -10,14 +10,14 @@
 
 // --- base.carbon
 
-library "base" api;
+library "base";
 
 class C {}
 alias D = C;
 
 // --- export.carbon
 
-library "export" api;
+library "export";
 
 import library "base";
 
@@ -25,7 +25,7 @@ export D;
 
 // --- export_orig.carbon
 
-library "export_orig" api;
+library "export_orig";
 
 import library "base";
 
@@ -37,7 +37,7 @@ export C;
 
 // --- use_export.carbon
 
-library "use_export" api;
+library "use_export";
 
 import library "export";
 
@@ -45,7 +45,7 @@ var d: D = {};
 
 // --- fail_orig_name_not_in_export.carbon
 
-library "fail_orig_name_not_in_export" api;
+library "fail_orig_name_not_in_export";
 
 import library "export";
 
@@ -56,7 +56,7 @@ var c: C = {};
 
 // --- indirect_compat.carbon
 
-library "indirect_compat" api;
+library "indirect_compat";
 
 import library "export";
 import library "export_orig";

+ 6 - 6
toolchain/check/testdata/alias/no_prelude/import.carbon

@@ -6,7 +6,7 @@
 
 // --- class1.carbon
 
-library "class1" api;
+library "class1";
 
 class C {}
 
@@ -16,7 +16,7 @@ var a: C*;
 
 // --- class2.carbon
 
-library "class2" api;
+library "class2";
 
 import library "class1";
 
@@ -26,7 +26,7 @@ var b: c_alias*;
 
 // --- class3.carbon
 
-library "class3" api;
+library "class3";
 
 import library "class2";
 
@@ -34,7 +34,7 @@ var c: c_alias_alias*;
 
 // --- var1.carbon
 
-library "var1" api;
+library "var1";
 
 var a: () = ();
 
@@ -42,7 +42,7 @@ alias a_alias = a;
 
 // --- var2.carbon
 
-library "var2" api;
+library "var2";
 
 import library "var1";
 
@@ -52,7 +52,7 @@ var b: () = a_alias;
 
 // --- fail_var3.carbon
 
-library "var3" api;
+library "var3";
 
 // CHECK:STDERR: fail_var3.carbon:[[@LINE+6]]:1: In import.
 // CHECK:STDERR: import library "var2";

+ 2 - 2
toolchain/check/testdata/alias/no_prelude/import_order.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 class C { var v: (); }
 alias a = C;
@@ -16,7 +16,7 @@ alias d = c;
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 5 - 5
toolchain/check/testdata/as/adapter_conversion.carbon

@@ -6,7 +6,7 @@
 
 // --- adapt_class.carbon
 
-library "adapt_class" api;
+library "adapt_class";
 
 class A {
   var x: i32;
@@ -32,7 +32,7 @@ var b_factory: B = A.Make() as B;
 
 // --- adapt_i32.carbon
 
-library "adapt_i32" api;
+library "adapt_i32";
 
 class A {
   adapt i32;
@@ -43,7 +43,7 @@ let n: i32 = a as i32;
 
 // --- multi_level_adapt.carbon
 
-library "multi_level_adapt" api;
+library "multi_level_adapt";
 
 class A { adapt {}; }
 class B { adapt A; }
@@ -54,7 +54,7 @@ let d: D = {} as D;
 
 // --- fail_init_class.carbon
 
-library "fail_init_class" api;
+library "fail_init_class";
 
 class A {
   var x: i32;
@@ -80,7 +80,7 @@ var b_init: B = ({.x = 1, .y = 2} as A) as B;
 
 // --- fail_adapt_init_from_struct.carbon
 
-library "fail_adapt_init_from_struct" api;
+library "fail_adapt_init_from_struct";
 
 class A {
   var x: i32;

+ 2 - 2
toolchain/check/testdata/basics/multifile.carbon

@@ -5,12 +5,12 @@
 // AUTOUPDATE
 
 // --- a.carbon
-package A api;
+package A;
 
 fn A() {}
 
 // --- b.carbon
-package B api;
+package B;
 
 fn B() {}
 

+ 2 - 2
toolchain/check/testdata/basics/no_prelude/multifile_raw_and_textual_ir.carbon

@@ -9,12 +9,12 @@
 // AUTOUPDATE
 
 // --- a.carbon
-package A api;
+package A;
 
 fn A() {}
 
 // --- b.carbon
-package B api;
+package B;
 
 fn B() {}
 

+ 2 - 2
toolchain/check/testdata/basics/no_prelude/multifile_raw_ir.carbon

@@ -9,12 +9,12 @@
 // AUTOUPDATE
 
 // --- a.carbon
-package A api;
+package A;
 
 fn A() {}
 
 // --- b.carbon
-package B api;
+package B;
 
 fn B() {}
 

+ 6 - 6
toolchain/check/testdata/basics/type_literals.carbon

@@ -5,14 +5,14 @@
 // AUTOUPDATE
 
 // --- iN.carbon
-library "iN" api;
+library "iN";
 
 var test_i8: i8;
 var test_i16: i16;
 var test_i64: i64;
 
 // --- fail_iN_bad_width.carbon
-library "fail_iN_bad_width" api;
+library "fail_iN_bad_width";
 
 // CHECK:STDERR: fail_iN_bad_width.carbon:[[@LINE+4]]:14: ERROR: Name `i0` not found.
 // CHECK:STDERR: var test_i0: i0;
@@ -42,14 +42,14 @@ var test_i1000000000: i1000000000;
 var test_i10000000000000000000: i10000000000000000000;
 
 // --- uN.carbon
-library "uN" api;
+library "uN";
 
 var test_u8: u8;
 var test_u16: u16;
 var test_u64: u64;
 
 // --- fail_uN_bad_width.carbon
-library "fail_uN_bad_width" api;
+library "fail_uN_bad_width";
 
 // CHECK:STDERR: fail_uN_bad_width.carbon:[[@LINE+4]]:14: ERROR: Name `u0` not found.
 // CHECK:STDERR: var test_u0: u0;
@@ -79,7 +79,7 @@ var test_u1000000000: u1000000000;
 var test_u10000000000000000000: u10000000000000000000;
 
 // --- fail_fN_bad_width.carbon
-library "fail_fN_bad_width" api;
+library "fail_fN_bad_width";
 
 // CHECK:STDERR: fail_fN_bad_width.carbon:[[@LINE+4]]:14: ERROR: Name `f0` not found.
 // CHECK:STDERR: var test_f0: f0;
@@ -97,7 +97,7 @@ var test_f1000000000: f1000000000;
 var test_f1000000000000: f1000000000000;
 
 // --- fail_fN_todo_unsupported.carbon
-library "fail_fN_todo_unsupported" api;
+library "fail_fN_todo_unsupported";
 
 // TODO: Some or all of these should eventually work.
 // CHECK:STDERR: fail_fN_todo_unsupported.carbon:[[@LINE+3]]:15: ERROR: Semantics TODO: `Currently only f64 is allowed`.

+ 2 - 2
toolchain/check/testdata/builtins/bool/make_type.carbon

@@ -6,13 +6,13 @@
 
 // --- types.carbon
 
-library "types" api;
+library "types";
 
 fn Bool() -> type = "bool.make_type";
 
 // --- use_types.carbon
 
-library "uses_types" api;
+library "uses_types";
 
 import library "types";
 

+ 1 - 1
toolchain/check/testdata/builtins/float/add.carbon

@@ -16,7 +16,7 @@ var x: f64 = Add(2.2, 2.3);
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.add".
 // CHECK:STDERR: fn TooFew(a: f64) -> f64 = "float.add";

+ 1 - 1
toolchain/check/testdata/builtins/float/div.carbon

@@ -18,7 +18,7 @@ let c: f64 = Div(0.0, 0.0);
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.div".
 // CHECK:STDERR: fn TooFew(a: f64) -> f64 = "float.div";

+ 1 - 1
toolchain/check/testdata/builtins/float/eq.carbon

@@ -22,7 +22,7 @@ fn RuntimeCall(a: f64, b: f64) -> bool {
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+3]]:1: ERROR: Invalid signature for builtin function "float.eq".
 // CHECK:STDERR: fn WrongResult(a: f64, b: f64) -> f64 = "float.eq";

+ 3 - 3
toolchain/check/testdata/builtins/float/make_type.carbon

@@ -6,13 +6,13 @@
 
 // --- types.carbon
 
-library "types" api;
+library "types";
 
 fn Float(size: i32) -> type = "float.make_type";
 
 // --- use_types.carbon
 
-library "uses_types" api;
+library "uses_types";
 
 import library "types";
 
@@ -24,7 +24,7 @@ fn GetFloat(dyn_size: i32) -> type {
 
 // --- fail_invalid_size.carbon
 
-library "invalid_size" api;
+library "invalid_size";
 
 import library "types";
 

+ 1 - 1
toolchain/check/testdata/builtins/float/mul.carbon

@@ -16,7 +16,7 @@ var x: f64 = Mul(2.0, 0.5);
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.mul".
 // CHECK:STDERR: fn TooFew(a: f64) -> f64 = "float.mul";

+ 1 - 1
toolchain/check/testdata/builtins/float/negate.carbon

@@ -16,7 +16,7 @@ let a: f64 = Negate(1.5);
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.negate".
 // CHECK:STDERR: fn TooFew() -> f64 = "float.negate";

+ 1 - 1
toolchain/check/testdata/builtins/float/neq.carbon

@@ -22,7 +22,7 @@ fn RuntimeCall(a: f64, b: f64) -> bool {
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+3]]:1: ERROR: Invalid signature for builtin function "float.neq".
 // CHECK:STDERR: fn WrongResult(a: f64, b: f64) -> f64 = "float.neq";

+ 1 - 1
toolchain/check/testdata/builtins/float/sub.carbon

@@ -16,7 +16,7 @@ var x: f64 = Sub(2.0, 0.5);
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.sub".
 // CHECK:STDERR: fn TooFew(a: f64) -> f64 = "float.sub";

+ 1 - 1
toolchain/check/testdata/builtins/int/eq.carbon

@@ -22,7 +22,7 @@ fn RuntimeCall(a: i32, b: i32) -> bool {
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+3]]:1: ERROR: Invalid signature for builtin function "int.eq".
 // CHECK:STDERR: fn WrongResult(a: i32, b: i32) -> i32 = "int.eq";

+ 1 - 1
toolchain/check/testdata/builtins/int/left_shift.carbon

@@ -19,7 +19,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_bad_shift.carbon
 
-package BadShift api;
+package BadShift;
 
 fn LeftShift(a: i32, b: i32) -> i32 = "int.left_shift";
 fn Negate(a: i32) -> i32 = "int.snegate";

+ 2 - 2
toolchain/check/testdata/builtins/int/make_type_32.carbon

@@ -6,13 +6,13 @@
 
 // --- types.carbon
 
-library "types" api;
+library "types";
 
 fn Int() -> type = "int.make_type_32";
 
 // --- use_types.carbon
 
-library "uses_types" api;
+library "uses_types";
 
 import library "types";
 

+ 5 - 5
toolchain/check/testdata/builtins/int/make_type_signed.carbon

@@ -6,13 +6,13 @@
 
 // --- types.carbon
 
-library "types" api;
+library "types";
 
 fn Int(n: i32) -> type = "int.make_type_signed";
 
 // --- use_types.carbon
 
-library "uses_types" api;
+library "uses_types";
 
 import library "types";
 
@@ -30,7 +30,7 @@ fn Symbolic(N:! i32, x: Int(N)) -> Int(N) {
 
 // --- fail_zero_size.carbon
 
-library "fail_zero_size" api;
+library "fail_zero_size";
 
 import library "types";
 
@@ -42,7 +42,7 @@ var n: Int(0);
 
 // --- fail_negative_size.carbon
 
-library "fail_negative_size" api;
+library "fail_negative_size";
 
 import library "types";
 
@@ -56,7 +56,7 @@ var n: Int(Negate(1));
 
 // --- fail_oversized.carbon
 
-library "fail_oversized" api;
+library "fail_oversized";
 
 import library "types";
 

+ 5 - 5
toolchain/check/testdata/builtins/int/make_type_unsigned.carbon

@@ -6,13 +6,13 @@
 
 // --- types.carbon
 
-library "types" api;
+library "types";
 
 fn UInt(n: i32) -> type = "int.make_type_unsigned";
 
 // --- use_types.carbon
 
-library "uses_types" api;
+library "uses_types";
 
 import library "types";
 
@@ -30,7 +30,7 @@ fn Symbolic(N:! i32, x: UInt(N)) -> UInt(N) {
 
 // --- fail_zero_size.carbon
 
-library "fail_zero_size" api;
+library "fail_zero_size";
 
 import library "types";
 
@@ -42,7 +42,7 @@ var n: UInt(0);
 
 // --- fail_negative_size.carbon
 
-library "fail_negative_size" api;
+library "fail_negative_size";
 
 import library "types";
 
@@ -56,7 +56,7 @@ var n: UInt(Negate(1));
 
 // --- fail_oversized.carbon
 
-library "fail_oversized" api;
+library "fail_oversized";
 
 import library "types";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/right_shift.carbon

@@ -21,7 +21,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // TODO: Also test unsigned / logical right shift.
 
-package ArithShift api;
+package ArithShift;
 
 fn RightShift(a: i32, b: i32) -> i32 = "int.right_shift";
 fn Negate(a: i32) -> i32 = "int.snegate";
@@ -36,7 +36,7 @@ let arr2_p: [i32; 3]* = &arr2;
 
 // --- fail_bad_shift.carbon
 
-package BadShift api;
+package BadShift;
 
 fn RightShift(a: i32, b: i32) -> i32 = "int.right_shift";
 fn Negate(a: i32) -> i32 = "int.snegate";

+ 2 - 2
toolchain/check/testdata/builtins/int/sadd.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "int.sadd".
 // CHECK:STDERR: fn TooFew(a: i32) -> i32 = "int.sadd";
@@ -75,7 +75,7 @@ fn RuntimeCallBadReturnType(a: i32, b: i32) -> bool {
 
 // --- fail_overflow.carbon
 
-package FailOverflow api;
+package FailOverflow;
 
 fn Add(a: i32, b: i32) -> i32 = "int.sadd";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/sdiv.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_overflow.carbon
 
-package FailOverflow api;
+package FailOverflow;
 
 fn Div(a: i32, b: i32) -> i32 = "int.sdiv";
 fn Sub(a: i32, b: i32) -> i32 = "int.ssub";
@@ -38,7 +38,7 @@ let c: i32 = Div(Sub(Negate(0x7FFF_FFFF), 1), Negate(1));
 
 // --- fail_div_by_zero.carbon
 
-package FailDivByZero api;
+package FailDivByZero;
 
 fn Div(a: i32, b: i32) -> i32 = "int.sdiv";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/smod.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_overflow.carbon
 
-package FailOverflow api;
+package FailOverflow;
 
 fn Mod(a: i32, b: i32) -> i32 = "int.smod";
 fn Sub(a: i32, b: i32) -> i32 = "int.ssub";
@@ -39,7 +39,7 @@ let c: i32 = Mod(Sub(Negate(0x7FFF_FFFF), 1), Negate(1));
 
 // --- fail_div_by_zero.carbon
 
-package FailDivByZero api;
+package FailDivByZero;
 
 fn Mod(a: i32, b: i32) -> i32 = "int.smod";
 

+ 1 - 1
toolchain/check/testdata/builtins/int/smul.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_overflow.carbon
 
-package FailOverflow api;
+package FailOverflow;
 
 fn Mul(a: i32, b: i32) -> i32 = "int.smul";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/snegate.carbon

@@ -19,7 +19,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "int.snegate".
 // CHECK:STDERR: fn TooFew() -> i32 = "int.snegate";
@@ -98,7 +98,7 @@ fn RuntimeCallBadReturnType(a: i32, b: i32) -> bool {
 
 // --- fail_overflow.carbon
 
-package FailOverflow api;
+package FailOverflow;
 
 fn Negate(a: i32) -> i32 = "int.snegate";
 fn Sub(a: i32, b: i32) -> i32 = "int.ssub";

+ 1 - 1
toolchain/check/testdata/builtins/int/ssub.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_overflow.carbon
 
-package FailOverflow api;
+package FailOverflow;
 
 fn Sub(a: i32, b: i32) -> i32 = "int.ssub";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/uadd.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "int.uadd".
 // CHECK:STDERR: fn TooFew(a: i32) -> i32 = "int.uadd";
@@ -74,7 +74,7 @@ fn RuntimeCallBadReturnType(a: i32, b: i32) -> bool {
 
 // --- overflow.carbon
 
-package Overflow api;
+package Overflow;
 
 fn Add(a: i32, b: i32) -> i32 = "int.uadd";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/udiv.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- overflow.carbon
 
-package Overflow api;
+package Overflow;
 
 fn Div(a: i32, b: i32) -> i32 = "int.udiv";
 fn Sub(a: i32, b: i32) -> i32 = "int.usub";
@@ -34,7 +34,7 @@ let c: i32 = Div(Sub(Negate(0x7FFF_FFFF), 1), Negate(1));
 
 // --- fail_div_by_zero.carbon
 
-package FailDivByZero api;
+package FailDivByZero;
 
 fn Div(a: i32, b: i32) -> i32 = "int.udiv";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/umod.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- overflow.carbon
 
-package Overflow api;
+package Overflow;
 
 fn Mod(a: i32, b: i32) -> i32 = "int.umod";
 fn Sub(a: i32, b: i32) -> i32 = "int.usub";
@@ -34,7 +34,7 @@ let c: i32 = Mod(Sub(Negate(0x7FFF_FFFF), 1), Negate(1));
 
 // --- fail_div_by_zero.carbon
 
-package FailDivByZero api;
+package FailDivByZero;
 
 fn Mod(a: i32, b: i32) -> i32 = "int.umod";
 

+ 1 - 1
toolchain/check/testdata/builtins/int/umul.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- overflow.carbon
 
-package Overflow api;
+package Overflow;
 
 fn Mul(a: i32, b: i32) -> i32 = "int.umul";
 

+ 2 - 2
toolchain/check/testdata/builtins/int/unegate.carbon

@@ -19,7 +19,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- fail_bad_decl.carbon
 
-package FailBadDecl api;
+package FailBadDecl;
 
 // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "int.unegate".
 // CHECK:STDERR: fn TooFew() -> i32 = "int.unegate";
@@ -97,7 +97,7 @@ fn RuntimeCallBadReturnType(a: i32, b: i32) -> bool {
 
 // --- overflow.carbon
 
-package Overflow api;
+package Overflow;
 
 fn Negate(a: i32) -> i32 = "int.unegate";
 fn Sub(a: i32, b: i32) -> i32 = "int.usub";

+ 1 - 1
toolchain/check/testdata/builtins/int/usub.carbon

@@ -17,7 +17,7 @@ fn RuntimeCall(a: i32, b: i32) -> i32 {
 
 // --- overflow.carbon
 
-package Overflow api;
+package Overflow;
 
 fn Sub(a: i32, b: i32) -> i32 = "int.usub";
 

+ 2 - 2
toolchain/check/testdata/class/adapt.carbon

@@ -6,7 +6,7 @@
 
 // --- basic.carbon
 
-library "basic" api;
+library "basic";
 
 class SomeClass {
   var a: i32;
@@ -23,7 +23,7 @@ class StructAdapter {
 
 // --- fail_not_extend.carbon
 
-library "fail_not_extend" api;
+library "fail_not_extend";
 
 class Adapted {
   fn F();

+ 7 - 7
toolchain/check/testdata/class/cross_package_import.carbon

@@ -10,19 +10,19 @@
 
 // --- other_define.carbon
 
-package Other library "define" api;
+package Other library "define";
 
 class C {}
 
 // --- other_extern.carbon
 
-package Other library "extern" api;
+package Other library "extern";
 
 extern class C;
 
 // --- other_conflict.carbon
 
-package Other library "conflict" api;
+package Other library "conflict";
 
 fn C() {}
 
@@ -32,7 +32,7 @@ fn C() {}
 
 // --- define.carbon
 
-library "define" api;
+library "define";
 
 import Other library "define";
 
@@ -40,7 +40,7 @@ var c: Other.C = {};
 
 // --- fail_extern.carbon
 
-library "extern" api;
+library "extern";
 
 import Other library "extern";
 
@@ -58,7 +58,7 @@ var c: Other.C = {};
 
 // --- fail_todo_merge_define_extern.carbon
 
-library "merge_define_extern" api;
+library "merge_define_extern";
 
 import Other library "define";
 // CHECK:STDERR: fail_todo_merge_define_extern.carbon:[[@LINE+12]]:1: In import.
@@ -83,7 +83,7 @@ var c: Other.C = {};
 
 // --- fail_conflict.carbon
 
-library "conflict" api;
+library "conflict";
 
 import Other library "define";
 // CHECK:STDERR: fail_conflict.carbon:[[@LINE+12]]:1: In import.

+ 4 - 4
toolchain/check/testdata/class/extend_adapt.carbon

@@ -6,7 +6,7 @@
 
 // --- basic.carbon
 
-library "basic" api;
+library "basic";
 
 class SomeClassAdapter;
 
@@ -33,7 +33,7 @@ fn TestAdapterMethod(a: SomeClassAdapter) {
 
 // --- fail_todo_method_access.carbon
 
-library "fail_todo_method_access" api;
+library "fail_todo_method_access";
 
 class SomeClass {
   fn F[self: Self]();
@@ -56,7 +56,7 @@ fn F(a: SomeClassAdapter) {
 
 // --- fail_todo_field_access.carbon
 
-library "fail_todo_field_access" api;
+library "fail_todo_field_access";
 
 class SomeClass {
   var a: i32;
@@ -77,7 +77,7 @@ fn F(a: SomeClassAdapter) -> i32 {
 
 // --- fail_todo_adapt_non_class.carbon
 
-library "fail_todo_adapt_non_class" api;
+library "fail_todo_adapt_non_class";
 
 class StructAdapter {
   // CHECK:STDERR: fail_todo_adapt_non_class.carbon:[[@LINE+3]]:3: ERROR: Semantics TODO: `extending non-class type`.

+ 20 - 20
toolchain/check/testdata/class/extern.carbon

@@ -10,25 +10,25 @@
 
 // --- decl.carbon
 
-library "decl" api;
+library "decl";
 
 class C;
 
 // --- extern_decl.carbon
 
-library "extern_decl" api;
+library "extern_decl";
 
 extern class C;
 
 // --- extern_decl_copy.carbon
 
-library "extern_decl_copy" api;
+library "extern_decl_copy";
 
 extern class C;
 
 // --- def.carbon
 
-library "def" api;
+library "def";
 
 class C {}
 
@@ -38,7 +38,7 @@ class C {}
 
 // --- fail_decl_fn_in_extern.carbon
 
-library "fail_decl_fn_in_extern" api;
+library "fail_decl_fn_in_extern";
 
 extern class C;
 // CHECK:STDERR: fail_decl_fn_in_extern.carbon:[[@LINE+7]]:4: ERROR: Cannot declare a member of incomplete class `C`.
@@ -52,7 +52,7 @@ fn C.F();
 
 // --- fail_extern_def.carbon
 
-library "fail_extern_def" api;
+library "fail_extern_def";
 
 // CHECK:STDERR: fail_extern_def.carbon:[[@LINE+4]]:1: ERROR: `extern` not allowed on `class` declaration that provides a definition.
 // CHECK:STDERR: extern class C {}
@@ -62,7 +62,7 @@ extern class C {}
 
 // --- fail_extern_decl_after_extern_decl.carbon
 
-library "fail_extern_decl_after_extern_decl" api;
+library "fail_extern_decl_after_extern_decl";
 
 extern class C;
 // CHECK:STDERR: fail_extern_decl_after_extern_decl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `class C` is redundant.
@@ -76,7 +76,7 @@ extern class C;
 
 // --- fail_decl_after_extern_decl.carbon
 
-library "fail_decl_after_extern_decl" api;
+library "fail_decl_after_extern_decl";
 
 extern class C;
 // CHECK:STDERR: fail_decl_after_extern_decl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `class C` is redundant.
@@ -90,7 +90,7 @@ class C;
 
 // --- fail_extern_member_class.carbon
 
-library "fail_extern_member_class" api;
+library "fail_extern_member_class";
 
 class C {
   // CHECK:STDERR: fail_extern_member_class.carbon:[[@LINE+4]]:3: ERROR: `extern` not allowed on `class` declaration that is a member.
@@ -102,14 +102,14 @@ class C {
 
 // --- todo_fail_def_after_extern_decl.carbon
 
-library "fail_def_after_extern_decl" api;
+library "fail_def_after_extern_decl";
 
 extern class C;
 class C {}
 
 // --- fail_extern_decl_after_decl.carbon
 
-library "fail_extern_decl_after_decl" api;
+library "fail_extern_decl_after_decl";
 
 class C;
 // CHECK:STDERR: fail_extern_decl_after_decl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `class C` is redundant.
@@ -123,7 +123,7 @@ extern class C;
 
 // --- fail_todo_import_extern_decl_then_decl.carbon
 
-library "import_extern_decl_then_decl" api;
+library "import_extern_decl_then_decl";
 
 import library "extern_decl";
 // CHECK:STDERR: fail_todo_import_extern_decl_then_decl.carbon:[[@LINE+13]]:1: In import.
@@ -143,7 +143,7 @@ import library "decl";
 
 // --- fail_todo_import_decl_then_extern_decl.carbon
 
-library "import_decl_then_extern_decl" api;
+library "import_decl_then_extern_decl";
 
 import library "decl";
 // CHECK:STDERR: fail_todo_import_decl_then_extern_decl.carbon:[[@LINE+13]]:1: In import.
@@ -163,7 +163,7 @@ import library "extern_decl";
 
 // --- fail_todo_import_extern_decl_then_def.carbon
 
-library "import_extern_decl_then_def" api;
+library "import_extern_decl_then_def";
 
 import library "extern_decl";
 // CHECK:STDERR: fail_todo_import_extern_decl_then_def.carbon:[[@LINE+13]]:1: In import.
@@ -183,7 +183,7 @@ import library "def";
 
 // --- fail_import_ownership_conflict.carbon
 
-library "fail_import_ownership_conflict" api;
+library "fail_import_ownership_conflict";
 
 import library "extern_decl";
 // CHECK:STDERR: fail_import_ownership_conflict.carbon:[[@LINE+13]]:1: In import.
@@ -217,7 +217,7 @@ import library "def";
 
 // --- fail_todo_import_extern_decl_copy.carbon
 
-library "import_extern_decl_copy" api;
+library "import_extern_decl_copy";
 
 import library "extern_decl";
 // CHECK:STDERR: fail_todo_import_extern_decl_copy.carbon:[[@LINE+12]]:1: In import.
@@ -236,7 +236,7 @@ import library "extern_decl_copy";
 
 // --- extern_decl_after_import_extern_decl.carbon
 
-library "extern_decl_after_import_extern_decl" api;
+library "extern_decl_after_import_extern_decl";
 
 import library "extern_decl";
 
@@ -244,7 +244,7 @@ extern class C;
 
 // --- decl_after_import_extern_decl.carbon
 
-library "decl_after_import_extern_decl" api;
+library "decl_after_import_extern_decl";
 
 import library "decl";
 
@@ -252,7 +252,7 @@ extern class C;
 
 // --- def_after_import_extern_decl.carbon
 
-library "def_after_import_extern_decl" api;
+library "def_after_import_extern_decl";
 
 import library "def";
 
@@ -260,7 +260,7 @@ extern class C;
 
 // --- extern_decl_after_import_def.carbon
 
-library "extern_decl_after_import_def" api;
+library "extern_decl_after_import_def";
 
 import library "def";
 

+ 4 - 4
toolchain/check/testdata/class/fail_adapt_bad_decl.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_not_type.carbon
 
-library "not_type" api;
+library "not_type";
 
 class Bad {
   // CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:3: ERROR: Cannot implicitly convert from `i32` to `type`.
@@ -24,7 +24,7 @@ fn Use(b: Bad) { b.F(); }
 
 // --- fail_extend_not_type.carbon
 
-library "extend_not_type" api;
+library "extend_not_type";
 
 class Bad {
   // CHECK:STDERR: fail_extend_not_type.carbon:[[@LINE+4]]:3: ERROR: Cannot implicitly convert from `i32` to `type`.
@@ -39,7 +39,7 @@ fn Use(b: Bad) { b.F(); }
 
 // --- fail_repeated.carbon
 
-library "fail_repeated" api;
+library "fail_repeated";
 
 class MultipleAdapts {
   adapt ();
@@ -67,7 +67,7 @@ class MultipleAdaptsSameType {
 
 // --- fail_bad_scope.carbon
 
-library "fail_bad_scope" api;
+library "fail_bad_scope";
 
 // CHECK:STDERR: fail_bad_scope.carbon:[[@LINE+4]]:1: ERROR: `adapt` declaration can only be used in a class.
 // CHECK:STDERR: adapt {};

+ 1 - 1
toolchain/check/testdata/class/fail_adapt_bad_type.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_incomplete_type.carbon
 
-library "incomplete_type" api;
+library "incomplete_type";
 
 class Incomplete;
 

+ 3 - 3
toolchain/check/testdata/class/fail_adapt_with_subobjects.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_adapt_with_base.carbon
 
-library "fail_adapt_with_base" api;
+library "fail_adapt_with_base";
 
 base class Base {}
 
@@ -24,7 +24,7 @@ class AdaptWithBase {
 
 // --- fail_adapt_with_fields.carbon
 
-library "fail_adapt_with_fields" api;
+library "fail_adapt_with_fields";
 
 class AdaptWithField {
   // CHECK:STDERR: fail_adapt_with_fields.carbon:[[@LINE+3]]:3: ERROR: Adapter cannot have fields.
@@ -54,7 +54,7 @@ class AdaptWithFields {
 
 // --- fail_adapt_with_base_and_fields.carbon
 
-library "fail_adapt_with_base_and_fields" api;
+library "fail_adapt_with_base_and_fields";
 
 base class Base {}
 

+ 2 - 2
toolchain/check/testdata/class/fail_import_misuses.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 class Empty {
 }
@@ -15,7 +15,7 @@ class Incomplete;
 
 // --- fail_b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 6 - 6
toolchain/check/testdata/class/fail_redeclaration_introducer.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_add_base.carbon
 
-library "fail_add_base" api;
+library "fail_add_base";
 
 class A;
 // CHECK:STDERR: fail_add_base.carbon:[[@LINE+7]]:1: ERROR: Class redeclared with different inheritance kind.
@@ -20,7 +20,7 @@ base class A {}
 
 // --- fail_add_abstract.carbon
 
-library "fail_add_abstract" api;
+library "fail_add_abstract";
 
 class B;
 // CHECK:STDERR: fail_add_abstract.carbon:[[@LINE+7]]:1: ERROR: Class redeclared with different inheritance kind.
@@ -34,7 +34,7 @@ abstract class B {}
 
 // --- fail_remove_base.carbon
 
-library "fail_remove_base" api;
+library "fail_remove_base";
 
 base class C;
 // CHECK:STDERR: fail_remove_base.carbon:[[@LINE+7]]:1: ERROR: Class redeclared with different inheritance kind.
@@ -48,7 +48,7 @@ class C {}
 
 // --- fail_base_to_abstract.carbon
 
-library "fail_base_to_abstract" api;
+library "fail_base_to_abstract";
 
 base class D;
 // CHECK:STDERR: fail_base_to_abstract.carbon:[[@LINE+7]]:1: ERROR: Class redeclared with different inheritance kind.
@@ -62,7 +62,7 @@ abstract class D {}
 
 // --- fail_remove_abstract.carbon
 
-library "fail_remove_abstract" api;
+library "fail_remove_abstract";
 
 abstract class E;
 // CHECK:STDERR: fail_remove_abstract.carbon:[[@LINE+7]]:1: ERROR: Class redeclared with different inheritance kind.
@@ -76,7 +76,7 @@ class E {}
 
 // --- fail_abstract_to_base.carbon
 
-library "fail_abstract_to_base" api;
+library "fail_abstract_to_base";
 
 abstract class F;
 // CHECK:STDERR: fail_abstract_to_base.carbon:[[@LINE+6]]:1: ERROR: Class redeclared with different inheritance kind.

+ 4 - 4
toolchain/check/testdata/class/generic/call.carbon

@@ -6,7 +6,7 @@
 
 // --- call.carbon
 
-library "call" api;
+library "call";
 
 class Class(T:! type, N:! i32) {}
 
@@ -17,7 +17,7 @@ var b: Class((), 0);
 
 // --- fail_too_few.carbon
 
-library "too_few" api;
+library "too_few";
 
 class Class(T:! type, N:! i32) {}
 
@@ -32,7 +32,7 @@ var a: Class(i32*);
 
 // --- fail_too_many.carbon
 
-library "too_many" api;
+library "too_many";
 
 class Class(T:! type, N:! i32) {}
 
@@ -47,7 +47,7 @@ var a: Class(i32*, 1, 2);
 
 // --- fail_no_conversion.carbon
 
-library "no_conversion" api;
+library "no_conversion";
 
 class Class(T:! type, N:! i32) {}
 

+ 3 - 3
toolchain/check/testdata/class/generic/import.carbon

@@ -6,13 +6,13 @@
 
 // --- foo.carbon
 
-library "foo" api;
+library "foo";
 
 class Class(T:! type);
 
 // --- foo.impl.carbon
 
-library "foo" impl;
+impl library "foo";
 
 class Class(T:! type) {
   var x: T;
@@ -20,7 +20,7 @@ class Class(T:! type) {
 
 // --- fail_bad_foo.impl.carbon
 
-library "foo" impl;
+impl library "foo";
 
 // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+5]]:13: ERROR: Redeclaration differs at parameter 1.
 // CHECK:STDERR: class Class(U:! type) {

+ 6 - 6
toolchain/check/testdata/class/generic/redeclare.carbon

@@ -6,7 +6,7 @@
 
 // --- valid.carbon
 
-library "valid" api;
+library "valid";
 
 class Generic(T:! type);
 
@@ -15,7 +15,7 @@ class Generic(T:! type) {
 
 // --- fail_mismatch_param_list.carbon
 
-library "mismatch_param_list" api;
+library "mismatch_param_list";
 
 class A;
 // CHECK:STDERR: fail_mismatch_param_list.carbon:[[@LINE+7]]:1: ERROR: Redeclaration differs because of parameter list.
@@ -29,7 +29,7 @@ class A(T:! type) {}
 
 // --- fail_mismatch_implicit_param_list.carbon
 
-library "implicit_mismatch_param_list" api;
+library "implicit_mismatch_param_list";
 
 class B(N:! i32);
 // CHECK:STDERR: fail_mismatch_implicit_param_list.carbon:[[@LINE+7]]:1: ERROR: Redeclaration differs because of implicit parameter list.
@@ -43,7 +43,7 @@ class B[T:! type](N:! T) {}
 
 // --- fail_mismatch_param_count.carbon
 
-library "mismatch_param_count" api;
+library "mismatch_param_count";
 
 class C(T:! type);
 // CHECK:STDERR: fail_mismatch_param_count.carbon:[[@LINE+7]]:1: ERROR: Redeclaration differs because of parameter count of 2.
@@ -57,7 +57,7 @@ class C(T:! type, U:! i32) {}
 
 // --- fail_mismatch_param_type.carbon
 
-library "mismatch_param_type" api;
+library "mismatch_param_type";
 
 class D(T:! type);
 // CHECK:STDERR: fail_mismatch_param_type.carbon:[[@LINE+7]]:9: ERROR: Redeclaration differs at parameter 1.
@@ -71,7 +71,7 @@ class D(T:! i32) {}
 
 // --- fail_mismatch_param_name.carbon
 
-library "mismatch_param_name" api;
+library "mismatch_param_name";
 
 class E(T:! type);
 // CHECK:STDERR: fail_mismatch_param_name.carbon:[[@LINE+6]]:9: ERROR: Redeclaration differs at parameter 1.

+ 2 - 2
toolchain/check/testdata/class/import.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 class Empty {
 }
@@ -26,7 +26,7 @@ class Incomplete;
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 2 - 2
toolchain/check/testdata/class/import_base.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 base class Base {
   fn F[self: Self]();
@@ -22,7 +22,7 @@ class Child {
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 2 - 2
toolchain/check/testdata/class/import_forward_decl.carbon

@@ -6,13 +6,13 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 class ForwardDecl;
 
 // --- a.impl.carbon
 
-library "a" impl;
+impl library "a";
 
 class ForwardDecl {
 }

+ 7 - 7
toolchain/check/testdata/class/import_indirect.carbon

@@ -26,13 +26,13 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 class C {}
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 
@@ -43,7 +43,7 @@ var b_ptr: D* = &b_val;
 
 // --- c.carbon
 
-library "c" api;
+library "c";
 
 import library "a";
 
@@ -58,7 +58,7 @@ var c_ptr: E* = &c_val;
 
 // --- triangle.carbon
 
-library "triangle" api;
+library "triangle";
 
 import library "a";
 import library "b";
@@ -68,7 +68,7 @@ var ptr: D* = &val;
 
 // --- triangle_reverse.carbon
 
-library "triangle_reverse" api;
+library "triangle_reverse";
 
 import library "b";
 import library "a";
@@ -78,7 +78,7 @@ var ptr: D* = &val;
 
 // --- diamond.carbon
 
-library "diamond" api;
+library "diamond";
 
 import library "b";
 import library "c";
@@ -88,7 +88,7 @@ var ptr: E* = &val;
 
 // --- diamond_reverse.carbon
 
-library "diamond_reverse" api;
+library "diamond_reverse";
 
 import library "c";
 import library "b";

+ 2 - 2
toolchain/check/testdata/class/import_member_cycle.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 class Cycle {
   var a: Cycle*;
@@ -14,7 +14,7 @@ class Cycle {
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 2 - 2
toolchain/check/testdata/class/import_struct_cyle.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 class Cycle;
 
@@ -19,7 +19,7 @@ class Cycle {
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 2 - 2
toolchain/check/testdata/class/init_adapt.carbon

@@ -6,7 +6,7 @@
 
 // --- init_adapt.carbon
 
-library "init_adapt" api;
+library "init_adapt";
 
 class C {
   var a: i32;
@@ -33,7 +33,7 @@ var e: C = MakeAdaptC() as C;
 
 // --- fail_not_implicit.carbon
 
-library "fail_not_implicit" api;
+library "fail_not_implicit";
 
 class C {
   var a: i32;

+ 3 - 3
toolchain/check/testdata/class/no_prelude/export_name.carbon

@@ -10,13 +10,13 @@
 
 // --- base.carbon
 
-library "base" api;
+library "base";
 
 class C {}
 
 // --- export.carbon
 
-library "export" api;
+library "export";
 
 import library "base";
 
@@ -28,7 +28,7 @@ export C;
 
 // --- use_export.carbon
 
-library "use_export" api;
+library "use_export";
 
 import library "export";
 

+ 17 - 17
toolchain/check/testdata/class/no_prelude/implicit_import.carbon

@@ -6,32 +6,32 @@
 
 // --- basic.carbon
 
-library "basic" api;
+library "basic";
 
 class C;
 
 // --- basic.impl.carbon
 
-library "basic" impl;
+impl library "basic";
 
 class C {}
 
 // --- redecl_after_def.carbon
 
-library "redecl_after_def" api;
+library "redecl_after_def";
 
 class C {}
 
 // --- fail_redecl_after_def.impl.carbon
 
-library "redecl_after_def" impl;
+impl library "redecl_after_def";
 
 // CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+10]]:1: ERROR: Redeclaration of `class C` is redundant.
 // CHECK:STDERR: class C;
 // CHECK:STDERR: ^~~~~~~~
-// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "redecl_after_def" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "redecl_after_def";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: redecl_after_def.carbon:4:1: Previously declared here.
 // CHECK:STDERR: class C {}
 // CHECK:STDERR: ^~~~~~~~~
@@ -40,20 +40,20 @@ class C;
 
 // --- redef_after_def.carbon
 
-library "redef_after_def" api;
+library "redef_after_def";
 
 class C {}
 
 // --- fail_redef_after_def.impl.carbon
 
-library "redef_after_def" impl;
+impl library "redef_after_def";
 
 // CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+10]]:1: ERROR: Redefinition of `class C`.
 // CHECK:STDERR: class C {}
 // CHECK:STDERR: ^~~~~~~~~
-// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "redef_after_def" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "redef_after_def";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: redef_after_def.carbon:4:1: Previously defined here.
 // CHECK:STDERR: class C {}
 // CHECK:STDERR: ^~~~~~~~~
@@ -62,21 +62,21 @@ class C {}
 
 // --- def_alias.carbon
 
-library "def_alias" api;
+library "def_alias";
 
 class C;
 alias B = C;
 
 // --- fail_def_alias.impl.carbon
 
-library "def_alias" impl;
+impl library "def_alias";
 
 // CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+9]]:1: ERROR: Duplicate name being declared in the same scope.
 // CHECK:STDERR: class B {}
 // CHECK:STDERR: ^~~~~~~~~
-// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "def_alias" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "def_alias";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: def_alias.carbon:5:7: Name is previously declared here.
 // CHECK:STDERR: alias B = C;
 // CHECK:STDERR:       ^

+ 2 - 2
toolchain/check/testdata/const/import.carbon

@@ -6,7 +6,7 @@
 
 // --- implicit.carbon
 
-package Implicit api;
+package Implicit;
 
 fn F() -> const i32;
 
@@ -15,7 +15,7 @@ var a_ptr_ref: const i32* = &a_ref;
 
 // --- implicit.impl.carbon
 
-package Implicit impl;
+impl package Implicit;
 
 // Take a reference to avoid unsupported copy logic. This still validates the
 // `const` is handled.

+ 1 - 1
toolchain/check/testdata/function/builtin/call_from_operator.carbon

@@ -6,7 +6,7 @@
 
 // --- core.carbon
 
-package Core api;
+package Core;
 
 interface Add {
   fn Op[self: Self](other: Self) -> Self;

+ 1 - 1
toolchain/check/testdata/function/builtin/import.carbon

@@ -6,7 +6,7 @@
 
 // --- core.carbon
 
-package Core api;
+package Core;
 
 import library "prelude";
 

+ 13 - 13
toolchain/check/testdata/function/declaration/import.carbon

@@ -10,7 +10,7 @@
 
 // --- api.carbon
 
-library "api" api;
+library "api";
 
 fn A();
 fn B(b: i32) -> i32;
@@ -22,7 +22,7 @@ fn NS.E();
 
 // --- extern_api.carbon
 
-library "extern_api" api;
+library "extern_api";
 
 extern fn A();
 extern fn B(b: i32) -> i32;
@@ -38,7 +38,7 @@ extern fn NS.E();
 
 // --- basics.carbon
 
-library "basics" api;
+library "basics";
 
 import library "api";
 
@@ -50,7 +50,7 @@ var e: () = NS.E();
 
 // --- redecl_api.carbon
 
-library "redecl_api" api;
+library "redecl_api";
 
 import library "api";
 
@@ -68,7 +68,7 @@ var e: () = NS.E();
 
 // --- redecl_extern_api.carbon
 
-library "redecl_extern_api" api;
+library "redecl_extern_api";
 
 import library "extern_api";
 
@@ -86,7 +86,7 @@ var e: () = NS.E();
 
 // --- fail_todo_merge.carbon
 
-library "merge" api;
+library "merge";
 
 import library "api";
 // CHECK:STDERR: fail_todo_merge.carbon:[[@LINE+65]]:1: In import.
@@ -164,7 +164,7 @@ var e: () = NS.E();
 
 // --- fail_todo_merge_reverse.carbon
 
-library "merge_reverse" api;
+library "merge_reverse";
 
 import library "extern_api";
 // CHECK:STDERR: fail_todo_merge_reverse.carbon:[[@LINE+65]]:1: In import.
@@ -242,7 +242,7 @@ var e: () = NS.E();
 
 // --- decl_after_use.carbon
 
-library "decl_after_use" api;
+library "decl_after_use";
 
 import library "extern_api";
 
@@ -252,7 +252,7 @@ fn A();
 
 // --- fail_redecl_mismatch_after_use.carbon
 
-library "redecl_mismatch_after_use" api;
+library "redecl_mismatch_after_use";
 
 import library "extern_api";
 
@@ -272,7 +272,7 @@ fn A() -> i32;
 
 // --- todo_fail_extern_after_use.carbon
 
-library "extern_after_use" api;
+library "extern_after_use";
 
 import library "api";
 
@@ -282,19 +282,19 @@ extern fn A();
 
 // --- unloaded.carbon
 
-library "unloaded" api;
+library "unloaded";
 
 import library "api";
 
 // --- unloaded_extern.carbon
 
-library "unloaded_extern" api;
+library "unloaded_extern";
 
 import library "extern_api";
 
 // --- fail_todo_loaded_merge.carbon
 
-library "loaded_merge" api;
+library "loaded_merge";
 
 import library "api";
 // CHECK:STDERR: fail_todo_loaded_merge.carbon:[[@LINE+64]]:1: In import.

+ 3 - 3
toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon

@@ -10,13 +10,13 @@
 
 // --- base.carbon
 
-library "base" api;
+library "base";
 
 fn F();
 
 // --- export.carbon
 
-library "export" api;
+library "export";
 
 import library "base";
 
@@ -28,7 +28,7 @@ export F;
 
 // --- use_export.carbon
 
-library "use_export" api;
+library "use_export";
 
 import library "export";
 

+ 3 - 3
toolchain/check/testdata/function/declaration/no_prelude/extern.carbon

@@ -6,13 +6,13 @@
 
 // --- basic.carbon
 
-library "basic" api;
+library "basic";
 
 extern fn F();
 
 // --- fail_redecl.carbon
 
-library "redecl" api;
+library "redecl";
 
 extern fn F();
 // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn F` is redundant.
@@ -26,7 +26,7 @@ extern fn F();
 
 // --- fail_redecl_extern.carbon
 
-library "redecl_extern" api;
+library "redecl_extern";
 
 extern fn F();
 // CHECK:STDERR: fail_redecl_extern.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn F` is redundant.

+ 2 - 2
toolchain/check/testdata/function/declaration/no_prelude/fail_import_incomplete_return.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_incomplete_return.carbon
 
-library "api" api;
+library "api";
 
 class C;
 class D;
@@ -45,7 +45,7 @@ class D {}
 
 // --- fail_use_imported.carbon
 
-library "use_imported" api;
+library "use_imported";
 
 import library "api";
 

+ 12 - 12
toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon

@@ -6,32 +6,32 @@
 
 // --- basic.carbon
 
-library "basic" api;
+library "basic";
 
 fn A();
 
 // --- basic.impl.carbon
 
-library "basic" impl;
+impl library "basic";
 
 fn A();
 
 // --- extern_api.carbon
 
-library "extern_api" api;
+library "extern_api";
 
 extern fn A();
 
 // --- fail_extern_api.impl.carbon
 
-library "extern_api" impl;
+impl library "extern_api";
 
 // CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+10]]:1: ERROR: Redeclarations of `fn A` in the same library must match use of `extern`.
 // CHECK:STDERR: fn A();
 // CHECK:STDERR: ^~~~~~~
-// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "extern_api" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "extern_api";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: extern_api.carbon:4:1: Previously declared here.
 // CHECK:STDERR: extern fn A();
 // CHECK:STDERR: ^~~~~~~~~~~~~~
@@ -40,20 +40,20 @@ fn A();
 
 // --- extern_impl.carbon
 
-library "extern_impl" api;
+library "extern_impl";
 
 fn A();
 
 // --- fail_extern_impl.impl.carbon
 
-library "extern_impl" impl;
+impl library "extern_impl";
 
 // CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+9]]:1: ERROR: Redeclarations of `fn A` in the same library must match use of `extern`.
 // CHECK:STDERR: extern fn A();
 // CHECK:STDERR: ^~~~~~~~~~~~~~
-// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "extern_impl" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "extern_impl";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: extern_impl.carbon:4:1: Previously declared here.
 // CHECK:STDERR: fn A();
 // CHECK:STDERR: ^~~~~~~

+ 6 - 6
toolchain/check/testdata/function/definition/import.carbon

@@ -10,7 +10,7 @@
 
 // --- fns.carbon
 
-library "fns" api;
+library "fns";
 
 fn A() {}
 fn B(b: i32) -> i32 { return b; }
@@ -19,7 +19,7 @@ fn D();
 
 // --- extern.carbon
 
-library "extern" api;
+library "extern";
 
 extern fn A();
 
@@ -29,7 +29,7 @@ extern fn A();
 
 // --- basics.carbon
 
-library "basics" api;
+library "basics";
 
 import library "fns";
 
@@ -39,7 +39,7 @@ var c: {.c: i32} = C((1,));
 
 // --- fail_def_ownership.carbon
 
-library "def_ownership" api;
+library "def_ownership";
 
 import library "fns";
 
@@ -68,7 +68,7 @@ fn B(b: i32) -> i32;
 
 // --- redecl_then_def.carbon
 
-library "redecl_then_def" api;
+library "redecl_then_def";
 
 import library "extern";
 
@@ -77,7 +77,7 @@ fn A() {}
 
 // --- fail_mix_extern_decl.carbon
 
-library "mix_extern_decl" api;
+library "mix_extern_decl";
 
 import library "fns";
 

+ 4 - 4
toolchain/check/testdata/function/definition/no_prelude/extern.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_extern_def.carbon
 
-library "extern_def" api;
+library "extern_def";
 
 // CHECK:STDERR: fail_extern_def.carbon:[[@LINE+4]]:1: ERROR: `extern` not allowed on `fn` declaration that provides a definition.
 // CHECK:STDERR: extern fn F() {}
@@ -16,7 +16,7 @@ extern fn F() {}
 
 // --- fail_def_for_extern_decl.carbon
 
-library "def_for_extern_decl" api;
+library "def_for_extern_decl";
 
 extern fn F();
 // CHECK:STDERR: fail_def_for_extern_decl.carbon:[[@LINE+7]]:1: ERROR: Redeclarations of `fn F` in the same library must match use of `extern`.
@@ -30,7 +30,7 @@ fn F() {}
 
 // --- fail_extern_diag_suppressed.carbon
 
-library "extern_diag_suppressed" api;
+library "extern_diag_suppressed";
 
 extern fn F();
 // CHECK:STDERR: fail_extern_diag_suppressed.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn F` is redundant.
@@ -45,7 +45,7 @@ fn F() {}
 
 // --- fail_extern_decl_after_def.carbon
 
-library "extern_decl_after_def" api;
+library "extern_decl_after_def";
 
 fn F() {}
 // CHECK:STDERR: fail_extern_decl_after_def.carbon:[[@LINE+6]]:1: ERROR: Redeclaration of `fn F` is redundant.

+ 24 - 24
toolchain/check/testdata/function/definition/no_prelude/implicit_import.carbon

@@ -6,32 +6,32 @@
 
 // --- basic.carbon
 
-library "basic" api;
+library "basic";
 
 fn A();
 
 // --- basic.impl.carbon
 
-library "basic" impl;
+impl library "basic";
 
 fn A() {}
 
 // --- extern_api.carbon
 
-library "extern_api" api;
+library "extern_api";
 
 extern fn A();
 
 // --- fail_extern_api.impl.carbon
 
-library "extern_api" impl;
+impl library "extern_api";
 
 // CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+10]]:1: ERROR: Redeclarations of `fn A` in the same library must match use of `extern`.
 // CHECK:STDERR: fn A() {}
 // CHECK:STDERR: ^~~~~~~~
-// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "extern_api" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "extern_api";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: extern_api.carbon:4:1: Previously declared here.
 // CHECK:STDERR: extern fn A();
 // CHECK:STDERR: ^~~~~~~~~~~~~~
@@ -40,13 +40,13 @@ fn A() {}
 
 // --- extern_impl.carbon
 
-library "extern_impl" api;
+library "extern_impl";
 
 fn A();
 
 // --- fail_extern_impl.impl.carbon
 
-library "extern_impl" impl;
+impl library "extern_impl";
 
 // CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+4]]:1: ERROR: `extern` not allowed on `fn` declaration that provides a definition.
 // CHECK:STDERR: extern fn A() {}
@@ -56,20 +56,20 @@ extern fn A() {}
 
 // --- redecl_after_def.carbon
 
-library "redecl_after_def" api;
+library "redecl_after_def";
 
 fn A() {}
 
 // --- fail_redecl_after_def.impl.carbon
 
-library "redecl_after_def" impl;
+impl library "redecl_after_def";
 
 // CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+10]]:1: ERROR: Redeclaration of `fn A` is redundant.
 // CHECK:STDERR: fn A();
 // CHECK:STDERR: ^~~~~~~
-// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "redecl_after_def" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "redecl_after_def";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: redecl_after_def.carbon:4:1: Previously declared here.
 // CHECK:STDERR: fn A() {}
 // CHECK:STDERR: ^~~~~~~~
@@ -78,20 +78,20 @@ fn A();
 
 // --- redef_after_def.carbon
 
-library "redef_after_def" api;
+library "redef_after_def";
 
 fn A() {}
 
 // --- fail_redef_after_def.impl.carbon
 
-library "redef_after_def" impl;
+impl library "redef_after_def";
 
 // CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+10]]:1: ERROR: Redefinition of `fn A`.
 // CHECK:STDERR: fn A() {}
 // CHECK:STDERR: ^~~~~~~~
-// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "redef_after_def" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "redef_after_def";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: redef_after_def.carbon:4:1: Previously defined here.
 // CHECK:STDERR: fn A() {}
 // CHECK:STDERR: ^~~~~~~~
@@ -100,21 +100,21 @@ fn A() {}
 
 // --- def_alias.carbon
 
-library "def_alias" api;
+library "def_alias";
 
 fn A();
 alias B = A;
 
 // --- fail_def_alias.impl.carbon
 
-library "def_alias" impl;
+impl library "def_alias";
 
 // CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+9]]:1: ERROR: Duplicate name being declared in the same scope.
 // CHECK:STDERR: fn B() {}
 // CHECK:STDERR: ^~~~~~~~
-// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:1: In import.
-// CHECK:STDERR: library "def_alias" impl;
-// CHECK:STDERR: ^~~~~~~
+// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE-5]]:6: In import.
+// CHECK:STDERR: impl library "def_alias";
+// CHECK:STDERR:      ^~~~~~~
 // CHECK:STDERR: def_alias.carbon:5:7: Name is previously declared here.
 // CHECK:STDERR: alias B = A;
 // CHECK:STDERR:       ^

+ 4 - 4
toolchain/check/testdata/function/generic/redeclare.carbon

@@ -6,7 +6,7 @@
 
 // --- redeclare.carbon
 
-library "redeclare" api;
+library "redeclare";
 
 fn F(T:! type) -> T*;
 
@@ -16,7 +16,7 @@ fn F(T:! type) -> T* {
 
 // --- fail_different_return_type.carbon
 
-library "fail_different_return_type" api;
+library "fail_different_return_type";
 
 fn F(T:! type, U:! type) -> T*;
 
@@ -44,7 +44,7 @@ fn F(T:! type, U:! type) -> U* {
 
 // --- fail_reorder.carbon
 
-library "fail_reorder" api;
+library "fail_reorder";
 
 fn F(T:! type, U:! type) -> T*;
 
@@ -72,7 +72,7 @@ fn F(U:! type, T:! type) -> T* {
 
 // --- fail_rename.carbon
 
-library "fail_rename" api;
+library "fail_rename";
 
 fn F(T:! type, U:! type) -> T*;
 

+ 2 - 2
toolchain/check/testdata/if_expr/fail_partial_constant.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_non_constant_condition.carbon
 
-package NonConstantCondition api;
+package NonConstantCondition;
 
 fn ConditionIsNonConstant(b: bool) {
   // We choose to not accept this even if both arms evaluate to the same
@@ -21,7 +21,7 @@ fn ConditionIsNonConstant(b: bool) {
 
 // --- fail_non_constant_result.carbon
 
-package NonConstantResult api;
+package NonConstantResult;
 
 fn ChosenBranchIsNonConstant(t: type) {
   // CHECK:STDERR: fail_non_constant_result.carbon:[[@LINE+4]]:10: ERROR: Cannot evaluate type expression.

+ 1 - 1
toolchain/check/testdata/impl/lookup/import.carbon

@@ -6,7 +6,7 @@
 
 // --- impl.carbon
 
-package Impl api;
+package Impl;
 
 interface HasF {
   fn F();

+ 1 - 1
toolchain/check/testdata/impl/lookup/no_prelude/import.carbon

@@ -6,7 +6,7 @@
 
 // --- impl.carbon
 
-package Impl api;
+package Impl;
 
 interface HasF {
   fn F();

+ 2 - 2
toolchain/check/testdata/impl/no_prelude/import_self.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 interface Add {
   fn Op[self: Self](other: Self) -> Self;
@@ -14,7 +14,7 @@ interface Add {
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 3 - 3
toolchain/check/testdata/interface/no_prelude/export_name.carbon

@@ -10,13 +10,13 @@
 
 // --- base.carbon
 
-library "base" api;
+library "base";
 
 interface I {}
 
 // --- export.carbon
 
-library "export" api;
+library "export";
 
 import library "base";
 
@@ -28,7 +28,7 @@ export I;
 
 // --- use_export.carbon
 
-library "use_export" api;
+library "use_export";
 
 import library "export";
 

+ 2 - 2
toolchain/check/testdata/interface/no_prelude/import.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-library "a" api;
+library "a";
 
 interface Empty {
 }
@@ -28,7 +28,7 @@ var f_ref: {.f: ForwardDeclared};
 
 // --- b.carbon
 
-library "b" api;
+library "b";
 
 import library "a";
 

+ 2 - 2
toolchain/check/testdata/let/fail_generic_import.carbon

@@ -6,13 +6,13 @@
 
 // --- implicit.carbon
 
-package Implicit api;
+package Implicit;
 
 let T:! type = i32;
 
 // --- fail_implicit.impl.carbon
 
-package Implicit impl;
+impl package Implicit;
 
 // TODO: Should this be valid?
 // CHECK:STDERR: fail_implicit.impl.carbon:[[@LINE+3]]:1: ERROR: Cannot implicitly convert from `i32` to `T`.

+ 2 - 2
toolchain/check/testdata/let/generic_import.carbon

@@ -6,13 +6,13 @@
 
 // --- implicit.carbon
 
-package Implicit api;
+package Implicit;
 
 let T:! type = i32;
 
 // --- implicit.impl.carbon
 
-package Implicit impl;
+impl package Implicit;
 
 var a: T*;
 var b: T = *a;

+ 2 - 2
toolchain/check/testdata/let/import.carbon

@@ -6,13 +6,13 @@
 
 // --- implicit.carbon
 
-package Implicit api;
+package Implicit;
 
 let a:! bool = true;
 
 // --- implicit.impl.carbon
 
-package Implicit impl;
+impl package Implicit;
 
 let b:! bool = a;
 

+ 2 - 2
toolchain/check/testdata/namespace/add_to_import.carbon

@@ -6,13 +6,13 @@
 
 // --- implicit.carbon
 
-package Implicit api;
+package Implicit;
 
 namespace NS;
 
 // --- implicit.impl.carbon
 
-package Implicit impl;
+impl package Implicit;
 
 fn NS.A() -> i32 { return 0; }
 

+ 2 - 2
toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon

@@ -6,13 +6,13 @@
 
 // --- namespace.carbon
 
-package Example library "namespace" api;
+package Example library "namespace";
 
 namespace NS;
 
 // --- fail_conflict.carbon
 
-package Example api;
+package Example;
 
 import library "namespace";
 

+ 2 - 2
toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon

@@ -6,13 +6,13 @@
 
 // --- namespace.carbon
 
-package Example library "namespace" api;
+package Example library "namespace";
 
 namespace NS;
 
 // --- fail_conflict.carbon
 
-package Example api;
+package Example;
 
 import library "namespace";
 

+ 2 - 2
toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon

@@ -6,13 +6,13 @@
 
 // --- fn.carbon
 
-package Example library "fn" api;
+package Example library "fn";
 
 fn NS();
 
 // --- fail_conflict.carbon
 
-package Example api;
+package Example;
 
 import library "fn";
 

+ 3 - 3
toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon

@@ -6,20 +6,20 @@
 
 // --- namespace.carbon
 
-package Example library "namespace" api;
+package Example library "namespace";
 
 namespace NS;
 fn NS.Foo() {}
 
 // --- fn.carbon
 
-package Example library "fn" api;
+package Example library "fn";
 
 fn NS() {}
 
 // --- fail_conflict.carbon
 
-package Example library "namespace_then_fn" api;
+package Example library "namespace_then_fn";
 
 import library "namespace";
 // CHECK:STDERR: fail_conflict.carbon:[[@LINE+12]]:1: In import.

+ 3 - 3
toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon

@@ -6,20 +6,20 @@
 
 // --- fn.carbon
 
-package Example library "fn" api;
+package Example library "fn";
 
 fn NS() {}
 
 // --- namespace.carbon
 
-package Example library "namespace" api;
+package Example library "namespace";
 
 namespace NS;
 fn NS.Foo() {}
 
 // --- fail_conflict.carbon
 
-package Example library "fn_then_namespace" api;
+package Example library "fn_then_namespace";
 
 import library "fn";
 // CHECK:STDERR: fail_conflict.carbon:[[@LINE+12]]:1: In import.

+ 2 - 2
toolchain/check/testdata/namespace/imported.carbon

@@ -6,7 +6,7 @@
 
 // --- implicit.carbon
 
-package Implicit api;
+package Implicit;
 
 namespace NS;
 namespace NS.ChildNS;
@@ -16,7 +16,7 @@ fn NS.ChildNS.B();
 
 // --- implicit.impl.carbon
 
-package Implicit impl;
+impl package Implicit;
 
 var a: () = NS.A();
 var b: () = NS.ChildNS.B();

+ 5 - 5
toolchain/check/testdata/namespace/imported_indirect.carbon

@@ -6,34 +6,34 @@
 
 // --- a.carbon
 
-package Same library "a" api;
+package Same library "a";
 
 namespace A;
 
 // --- b.carbon
 
-package Same library "b" api;
+package Same library "b";
 import library "a";
 
 namespace A.B;
 
 // --- c.carbon
 
-package Same library "c" api;
+package Same library "c";
 import library "b";
 
 namespace A.B.C;
 
 // --- d.carbon
 
-package Same library "d" api;
+package Same library "d";
 import library "c";
 
 fn A.B.C.D() {};
 
 // --- e.carbon
 
-package Same library "e" api;
+package Same library "e";
 import library "d";
 
 var e: () = A.B.C.D();

+ 3 - 3
toolchain/check/testdata/namespace/merging.carbon

@@ -6,7 +6,7 @@
 
 // --- a.carbon
 
-package Example library "a" api;
+package Example library "a";
 
 namespace NS;
 
@@ -14,7 +14,7 @@ fn NS.A() {}
 
 // --- b.carbon
 
-package Example library "b" api;
+package Example library "b";
 
 namespace NS;
 
@@ -26,7 +26,7 @@ fn NS.B2() {}
 
 // --- c.carbon
 
-package Example library "c" api;
+package Example library "c";
 
 import library "a";
 import library "b";

+ 2 - 2
toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon

@@ -6,7 +6,7 @@
 
 // --- fail_non_constant_result.carbon
 
-package FailNonConstantResult api;
+package FailNonConstantResult;
 
 fn PartialConstant(x: bool) {
   // CHECK:STDERR: fail_non_constant_result.carbon:[[@LINE+4]]:10: ERROR: Cannot evaluate type expression.
@@ -23,7 +23,7 @@ fn PartialConstant(x: bool) {
 
 // --- fail_despite_known_result.carbon
 
-package FailDespiteKnownResult api;
+package FailDespiteKnownResult;
 
 fn KnownValueButNonConstantCondition(x: bool) {
   // We choose not to give these cases constant values, even though we could,

+ 2 - 2
toolchain/check/testdata/operators/overloaded/add.carbon

@@ -8,7 +8,7 @@
 
 // --- prelude.carbon
 
-package Core api;
+package Core;
 
 interface Add {
   fn Op[self: Self](other: Self) -> Self;
@@ -19,7 +19,7 @@ interface AddAssign {
 
 // --- user.carbon
 
-package User api;
+package User;
 
 import Core;
 

+ 2 - 2
toolchain/check/testdata/operators/overloaded/bit_and.carbon

@@ -8,7 +8,7 @@
 
 // --- prelude.carbon
 
-package Core api;
+package Core;
 
 interface BitAnd {
   fn Op[self: Self](other: Self) -> Self;
@@ -19,7 +19,7 @@ interface BitAndAssign {
 
 // --- user.carbon
 
-package User api;
+package User;
 
 import Core;
 

+ 2 - 2
toolchain/check/testdata/operators/overloaded/bit_complement.carbon

@@ -8,7 +8,7 @@
 
 // --- prelude.carbon
 
-package Core api;
+package Core;
 
 interface BitComplement {
   fn Op[self: Self]() -> Self;
@@ -16,7 +16,7 @@ interface BitComplement {
 
 // --- user.carbon
 
-package User api;
+package User;
 
 import Core;
 

Some files were not shown because too many files changed in this diff