-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Gramar, and spelin kleanup #10487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gramar, and spelin kleanup #10487
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
You may need following tooltips to catch up with common operations. | ||
|
||
- [Common tools for writing lints](#common-tools-for-writing-lints) | ||
- [Retrieving the type of an expression](#retrieving-the-type-of-an-expression) | ||
- [Retrieving the type of expression](#retrieving-the-type-of-expression) | ||
- [Checking if an expr is calling a specific method](#checking-if-an-expr-is-calling-a-specific-method) | ||
- [Checking for a specific type](#checking-for-a-specific-type) | ||
- [Checking if a type implements a specific trait](#checking-if-a-type-implements-a-specific-trait) | ||
|
@@ -16,7 +16,7 @@ Useful Rustc dev guide links: | |
- [Type checking](https://rustc-dev-guide.rust-lang.org/type-checking.html) | ||
- [Ty module](https://rustc-dev-guide.rust-lang.org/ty.html) | ||
|
||
## Retrieving the type of an expression | ||
## Retrieving the type of expression | ||
|
||
Sometimes you may want to retrieve the type `Ty` of an expression `Expr`, for | ||
example to answer following questions: | ||
|
@@ -45,7 +45,7 @@ impl LateLintPass<'_> for MyStructLint { | |
} | ||
``` | ||
|
||
Similarly in [`TypeckResults`][TypeckResults] methods, you have the | ||
Similarly, in [`TypeckResults`][TypeckResults] methods, you have the | ||
[`pat_ty()`][pat_ty] method to retrieve a type from a pattern. | ||
|
||
Two noticeable items here: | ||
|
@@ -192,7 +192,7 @@ functions to deal with macros: | |
- `span.from_expansion()`: detects if a span is from macro expansion or | ||
desugaring. Checking this is a common first step in a lint. | ||
|
||
```rust | ||
```rust,ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The The rendering seems to work on GH just fine either way: let x = 0; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xFrednet oops, just saw your reply, thx for patience :) The reason I added it there was because some IDEs (and most like all IDEs in the future) treat any code inside the triple backticks as valid code, and try to help with it. In this case, the code is incorrect (e.g. it has a tripple dot instead of a real code: |
||
if expr.span.from_expansion() { | ||
// just forget it | ||
return; | ||
|
@@ -203,11 +203,11 @@ functions to deal with macros: | |
if so, which macro call expanded it. It is sometimes useful to check if the | ||
context of two spans are equal. | ||
|
||
```rust | ||
```rust,ignore | ||
// expands to `1 + 0`, but don't lint | ||
1 + mac!() | ||
``` | ||
```rust | ||
```rust,ignore | ||
if left.span.ctxt() != right.span.ctxt() { | ||
// the coder most likely cannot modify this expression | ||
return; | ||
|
@@ -246,7 +246,7 @@ functions to deal with macros: | |
`macro_rules!` with `a == $b`, `$b` is expanded to some expression with a | ||
different context from `a`. | ||
|
||
```rust | ||
```rust,ignore | ||
macro_rules! m { | ||
($a:expr, $b:expr) => { | ||
if $a.is_some() { | ||
|
Uh oh!
There was an error while loading. Please reload this page.