Remove support for addr (#6375)

Every test that used `addr` before #6283 should be using `ref` after
this PR. In most cases that was done in #6283, but this PR transitions a
few that I missed in that first pass. In addition, #6283 cloned the old
`addr` tests from `foo.carbon` to `foo_addr.carbon` in order to maintain
test coverage during the transition; this PR removes those cloned tests.
This commit is contained in:
Geoff Romer
2025-11-18 19:48:58 +00:00
committed by GitHub
parent ee49d65e29
commit 57a2715f10
76 changed files with 397 additions and 6442 deletions
@@ -402,37 +402,6 @@ auto HandleParseNode(Context& context, Parse::FieldNameAndTypeId node_id)
return true;
}
auto HandleParseNode(Context& context, Parse::AddrId node_id) -> bool {
auto param_pattern_id = context.node_stack().PopPattern();
if (SemIR::IsSelfPattern(context.sem_ir(), param_pattern_id)) {
auto param_type_id = ExtractScrutineeType(
context.sem_ir(), context.insts().Get(param_pattern_id).type_id());
auto pointer_type =
context.types().TryGetAs<SemIR::PointerType>(param_type_id);
if (pointer_type) {
auto addr_pattern_id = AddPatternInst<SemIR::AddrPattern>(
context, node_id,
{.type_id = GetPatternType(
context, GetSingletonType(context, SemIR::AutoType::TypeInstId)),
.inner_id = param_pattern_id});
context.node_stack().Push(node_id, addr_pattern_id);
} else {
CARBON_DIAGNOSTIC(
AddrOnNonPointerType, Error,
"`addr` can only be applied to a binding with a pointer type");
context.emitter().Emit(node_id, AddrOnNonPointerType);
context.node_stack().Push(node_id, param_pattern_id);
}
} else {
CARBON_DIAGNOSTIC(AddrOnNonSelfParam, Error,
"`addr` can only be applied to a `self` parameter");
context.emitter().Emit(LocIdForDiagnostics::TokenOnly(node_id),
AddrOnNonSelfParam);
context.node_stack().Push(node_id, param_pattern_id);
}
return true;
}
auto HandleParseNode(Context& context, Parse::RefBindingNameId node_id)
-> bool {
context.node_stack().Push(node_id);