Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
1a462831ad4c6966f3baabe5cbf21cb9f330ffc4
rust/src/test/ui/generator/yield-in-initializer.rs

18 lines
401 B
Rust
Raw Normal View History

Add `// run-pass` to collection of tests.
2018-09-06 14:41:12 +02:00
// run-pass
Don't count MIR locals as borrowed after StorageDead when finding locals live across a yield terminator
2018-07-31 21:54:30 +02:00
#![feature(generators)]
fn main() {
Make closures and generators a must use types Warn about unused expressions with closure or generator type. This follows existing precedence of must use annotations present on `FnOnce`, `FnMut`, `Fn` traits, which already indirectly apply to closures in some cases, e.g.,: ```rust fn f() -> impl FnOnce() { || {} } fn main() { // an existing warning: unused implementer of `std::ops::FnOnce` that must be used: f(); // a new warning: unused closure that must be used: || {}; } ```
2020-07-28 00:00:00 +00:00
static || { //~ WARN unused generator that must be used
Don't count MIR locals as borrowed after StorageDead when finding locals live across a yield terminator
2018-07-31 21:54:30 +02:00
loop {
// Test that `opt` is not live across the yield, even when borrowed in a loop
// See https://github.com/rust-lang/rust/issues/52792
let opt = {
yield;
true
};
&opt;
}
};
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 1054ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API