Skip to content

Commit b89b445

Browse files
anpyaahc
andcommitted
fix typo
Co-Authored-By: Jane Lusby <[email protected]>
1 parent b3e1428 commit b89b445

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/codegen/implicit-caller-location.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ explained in terms of how it works in a `const` context.
5252
## Caller Location in `const`
5353

5454
There are two main phases to returning the caller location in a const context: walking up the stack
55-
to find it and allocating a const value to return.
55+
to find the right location and allocating a const value to return.
56+
57+
### Finding the right `Location`
5658

5759
In a const context we "walk up the stack" from where the intrinsic is invoked, stopping when we
5860
reach the first function call in the stack which does *not* have the attribute. This walk is in
59-
[`InterpCx::find_closest_untracked_caller_location()`][const-find-closest] which returns
60-
`Option<Span>`.
61-
62-
If the caller of the current function is untracked, it returns `None`. We use the span for the
63-
intrinsic's callsite in this case.
61+
[`InterpCx::find_closest_untracked_caller_location()`][const-find-closest].
6462

65-
Otherwise it searches by iterating in reverse over [`Frame`][const-frame]s in the [InterpCx::stack],
63+
Starting at the bottom, we iterate up over stack [`Frame`][const-frame]s in the [InterpCx::stack],
6664
calling [`InstanceDef::requires_caller_location`][requires-location] on the
67-
[`Frame::instance`][frame-instance]'s def until it finds a `false` return. It then returns the span
68-
of the prior still-tracked frame which is the "topmost" tracked function.
65+
[`Instance`s from each `Frame`][frame-instance]. We stop once we find one that returns `false` and
66+
return the span of the *previous* frame which was the "topmost" tracked function.
67+
68+
### Allocating a static `Location`
6969

70-
We use the same code in both contexts to allocate a static value for each `Location`. This is
71-
performed by the [`TyCtxt::const_caller_location()`][const-location-query] query. Internally this
72-
calls [`InterpCx::alloc_caller_location()`][alloc-location] and results in a unique
70+
Once we have a `Span` we need to allocate static memory for the `Location`, which is performed by
71+
the [`TyCtxt::const_caller_location()`][const-location-query] query. Internally this calls
72+
[`InterpCx::alloc_caller_location()`][alloc-location] and results in a unique
7373
[memory kind][location-memory-kind]. The SSA codegen backend is able to emit code for these same
74-
values.
74+
values, and we use this code there as well..
7575

76-
Once our location has been allocated in static memory we return a pointer to it.
76+
Once our `Location` has been allocated in static memory, our intrinsic returns a reference to it.
7777

7878
## Generating code for `#[track_caller]` callees
7979

@@ -157,8 +157,8 @@ probably the best we can do without modifying fully-stabilized type signatures.
157157

158158
The `#[track_caller]` attribute is checked alongside other codegen attrs to ensure the function:
159159

160-
* is not a foreign import (e.g. in an `extern {...}` block)
161160
* has `"Rust"` ABI (as opposed to `"C"`, etc...)
161+
* is not a foreign import (e.g. in an `extern {...}` block)
162162
* is not a closure
163163
* is not `#[naked]`
164164

@@ -168,13 +168,13 @@ used in both const and codegen contexts to ensure correct propagation.
168168

169169
### Traits
170170

171-
When applied to a trait method prototype, the attribute takes effect on all implementations of the
172-
trait method. When applied to a default trait method implementation, the attribute takes effect on
173-
that implementation *and* any overrides. It is valid to apply the attribute to a regular
174-
implementation of a trait method, regardless of whether the defining trait does. It is a no-op to
175-
apply the attribute to trait methods with the attribute in the trait definition, but a valid one.
171+
When applied to trait method implementations, the attribute works as it does for regular functions.
172+
173+
When applied to a trait method prototype, the attribute applies to all implementations of the
174+
method. When applied to a default trait method implementation, the attribute takes effect on
175+
that implementation *and* any overrides.
176176

177-
Example:
177+
Examples:
178178

179179
```rust
180180
#![feature(track_caller)]

0 commit comments

Comments
 (0)