Merge pull request #881 from marcusklaas/nightly-update

Fix tuple destructuring in impl fns
This commit is contained in:
Nick Cameron 2016-03-29 08:03:57 +13:00
commit 9e399463e7
4 changed files with 37 additions and 9 deletions

12
Cargo.lock generated
View File

@ -6,7 +6,7 @@ dependencies = [
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.58 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"strings 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -39,7 +39,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.58 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -52,7 +52,7 @@ name = "kernel32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -79,7 +79,7 @@ dependencies = [
[[package]]
name = "regex"
version = "0.1.56"
version = "0.1.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -125,7 +125,7 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -153,7 +153,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]

View File

@ -20,9 +20,8 @@ use comment::{FindUncommented, contains_comment};
use visitor::FmtVisitor;
use rewrite::{Rewrite, RewriteContext};
use config::{Config, BlockIndentStyle, Density, ReturnIndent, BraceStyle, StructLitStyle};
use syntax::codemap;
use syntax::{ast, abi, ptr};
use syntax::{ast, abi, ptr, codemap};
use syntax::codemap::{Span, BytePos, mk_sp};
use syntax::parse::token;
use syntax::ast::ImplItem;
@ -1477,7 +1476,13 @@ fn rewrite_args(context: &RewriteContext,
// it is explicit.
if args.len() >= min_args || variadic {
let comment_span_start = if min_args == 2 {
let reduced_span = mk_sp(span.lo, args[1].ty.span.lo);
let second_arg_start = if arg_has_pattern(&args[1]) {
args[1].pat.span.lo
} else {
args[1].ty.span.lo
};
let reduced_span = mk_sp(span.lo, second_arg_start);
context.codemap.span_after_last(reduced_span, ",")
} else {
span.lo
@ -1562,6 +1567,19 @@ fn rewrite_args(context: &RewriteContext,
write_list(&arg_items, &fmt)
}
fn arg_has_pattern(arg: &ast::Arg) -> bool {
if let ast::PatKind::Ident(_,
codemap::Spanned {
node: ast::Ident { name: ast::Name(0u32), .. },
..
},
_) = arg.pat.node {
false
} else {
true
}
}
fn compute_budgets_for_args(context: &RewriteContext,
result: &str,
indent: Indent,

View File

@ -73,6 +73,12 @@ impl X { fn do_parse( mut self : X ) {} }
impl Y5000 {
fn bar(self: X< 'a , 'b >, y: Y) {}
fn bad(&self, ( x, y): CoorT) {}
fn turbo_bad(self: X< 'a , 'b > , ( x, y): CoorT) {
}
}
pub impl<T> Foo for Bar<T> where T: Foo

View File

@ -93,6 +93,10 @@ impl X {
impl Y5000 {
fn bar(self: X<'a, 'b>, y: Y) {}
fn bad(&self, (x, y): CoorT) {}
fn turbo_bad(self: X<'a, 'b>, (x, y): CoorT) {}
}
pub impl<T> Foo for Bar<T>