Skip to content

Commit 6e01fac

Browse files
committed
Merge pull request #1008 from rust-lang-nursery/hrtb
Don't ignore universal quantification in function types
2 parents d633e83 + 0fae34d commit 6e01fac

File tree

5 files changed

+54
-26
lines changed

5 files changed

+54
-26
lines changed

Cargo.lock

Lines changed: 37 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/patterns.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ impl Rewrite for Pat {
2828
};
2929
let mut_infix = format_mutability(mutability);
3030
let id_str = ident.node.to_string();
31-
3231
let sub_pat = match *sub_pat {
3332
Some(ref p) => {
3433
// 3 - ` @ `.

src/types.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,19 @@ fn rewrite_bare_fn(bare_fn: &ast::BareFnTy,
600600
-> Option<String> {
601601
let mut result = String::with_capacity(128);
602602

603+
if !bare_fn.lifetimes.is_empty() {
604+
result.push_str("for<");
605+
// 6 = "for<> ".len(), 4 = "for<".
606+
// This doesn't work out so nicely for mutliline situation with lots of
607+
// rightward drift. If that is a problem, we could use the list stuff.
608+
result.push_str(&try_opt!(bare_fn.lifetimes
609+
.iter()
610+
.map(|l| l.rewrite(context, try_opt!(width.checked_sub(6)), offset + 4))
611+
.collect::<Option<Vec<_>>>())
612+
.join(", "));
613+
result.push_str("> ");
614+
}
615+
603616
result.push_str(&::utils::format_unsafety(bare_fn.unsafety));
604617

605618
if bare_fn.abi != abi::Abi::Rust {

tests/source/type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ struct F {
1212
i: extern "C" fn(x: u8, /* comment 4*/ y: String, // comment 3
1313
z: Foo, /* comment */ .../* comment 2*/ ),
1414
}
15+
16+
fn issue_1006(def_id_to_string: for<'a, 'b> unsafe fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String) {}

tests/target/type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ struct F {
2121
// comment
2222
... /* comment 2 */),
2323
}
24+
25+
fn issue_1006(def_id_to_string: for<'a, 'b> unsafe fn(TyCtxt<'b, 'tcx, 'tcx>, DefId) -> String) {}

0 commit comments

Comments
 (0)