Change the package namespace to use the package name (#6495)

Instead of naming the root namespace `package` (because it's accessed by
the `package` keyword), change it to use the current package name. Note,
buried in the checksum changes,
`toolchain/check/testdata/package_expr/fail_not_found.carbon`:

```
-  // CHECK:STDERR: fail_not_found.carbon:[[@LINE+4]]:16: error: member name `x` not found in `package` [MemberNameNotFoundInInstScope]
+  // CHECK:STDERR: fail_not_found.carbon:[[@LINE+4]]:16: error: member name `x` not found in `Main` [MemberNameNotFoundInInstScope]
```

for:

```
  // CHECK:STDERR:   var y: i32 = package.x;
  // CHECK:STDERR:                ^~~~~~~~~
```

I'll leave it to you if you prefer this; the alternative I see is to
just rename `IsCorePackage` to `IsImportedCorePackage`, and/or change it
to a helper that takes a `Context` and does the right thing with
`parse_tree` (which, I need for `Destroy`-related reasons and was my
default approach).
This commit is contained in:
Jon Ross-Perkins
2025-12-16 01:33:53 +00:00
committed by GitHub
parent 2a3d0b71bb
commit 47e551141f
453 changed files with 24276 additions and 24181 deletions
@@ -63,15 +63,15 @@ fn Run() {
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define void @main() #0 !dbg !12 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %G.call.loc40 = call i32 @_CG.Main.4d3c36eeac175c1f(i32 0), !dbg !13
// CHECK:STDOUT: %G.call.loc41 = call i32 @_CG.Main.7abe23e63361d139(i32 0), !dbg !14
// CHECK:STDOUT: %G.call.loc40 = call i32 @_CG.Main.e9e6696c149514bc(i32 0), !dbg !13
// CHECK:STDOUT: %G.call.loc41 = call i32 @_CG.Main.04781cad21582b39(i32 0), !dbg !14
// CHECK:STDOUT: ret void, !dbg !15
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: declare i32 @printf(ptr, ...)
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.4d3c36eeac175c1f(i32 %count) #0 !dbg !16 {
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.e9e6696c149514bc(i32 %count) #0 !dbg !16 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @"_CF.X.Main:I.Main"(), !dbg !22
// CHECK:STDOUT: %Int.as.OrderedWith.impl.Greater.call = icmp sgt i32 %count, 0, !dbg !23
@@ -82,12 +82,12 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: if.else: ; preds = %entry
// CHECK:STDOUT: %Int.as.AddWith.impl.Op.call = add i32 %count, 1, !dbg !26
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.4d3c36eeac175c1f(i32 %Int.as.AddWith.impl.Op.call), !dbg !27
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.e9e6696c149514bc(i32 %Int.as.AddWith.impl.Op.call), !dbg !27
// CHECK:STDOUT: ret i32 %G.call, !dbg !28
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.7abe23e63361d139(i32 %count) #0 !dbg !29 {
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.04781cad21582b39(i32 %count) #0 !dbg !29 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @"_CF.Y.Main:I.Main"(), !dbg !32
// CHECK:STDOUT: %Int.as.OrderedWith.impl.Greater.call = icmp sgt i32 %count, 0, !dbg !33
@@ -98,7 +98,7 @@ fn Run() {
// CHECK:STDOUT:
// CHECK:STDOUT: if.else: ; preds = %entry
// CHECK:STDOUT: %Int.as.AddWith.impl.Op.call = add i32 %count, 1, !dbg !36
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.7abe23e63361d139(i32 %Int.as.AddWith.impl.Op.call), !dbg !37
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.04781cad21582b39(i32 %Int.as.AddWith.impl.Op.call), !dbg !37
// CHECK:STDOUT: ret i32 %G.call, !dbg !38
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -126,7 +126,7 @@ fn Run() {
// CHECK:STDOUT: !13 = !DILocation(line: 40, column: 3, scope: !12)
// CHECK:STDOUT: !14 = !DILocation(line: 41, column: 3, scope: !12)
// CHECK:STDOUT: !15 = !DILocation(line: 39, column: 1, scope: !12)
// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.4d3c36eeac175c1f", scope: null, file: !3, line: 30, type: !17, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !20)
// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.e9e6696c149514bc", scope: null, file: !3, line: 30, type: !17, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !20)
// CHECK:STDOUT: !17 = !DISubroutineType(types: !18)
// CHECK:STDOUT: !18 = !{!19, !19}
// CHECK:STDOUT: !19 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
@@ -139,7 +139,7 @@ fn Run() {
// CHECK:STDOUT: !26 = !DILocation(line: 36, column: 15, scope: !16)
// CHECK:STDOUT: !27 = !DILocation(line: 36, column: 10, scope: !16)
// CHECK:STDOUT: !28 = !DILocation(line: 36, column: 3, scope: !16)
// CHECK:STDOUT: !29 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.7abe23e63361d139", scope: null, file: !3, line: 30, type: !17, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !30)
// CHECK:STDOUT: !29 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.04781cad21582b39", scope: null, file: !3, line: 30, type: !17, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !30)
// CHECK:STDOUT: !30 = !{!31}
// CHECK:STDOUT: !31 = !DILocalVariable(arg: 1, scope: !29, type: !19)
// CHECK:STDOUT: !32 = !DILocation(line: 31, column: 3, scope: !29)