diff options
| author | jumbatm <jumbatm@gmail.com> | 2020-11-16 17:48:41 +1000 |
|---|---|---|
| committer | Who? Me?! <mark-i-m@users.noreply.github.com> | 2020-12-02 22:34:16 -0600 |
| commit | b2eb38e362a757a0db5a7de665dc65b63b4a80fc (patch) | |
| tree | 5f78eb223ba22a62352f47afa730bc9d8d2d5f2d /src/doc/rustc-dev-guide | |
| parent | ca6075eb909424bcb7aa813568782809dbf4a61f (diff) | |
| download | rust-b2eb38e362a757a0db5a7de665dc65b63b4a80fc.tar.gz rust-b2eb38e362a757a0db5a7de665dc65b63b4a80fc.zip | |
Apply suggestions from review.
Co-authored-by: Camelid <camelidcamel@gmail.com>
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/diagnostics/sessiondiagnostic.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/doc/rustc-dev-guide/src/diagnostics/sessiondiagnostic.md b/src/doc/rustc-dev-guide/src/diagnostics/sessiondiagnostic.md index b64c620071d..4583e6d3dc9 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics/sessiondiagnostic.md +++ b/src/doc/rustc-dev-guide/src/diagnostics/sessiondiagnostic.md @@ -30,8 +30,8 @@ tcx.sess.emit_err(FieldAlreadyDeclared { ``` We see that using `SessionDiagnostic` is relatively straight forward. The `#[error = "..."]` -attribute is used to supply the error code for the diagnostic. We are then annotate fields in the -struct with various information of how to convert an instance of the struct into a proper +attribute is used to supply the error code for the diagnostic. We then annotate fields in the +struct with various information on how to convert an instance of the struct into a rendered diagnostic. The attributes above produce code which is roughly equivalent to the following (in pseudo-Rust): @@ -49,7 +49,7 @@ impl SessionDiagnostic for FieldAlreadyDeclared { ``` The generated code draws attention to a number of features. First, we see that within the strings -passed to each attribute, we see that field names can be referenced without needing to be passed +passed to each attribute, field names can be referenced without needing to be passed explicitly into the format string -- in this example here, `#[message = "field {field_name} is already declared"]` produces a call to `format!` with the appropriate arguments to format `self.field_name` into the string. This applies to strings passed to all attributes. |
