Merge branch 'master' into clippy2

This commit is contained in:
Maximilian Roos 2018-08-31 00:19:12 -04:00
commit b1da2a53b4
No known key found for this signature in database
GPG Key ID: 3232F28BEDA66FCD
9 changed files with 58 additions and 7 deletions

View File

@ -129,8 +129,6 @@ A minimal Travis setup could look like this (requires Rust 1.24.0 or greater):
```yaml
language: rust
rust:
- nightly
before_script:
- rustup component add rustfmt-preview
script:

View File

@ -15,7 +15,7 @@ use syntax::ast::{self, UseTreeKind};
use syntax::source_map::{self, BytePos, Span, DUMMY_SP};
use comment::combine_strs_with_missing_comments;
use config::IndentStyle;
use config::{Edition, IndentStyle};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator};
use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
@ -144,6 +144,7 @@ impl UseSegment {
fn from_path_segment(
context: &RewriteContext,
path_seg: &ast::PathSegment,
modsep: bool,
) -> Option<UseSegment> {
let name = rewrite_ident(context, path_seg.ident);
if name.is_empty() || name == "{{root}}" {
@ -152,7 +153,10 @@ impl UseSegment {
Some(match name {
"self" => UseSegment::Slf(None),
"super" => UseSegment::Super(None),
_ => UseSegment::Ident((*name).to_owned(), None),
_ => {
let mod_sep = if modsep { "::" } else { "" };
UseSegment::Ident(format!("{}{}", mod_sep, name), None)
}
})
}
}
@ -313,8 +317,13 @@ impl UseTree {
visibility,
attrs,
};
let leading_modsep = context.config.edition() == Edition::Edition2018
&& a.prefix.to_string().len() > 2
&& a.prefix.to_string().starts_with("::");
for p in &a.prefix.segments {
if let Some(use_segment) = UseSegment::from_path_segment(context, p) {
if let Some(use_segment) = UseSegment::from_path_segment(context, p, leading_modsep) {
result.path.push(use_segment);
}
}

View File

@ -2232,8 +2232,10 @@ fn rewrite_args(
) -> Option<String> {
let mut arg_item_strs = args
.iter()
.map(|arg| arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent)))
.collect::<Option<Vec<_>>>()?;
.map(|arg| {
arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent))
.unwrap_or_else(|| context.snippet(arg.span()).to_owned())
}).collect::<Vec<_>>();
// Account for sugary self.
// FIXME: the comment for the self argument is dropped. This is blocked

View File

@ -67,3 +67,8 @@ crate fn init() {}
// #2630
fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
// #2956
fn bar(beans: Asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf, spam: bool, eggs: bool) -> bool{
unimplemented!();
}

View File

@ -0,0 +1,7 @@
// rustfmt-edition: Edition2015
#![feature(rust_2018_preview, uniform_paths)]
use futures::prelude::*;
use http_03::cli::Cli;
use hyper::{service::service_fn_ok, Body, Response, Server};
use ::log::{error, info, log};
use structopt::StructOpt;

View File

@ -0,0 +1,7 @@
// rustfmt-edition: Edition2018
#![feature(rust_2018_preview, uniform_paths)]
use futures::prelude::*;
use http_03::cli::Cli;
use hyper::{service::service_fn_ok, Body, Response, Server};
use ::log::{error, info, log};
use structopt::StructOpt;

View File

@ -108,3 +108,12 @@ crate fn init() {}
// #2630
fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
// #2956
fn bar(
beans: Asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf,
spam: bool,
eggs: bool,
) -> bool {
unimplemented!();
}

View File

@ -0,0 +1,7 @@
// rustfmt-edition: Edition2015
#![feature(rust_2018_preview, uniform_paths)]
use futures::prelude::*;
use http_03::cli::Cli;
use hyper::{service::service_fn_ok, Body, Response, Server};
use log::{error, info, log};
use structopt::StructOpt;

View File

@ -0,0 +1,7 @@
// rustfmt-edition: Edition2018
#![feature(rust_2018_preview, uniform_paths)]
use ::log::{error, info, log};
use futures::prelude::*;
use http_03::cli::Cli;
use hyper::{service::service_fn_ok, Body, Response, Server};
use structopt::StructOpt;