Skip to content

Commit

Permalink
Fix tidy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 27, 2019
1 parent 243fb6f commit 5bb70c1
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/librustc_error_codes/error_codes/E0015.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
A constant item was initialized with something that is not a constant expression.
A constant item was initialized with something that is not a constant
expression.

Erroneous code example:

Expand Down
1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0107.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ fn main() {
// expected 0, found 1
}
```

1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0369.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ left and may require reallocation. This requires ownership of the string
on the left. If something should be added to a string literal, move the
literal to the heap by allocating it with `to_owned()` like in
`"Your text".to_owned()`.

1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0404.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ trait Foo {
fn bar<T: Foo>(t: T) {} // ok!
```

1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0458.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ Please specify a valid "kind" value, from one of the following:
* static
* dylib
* framework

1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0633.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ The `#[unwind]` attribute should be used as follows:

NB. The default behavior here is "allowed", but this is unspecified
and likely to change in the future.

1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0635.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ Erroneous code example:
```compile_fail,E0635
#![feature(nonexistent_rust_feature)] // error: unknown feature
```

1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0636.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ Erroneous code example:
#![feature(rust1)]
#![feature(rust1)] // error: the feature `rust1` has already been declared
```

2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes/E0641.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ let a = &(String::from("Hello world!")) as *const _; // Ok
let b = 0 as *const i32; // Ok
let c: *const i32 = 0 as *const _; // Ok
```
```
1 change: 0 additions & 1 deletion src/librustc_error_codes/error_codes/E0644.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ closure call itself by capturing a `&Fn()` object or `fn()` pointer
that refers to itself. That is permitting, since the closure would be
invoking itself via a virtual call, and hence does not directly
reference its own *type*.

20 changes: 11 additions & 9 deletions src/librustc_error_codes/error_codes/E0706.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
`async fn`s are not yet supported in traits in Rust.
`async fn`s are not yet supported in traits in Rust.

Erroneous code example:

Expand All @@ -10,7 +10,8 @@ trait T {
}
```

`async fn`s return an `impl Future`, making the following two examples equivalent:
`async fn`s return an `impl Future`, making the following two examples
equivalent:

```edition2018,ignore (example-of-desugaring-equivalence)
async fn foo() -> User {
Expand All @@ -23,8 +24,8 @@ fn foo(&self) -> impl Future<Output = User> + '_ {
```

But when it comes to supporting this in traits, there are [a few implementation
issues][async-is-hard]. One of them is returning `impl Trait` in traits is not supported,
as it would require [Generic Associated Types] to be supported:
issues][async-is-hard]. One of them is returning `impl Trait` in traits is not
supported, as it would require [Generic Associated Types] to be supported:

```edition2018,ignore (example-of-desugaring-equivalence)
impl MyDatabase {
Expand All @@ -40,13 +41,14 @@ impl MyDatabase {
}
```

Until these issues are resolved, you can use the [`async-trait` crate], allowing you to use
`async fn` in traits by desugaring to "boxed futures"
Until these issues are resolved, you can use the [`async-trait` crate], allowing
you to use `async fn` in traits by desugaring to "boxed futures"
(`Pin<Box<dyn Future + Send + 'async>>`).

Note that using these trait methods will result in a heap allocation per-function-call. This is not
a significant cost for the vast majority of applications, but should be considered when deciding
whether to use this functionality in the public API of a low-level function that is expected to be
Note that using these trait methods will result in a heap allocation
per-function-call. This is not a significant cost for the vast majority of
applications, but should be considered when deciding whether to use this
functionality in the public API of a low-level function that is expected to be
called millions of times a second.

You might be interested in visiting the [async book] for further information.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes/E0745.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn temp_address() {

To avoid the error, first bind the temporary to a named local variable.

```ignore
```ignore (not yet implemented)
# #![feature(raw_ref_op)]
fn temp_address() {
let val = 2;
Expand Down

0 comments on commit 5bb70c1

Please sign in to comment.