-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #77069 - sexxi-goose:closure_print_2, r=nikomatsakis
pretty.rs: Update Closure and Generator print More detailed outline: rust-lang/project-rfc-2229#17 Closes: rust-lang/project-rfc-2229#11 r? `@nikomatsakis` cc `@eddyb` `@davidtwco` `@estebank`
- Loading branch information
Showing
41 changed files
with
513 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
fn to_fn_once<F: FnOnce()>(f: F) -> F { | ||
f | ||
} | ||
|
||
fn f<T: std::fmt::Display>(y: T) { | ||
struct Foo<U: std::fmt::Display> { | ||
x: U, | ||
}; | ||
|
||
let foo = Foo { x: "x" }; | ||
|
||
let c = to_fn_once(move || { | ||
println!("{} {}", foo.x, y); | ||
}); | ||
|
||
c(); | ||
c(); | ||
//~^ ERROR use of moved value | ||
} | ||
|
||
fn main() { | ||
f("S"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0382]: use of moved value: `c` | ||
--> $DIR/closure-print-generic-1.rs:17:5 | ||
| | ||
LL | let c = to_fn_once(move || { | ||
| - move occurs because `c` has type `[closure@$DIR/closure-print-generic-1.rs:12:24: 14:6]`, which does not implement the `Copy` trait | ||
... | ||
LL | c(); | ||
| --- `c` moved due to this call | ||
LL | c(); | ||
| ^ value used here after move | ||
| | ||
note: this value implements `FnOnce`, which causes it to be moved when called | ||
--> $DIR/closure-print-generic-1.rs:16:5 | ||
| | ||
LL | c(); | ||
| ^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0382`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
mod mod1 { | ||
pub fn f<T: std::fmt::Display>(t: T) { | ||
let x = 20; | ||
|
||
let c = || println!("{} {}", t, x); | ||
let c1: () = c; | ||
//~^ ERROR mismatched types | ||
} | ||
} | ||
|
||
fn main() { | ||
mod1::f(5i32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/closure-print-generic-2.rs:6:22 | ||
| | ||
LL | let c = || println!("{} {}", t, x); | ||
| -------------------------- the found closure | ||
LL | let c1: () = c; | ||
| -- ^ expected `()`, found closure | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected unit type `()` | ||
found closure `[closure@$DIR/closure-print-generic-2.rs:5:17: 5:43]` | ||
help: use parentheses to call this closure | ||
| | ||
LL | let c1: () = c(); | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
Oops, something went wrong.