diff --git a/explorer/interpreter/pattern_match.cpp b/explorer/interpreter/pattern_match.cpp index 507ed9feda7d..30166fc78b4e 100644 --- a/explorer/interpreter/pattern_match.cpp +++ b/explorer/interpreter/pattern_match.cpp @@ -61,9 +61,11 @@ auto PatternMatch(Nonnull p, ExpressionResult v, BindingMap& generic_args, Nonnull trace_stream, Nonnull arena) -> bool { if (trace_stream->is_enabled()) { - *trace_stream << "match pattern " << *p << "\nfrom " - << ExpressionCategoryToString(v.expression_category()) - << " expression with value " << *v.value() << "\n"; + trace_stream->Match() << "match pattern `" << *p << "`\n"; + trace_stream->Indent() << "from " + << ExpressionCategoryToString( + v.expression_category()) + << " expression with value `" << *v.value() << "`\n"; } const auto make_expr_result = [](Nonnull v) -> ExpressionResult { diff --git a/explorer/testdata/trace/context_main.carbon b/explorer/testdata/trace/context_main.carbon index ee6ae85abbf8..a58ee288c07a 100644 --- a/explorer/testdata/trace/context_main.carbon +++ b/explorer/testdata/trace/context_main.carbon @@ -272,8 +272,8 @@ fn Main() -> i32 { // CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) // CHECK:STDOUT: ->> step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> // CHECK:STDOUT: -() calling function: fun
-// CHECK:STDOUT: match pattern () -// CHECK:STDOUT: from value expression with value () +// CHECK:STDOUT: === match pattern `()` +// CHECK:STDOUT: from value expression with value `()` // CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [] (None) // CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{return 0;}` (context_main.carbon:11) // CHECK:STDOUT: ->> step StatementAction pos: 0 `{return 0;}` (context_main.carbon:11) ---> diff --git a/explorer/testdata/trace/phase_all.carbon b/explorer/testdata/trace/phase_all.carbon index 4ffc6b7cac33..ceca5c6b3be9 100644 --- a/explorer/testdata/trace/phase_all.carbon +++ b/explorer/testdata/trace/phase_all.carbon @@ -490,8 +490,8 @@ fn Main() -> i32 { // CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) // CHECK:STDOUT: ->> step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> // CHECK:STDOUT: -() calling function: fun
-// CHECK:STDOUT: match pattern () -// CHECK:STDOUT: from value expression with value () +// CHECK:STDOUT: === match pattern `()` +// CHECK:STDOUT: from value expression with value `()` // CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [] (None) // CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) // CHECK:STDOUT: ->> step StatementAction pos: 0 `{var x: i32 = N.Foo(0);return x;}` (phase_all.carbon:18) ---> @@ -528,10 +528,10 @@ fn Main() -> i32 { // CHECK:STDOUT: <[] stack-pop: ExpressionAction pos: 0 `0` (phase_all.carbon:16) // CHECK:STDOUT: ->> step ExpressionAction pos: 2 `N.Foo(0)` results: [`fun`, `0`] scope: [] (phase_all.carbon:16) ---> // CHECK:STDOUT: -() calling function: fun -// CHECK:STDOUT: match pattern (Placeholder,) -// CHECK:STDOUT: from value expression with value (0,) -// CHECK:STDOUT: match pattern Placeholder -// CHECK:STDOUT: from value expression with value 0 +// CHECK:STDOUT: === match pattern `(Placeholder,)` +// CHECK:STDOUT: from value expression with value `(0,)` +// CHECK:STDOUT: === match pattern `Placeholder` +// CHECK:STDOUT: from value expression with value `0` // CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [`n: i32`: `0`] (None) // CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{return (n + 1);}` (phase_all.carbon:13) // CHECK:STDOUT: ->> step StatementAction pos: 0 `{return (n + 1);}` (phase_all.carbon:13) ---> @@ -597,8 +597,8 @@ fn Main() -> i32 { // CHECK:STDOUT: var x: i32 = N.Foo(0); // CHECK:STDOUT: ``` // CHECK:STDOUT: <-- memory-read: #1 `1` -// CHECK:STDOUT: match pattern Placeholder -// CHECK:STDOUT: from initializing expression with value 1 +// CHECK:STDOUT: === match pattern `Placeholder` +// CHECK:STDOUT: from initializing expression with value `1` // CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `var x: i32 = N.Foo(0);` results: [`1`] (phase_all.carbon:16) // CHECK:STDOUT: ->> step StatementAction pos: 1 `{var x: i32 = N.Foo(0);return x;}` scope: [`x: i32`: `lval`] (phase_all.carbon:18) ---> // CHECK:STDOUT: *** statement at (phase_all.carbon:18) diff --git a/explorer/testdata/trace/phase_execution.carbon b/explorer/testdata/trace/phase_execution.carbon index 895444f2e142..12679637e2a6 100644 --- a/explorer/testdata/trace/phase_execution.carbon +++ b/explorer/testdata/trace/phase_execution.carbon @@ -56,8 +56,8 @@ fn Main() -> i32 { // CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `Main` results: [`fun
`] (:0) // CHECK:STDOUT: ->> step ExpressionAction pos: 1 `Main()` results: [`fun
`] scope: [] (:0) ---> // CHECK:STDOUT: -() calling function: fun
-// CHECK:STDOUT: match pattern () -// CHECK:STDOUT: from value expression with value () +// CHECK:STDOUT: === match pattern `()` +// CHECK:STDOUT: from value expression with value `()` // CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [] (None) // CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{var x: T = {}.(interface ImplicitAs(T = class T).Convert)();return 0;}` (phase_execution.carbon:12) // CHECK:STDOUT: ->> step StatementAction pos: 0 `{var x: T = {}.(interface ImplicitAs(T = class T).Convert)();return 0;}` (phase_execution.carbon:12) ---> @@ -106,8 +106,8 @@ fn Main() -> i32 { // CHECK:STDOUT: <[] stack-pop: ValueExpressionAction pos: 1 `{}.(interface ImplicitAs(T = class T).Convert)` results: [`bound_method`] (phase_execution.carbon:10) // CHECK:STDOUT: ->> step ExpressionAction pos: 1 `{}.(interface ImplicitAs(T = class T).Convert)()` results: [`bound_method`] scope: [] (phase_execution.carbon:10) ---> // CHECK:STDOUT: -() calling function: bound_method -// CHECK:STDOUT: match pattern () -// CHECK:STDOUT: from value expression with value () +// CHECK:STDOUT: === match pattern `()` +// CHECK:STDOUT: from value expression with value `()` // CHECK:STDOUT: >[] stack-push: ScopeAction pos: 0 scope: [`self: Self`: `{}`] (None) // CHECK:STDOUT: >[] stack-push: StatementAction pos: 0 `{return __intrinsic_implicit_as_convert(self, U);}` (prelude.carbon:{{\d+}}) // CHECK:STDOUT: ->> step StatementAction pos: 0 `{return __intrinsic_implicit_as_convert(self, U);}` (prelude.carbon:{{\d+}}) ---> @@ -173,8 +173,8 @@ fn Main() -> i32 { // CHECK:STDOUT: var x: T = {}.(interface ImplicitAs(T = class T).Convert)(); // CHECK:STDOUT: ``` // CHECK:STDOUT: <-- memory-read: #1 `T{}` -// CHECK:STDOUT: match pattern Placeholder -// CHECK:STDOUT: from initializing expression with value T{} +// CHECK:STDOUT: === match pattern `Placeholder` +// CHECK:STDOUT: from initializing expression with value `T{}` // CHECK:STDOUT: <[] stack-pop: StatementAction pos: 1 `var x: T = {}.(interface ImplicitAs(T = class T).Convert)();` results: [`T{}`] (phase_execution.carbon:10) // CHECK:STDOUT: ->> step StatementAction pos: 1 `{var x: T = {}.(interface ImplicitAs(T = class T).Convert)();return 0;}` scope: [`x: T`: `lval`] (phase_execution.carbon:12) ---> // CHECK:STDOUT: *** statement at (phase_execution.carbon:12)