Do not treat impls in different scopes as redeclarations (#7161)

An impl in a different scope, with the same parameters, will overlap and
get diagnosed for that later by the [prioritization
rule](https://docs.carbon-lang.dev/docs/design/generics/details.html#prioritization-rule),
if they are not in a match_first block. But they are not considered as
redeclarations.

See [proposal
p5366](https://github.com/carbon-language/carbon-lang/blob/62b94f79322039acc3fc8e175896a64a32df470e/proposals/p5366.md)
for the rule.
This commit is contained in:
Dana Jansens
2026-05-04 19:11:51 +00:00
committed by GitHub
parent 4d1a61de29
commit f8dd4d85bf
297 changed files with 14091 additions and 13769 deletions
@@ -51,7 +51,7 @@ fn M() -> i32 {
// CHECK:STDOUT: %.loc34 = load i32, ptr %n.var, align 4, !dbg !10
// CHECK:STDOUT: call void @_CF.Main.b88d1103f417c6d4(i32 %.loc34), !dbg !11
// CHECK:STDOUT: %.loc35_9 = load i32, ptr %n.var, align 4, !dbg !12
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.bfb441135f07cbe1(i32 %.loc35_9), !dbg !13
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.f5e5d1b2c429b157(i32 %.loc35_9), !dbg !13
// CHECK:STDOUT: store i32 %G.call, ptr %m.var, align 4, !dbg !14
// CHECK:STDOUT: %.loc36 = load i32, ptr %m.var, align 4, !dbg !15
// CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %m.var), !dbg !9
@@ -75,11 +75,11 @@ fn M() -> i32 {
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.bfb441135f07cbe1(i32 %x) #0 !dbg !27 {
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.f5e5d1b2c429b157(i32 %x) #0 !dbg !27 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %.loc25_6.2.temp = alloca i32, align 4, !dbg !32
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc25_6.2.temp), !dbg !32
// CHECK:STDOUT: %H.call = call i32 @_CH.Main.64ccbb8e5d9a0b8e(i32 %x), !dbg !32
// CHECK:STDOUT: %H.call = call i32 @_CH.Main.5662bbc72901b5f6(i32 %x), !dbg !32
// CHECK:STDOUT: store i32 %H.call, ptr %.loc25_6.2.temp, align 4, !dbg !32
// CHECK:STDOUT: call void @_CF.Main.b88d1103f417c6d4(i32 %x), !dbg !33
// CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %.loc25_6.2.temp), !dbg !32
@@ -87,7 +87,7 @@ fn M() -> i32 {
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define linkonce_odr i32 @_CH.Main.64ccbb8e5d9a0b8e(i32 %x) #0 !dbg !35 {
// CHECK:STDOUT: define linkonce_odr i32 @_CH.Main.5662bbc72901b5f6(i32 %x) #0 !dbg !35 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @_CF.Main.b88d1103f417c6d4(i32 %x), !dbg !38
// CHECK:STDOUT: ret i32 %x, !dbg !39
@@ -130,7 +130,7 @@ fn M() -> i32 {
// CHECK:STDOUT: !24 = !{!25}
// CHECK:STDOUT: !25 = !DILocalVariable(arg: 1, scope: !23, type: !7)
// CHECK:STDOUT: !26 = !DILocation(line: 16, column: 1, scope: !23)
// CHECK:STDOUT: !27 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.bfb441135f07cbe1", scope: null, file: !3, line: 24, type: !28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !30)
// CHECK:STDOUT: !27 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.f5e5d1b2c429b157", scope: null, file: !3, line: 24, type: !28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !30)
// CHECK:STDOUT: !28 = !DISubroutineType(types: !29)
// CHECK:STDOUT: !29 = !{!7, !7}
// CHECK:STDOUT: !30 = !{!31}
@@ -138,7 +138,7 @@ fn M() -> i32 {
// CHECK:STDOUT: !32 = !DILocation(line: 25, column: 3, scope: !27)
// CHECK:STDOUT: !33 = !DILocation(line: 26, column: 3, scope: !27)
// CHECK:STDOUT: !34 = !DILocation(line: 27, column: 3, scope: !27)
// CHECK:STDOUT: !35 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main.64ccbb8e5d9a0b8e", scope: null, file: !3, line: 19, type: !28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36)
// CHECK:STDOUT: !35 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main.5662bbc72901b5f6", scope: null, file: !3, line: 19, type: !28, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36)
// CHECK:STDOUT: !36 = !{!37}
// CHECK:STDOUT: !37 = !DILocalVariable(arg: 1, scope: !35, type: !7)
// CHECK:STDOUT: !38 = !DILocation(line: 20, column: 3, scope: !35)