Merge pull request #2400 from csmoe/support_immovable_generators
Support immovable generators
This commit is contained in:
commit
2fb6bd3b9f
6 changed files with 93 additions and 58 deletions
62
Cargo.lock
generated
62
Cargo.lock
generated
|
|
@ -106,7 +106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "getopts"
|
||||
version = "0.2.15"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
|
@ -159,7 +159,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.1.41"
|
||||
version = "0.1.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
|
@ -223,7 +223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "rustc-ap-rustc_cratesio_shim"
|
||||
version = "12.0.0"
|
||||
version = "26.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -232,57 +232,57 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustc-ap-rustc_data_structures"
|
||||
version = "12.0.0"
|
||||
version = "26.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot_core 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-ap-rustc_errors"
|
||||
version = "12.0.0"
|
||||
version = "26.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_data_structures 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-syntax_pos 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-ap-serialize"
|
||||
version = "12.0.0"
|
||||
version = "26.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-ap-syntax"
|
||||
version = "12.0.0"
|
||||
version = "26.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_cratesio_shim 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_cratesio_shim 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_data_structures 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_errors 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-syntax_pos 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-ap-syntax_pos"
|
||||
version = "12.0.0"
|
||||
version = "26.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_data_structures 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-serialize 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -300,14 +300,14 @@ dependencies = [
|
|||
"derive-new 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-syntax 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-rustc_errors 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-ap-syntax 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -362,7 +362,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
|
||||
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
|
||||
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
||||
"checksum getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "65922871abd2f101a2eb0eaebadc66668e54a87ad9c3dd82520b5f86ede5eff9"
|
||||
"checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05"
|
||||
"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
|
||||
|
|
@ -505,7 +505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
|
||||
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
|
||||
"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
|
||||
"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
|
||||
"checksum num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9936036cc70fe4a8b2d338ab665900323290efb03983c86cbe235ae800ad8017"
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e7f7c9857874e54afeb950eebeae662b1e51a2493666d2ea4c0a5d91dcf0412"
|
||||
"checksum parking_lot_core 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "9f35048d735bb93dd115a0030498785971aab3234d311fbe273d020084d26bd8"
|
||||
|
|
@ -513,12 +513,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)" = "512870020642bb8c221bf68baa1b2573da814f6ccfe5c9699b1c303047abe9b1"
|
||||
"checksum regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "744554e01ccbd98fff8c457c3b092cd67af62a555a43bfe97ae8a0451f7799fa"
|
||||
"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
|
||||
"checksum rustc-ap-rustc_cratesio_shim 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a51c10af5abd5d698b7e3487e869e6d15f6feb04cbedb5c792e2824f9d845e"
|
||||
"checksum rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1aa227490501072780d57f74b1164d361833ff8e172f817da0da2cdf2e4280cc"
|
||||
"checksum rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21ff6c6e13ac4fc04b7d4d398828b024c4b6577045cb3175b33d35fea35ff6d0"
|
||||
"checksum rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b4e7f51e298675c2bf830f7265621a8936fb09e63b825b58144cbaac969e604"
|
||||
"checksum rustc-ap-syntax 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf5639869ba2f7fa581939cd217cb71a85506b82ad0ea520614fb0dceb2386c"
|
||||
"checksum rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1c020cdb7379e1c733ae0a311ae47c748337ba584d2dd7b7f53baaae78de6f8b"
|
||||
"checksum rustc-ap-rustc_cratesio_shim 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c883f9a3e52bfc3bd463ab7747aa04ebec864ed04f0ee42327b308910e6e58a"
|
||||
"checksum rustc-ap-rustc_data_structures 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee5b8955de8d85b55d91e38e7f45ec0b92a6ebdede45a782e8e6d3341eb4ac98"
|
||||
"checksum rustc-ap-rustc_errors 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f36946ec337c31859627baadf0992a3bfd87b0ff568978cd06cc17a4113f5243"
|
||||
"checksum rustc-ap-serialize 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2aaabc8226d2e06ac2d22c63a24a0fb36b03f53523979094a4dcdb78dc09d05"
|
||||
"checksum rustc-ap-syntax 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23f04ea1fc07186bea53269436162d0eb7acadb9ea56d52de3b5723c871296c6"
|
||||
"checksum rustc-ap-syntax_pos 26.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9e43797465d858dfd39cd27cc484085a832f09dc10c3df617c0b7927d6e2a0d1"
|
||||
"checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
|
||||
"checksum semver 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bee2bc909ab2d8d60dab26e8cad85b25d795b14603a0dcb627b78b9d30b6454b"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ env_logger = "0.4"
|
|||
getopts = "0.2"
|
||||
derive-new = "0.5"
|
||||
cargo_metadata = "0.4"
|
||||
rustc-ap-syntax = "12.0.0"
|
||||
rustc-ap-rustc_errors = "12.0.0"
|
||||
rustc-ap-syntax = "26.0.0"
|
||||
rustc-ap-rustc_errors = "26.0.0"
|
||||
|
||||
[dev-dependencies]
|
||||
lazy_static = "1.0.0"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ use utils::{last_line_width, left_most_sub_expr, stmt_expr};
|
|||
|
||||
pub fn rewrite_closure(
|
||||
capture: ast::CaptureBy,
|
||||
movability: ast::Movability,
|
||||
fn_decl: &ast::FnDecl,
|
||||
body: &ast::Expr,
|
||||
span: Span,
|
||||
|
|
@ -42,7 +43,7 @@ pub fn rewrite_closure(
|
|||
debug!("rewrite_closure {:?}", body);
|
||||
|
||||
let (prefix, extra_offset) =
|
||||
rewrite_closure_fn_decl(capture, fn_decl, body, span, context, shape)?;
|
||||
rewrite_closure_fn_decl(capture, movability, fn_decl, body, span, context, shape)?;
|
||||
// 1 = space between `|...|` and body.
|
||||
let body_shape = shape.offset_left(extra_offset)?;
|
||||
|
||||
|
|
@ -194,6 +195,7 @@ fn rewrite_closure_block(
|
|||
// Return type is (prefix, extra_offset)
|
||||
fn rewrite_closure_fn_decl(
|
||||
capture: ast::CaptureBy,
|
||||
movability: ast::Movability,
|
||||
fn_decl: &ast::FnDecl,
|
||||
body: &ast::Expr,
|
||||
span: Span,
|
||||
|
|
@ -205,9 +207,17 @@ fn rewrite_closure_fn_decl(
|
|||
} else {
|
||||
""
|
||||
};
|
||||
|
||||
let immovable = if movability == ast::Movability::Static {
|
||||
"static "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
// 4 = "|| {".len(), which is overconservative when the closure consists of
|
||||
// a single expression.
|
||||
let nested_shape = shape.shrink_left(mover.len())?.sub_width(4)?;
|
||||
let nested_shape = shape
|
||||
.shrink_left(mover.len() + immovable.len())?
|
||||
.sub_width(4)?;
|
||||
|
||||
// 1 = |
|
||||
let argument_offset = nested_shape.indent + 1;
|
||||
|
|
@ -254,7 +264,7 @@ fn rewrite_closure_fn_decl(
|
|||
config: context.config,
|
||||
};
|
||||
let list_str = write_list(&item_vec, &fmt)?;
|
||||
let mut prefix = format!("{}|{}|", mover, list_str);
|
||||
let mut prefix = format!("{}{}|{}|", immovable, mover, list_str);
|
||||
|
||||
if !ret_str.is_empty() {
|
||||
if prefix.contains('\n') {
|
||||
|
|
@ -278,7 +288,7 @@ pub fn rewrite_last_closure(
|
|||
expr: &ast::Expr,
|
||||
shape: Shape,
|
||||
) -> Option<String> {
|
||||
if let ast::ExprKind::Closure(capture, ref fn_decl, ref body, _) = expr.node {
|
||||
if let ast::ExprKind::Closure(capture, movability, ref fn_decl, ref body, _) = expr.node {
|
||||
let body = match body.node {
|
||||
ast::ExprKind::Block(ref block)
|
||||
if !is_unsafe_block(block) && is_simple_block(block, context.codemap) =>
|
||||
|
|
@ -287,8 +297,15 @@ pub fn rewrite_last_closure(
|
|||
}
|
||||
_ => body,
|
||||
};
|
||||
let (prefix, extra_offset) =
|
||||
rewrite_closure_fn_decl(capture, fn_decl, body, expr.span, context, shape)?;
|
||||
let (prefix, extra_offset) = rewrite_closure_fn_decl(
|
||||
capture,
|
||||
movability,
|
||||
fn_decl,
|
||||
body,
|
||||
expr.span,
|
||||
context,
|
||||
shape,
|
||||
)?;
|
||||
// If the closure goes multi line before its body, do not overflow the closure.
|
||||
if prefix.contains('\n') {
|
||||
return None;
|
||||
|
|
|
|||
42
src/expr.rs
42
src/expr.rs
|
|
@ -135,16 +135,16 @@ pub fn format_expr(
|
|||
ast::ExprKind::AssignOp(ref op, ref lhs, ref rhs) => {
|
||||
rewrite_assignment(context, lhs, rhs, Some(op), shape)
|
||||
}
|
||||
ast::ExprKind::Continue(ref opt_ident) => {
|
||||
let id_str = match *opt_ident {
|
||||
Some(ident) => format!(" {}", ident.node),
|
||||
ast::ExprKind::Continue(ref opt_label) => {
|
||||
let id_str = match *opt_label {
|
||||
Some(label) => format!(" {}", label.ident),
|
||||
None => String::new(),
|
||||
};
|
||||
Some(format!("continue{}", id_str))
|
||||
}
|
||||
ast::ExprKind::Break(ref opt_ident, ref opt_expr) => {
|
||||
let id_str = match *opt_ident {
|
||||
Some(ident) => format!(" {}", ident.node),
|
||||
ast::ExprKind::Break(ref opt_label, ref opt_expr) => {
|
||||
let id_str = match *opt_label {
|
||||
Some(label) => format!(" {}", label.ident),
|
||||
None => String::new(),
|
||||
};
|
||||
|
||||
|
|
@ -159,8 +159,16 @@ pub fn format_expr(
|
|||
} else {
|
||||
Some("yield".to_string())
|
||||
},
|
||||
ast::ExprKind::Closure(capture, ref fn_decl, ref body, _) => {
|
||||
closures::rewrite_closure(capture, fn_decl, body, expr.span, context, shape)
|
||||
ast::ExprKind::Closure(capture, movability, ref fn_decl, ref body, _) => {
|
||||
closures::rewrite_closure(
|
||||
capture,
|
||||
movability,
|
||||
fn_decl,
|
||||
body,
|
||||
expr.span,
|
||||
context,
|
||||
shape,
|
||||
)
|
||||
}
|
||||
ast::ExprKind::Try(..)
|
||||
| ast::ExprKind::Field(..)
|
||||
|
|
@ -718,7 +726,7 @@ struct ControlFlow<'a> {
|
|||
cond: Option<&'a ast::Expr>,
|
||||
block: &'a ast::Block,
|
||||
else_block: Option<&'a ast::Expr>,
|
||||
label: Option<ast::SpannedIdent>,
|
||||
label: Option<ast::Label>,
|
||||
pat: Option<&'a ast::Pat>,
|
||||
keyword: &'a str,
|
||||
matcher: &'a str,
|
||||
|
|
@ -795,11 +803,7 @@ impl<'a> ControlFlow<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn new_loop(
|
||||
block: &'a ast::Block,
|
||||
label: Option<ast::SpannedIdent>,
|
||||
span: Span,
|
||||
) -> ControlFlow<'a> {
|
||||
fn new_loop(block: &'a ast::Block, label: Option<ast::Label>, span: Span) -> ControlFlow<'a> {
|
||||
ControlFlow {
|
||||
cond: None,
|
||||
block: block,
|
||||
|
|
@ -819,7 +823,7 @@ impl<'a> ControlFlow<'a> {
|
|||
pat: Option<&'a ast::Pat>,
|
||||
cond: &'a ast::Expr,
|
||||
block: &'a ast::Block,
|
||||
label: Option<ast::SpannedIdent>,
|
||||
label: Option<ast::Label>,
|
||||
span: Span,
|
||||
) -> ControlFlow<'a> {
|
||||
ControlFlow {
|
||||
|
|
@ -844,7 +848,7 @@ impl<'a> ControlFlow<'a> {
|
|||
pat: &'a ast::Pat,
|
||||
cond: &'a ast::Expr,
|
||||
block: &'a ast::Block,
|
||||
label: Option<ast::SpannedIdent>,
|
||||
label: Option<ast::Label>,
|
||||
span: Span,
|
||||
) -> ControlFlow<'a> {
|
||||
ControlFlow {
|
||||
|
|
@ -1166,9 +1170,9 @@ impl<'a> Rewrite for ControlFlow<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn rewrite_label(label: Option<ast::SpannedIdent>) -> Cow<'static, str> {
|
||||
match label {
|
||||
Some(ident) => Cow::from(format!("{}: ", ident.node)),
|
||||
fn rewrite_label(opt_label: Option<ast::Label>) -> Cow<'static, str> {
|
||||
match opt_label {
|
||||
Some(label) => Cow::from(format!("{}: ", label.ident)),
|
||||
None => Cow::from(""),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7
tests/source/immovable_generators.rs
Normal file
7
tests/source/immovable_generators.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![feature(generators)]
|
||||
|
||||
unsafe fn foo() {
|
||||
let mut ga = static || {
|
||||
yield 1;
|
||||
};
|
||||
}
|
||||
7
tests/target/immovable_generators.rs
Normal file
7
tests/target/immovable_generators.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![feature(generators)]
|
||||
|
||||
unsafe fn foo() {
|
||||
let mut ga = static || {
|
||||
yield 1;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue