mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 13:36:49 +00:00
Merge pull request #1819 from brainlessdeveloper/fix-extern-crate-whitespace
Remove whitespace between words in extern declarations
This commit is contained in:
commit
47456aaa43
@ -25,6 +25,7 @@ use items::{format_impl, format_trait, rewrite_associated_impl_type, rewrite_ass
|
||||
rewrite_static, rewrite_type_alias};
|
||||
use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorTactic};
|
||||
use macros::{rewrite_macro, MacroPosition};
|
||||
use regex::Regex;
|
||||
use rewrite::{Rewrite, RewriteContext};
|
||||
use utils::{self, contains_skip, mk_sp};
|
||||
|
||||
@ -331,7 +332,14 @@ impl<'a> FmtVisitor<'a> {
|
||||
ast::ItemKind::ExternCrate(_) => {
|
||||
self.format_missing_with_indent(source!(self, item.span).lo);
|
||||
let new_str = self.snippet(item.span);
|
||||
self.buffer.push_str(&new_str);
|
||||
if contains_comment(&new_str) {
|
||||
self.buffer.push_str(&new_str)
|
||||
} else {
|
||||
let no_whitespace =
|
||||
&new_str.split_whitespace().collect::<Vec<&str>>().join(" ");
|
||||
self.buffer
|
||||
.push_str(&Regex::new(r"\s;").unwrap().replace(no_whitespace, ";"));
|
||||
}
|
||||
self.last_pos = source!(self, item.span).hi;
|
||||
}
|
||||
ast::ItemKind::Struct(ref def, ref generics) => {
|
||||
|
@ -1,5 +1,8 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
|
||||
extern crate foo ;
|
||||
extern crate foo as bar ;
|
||||
|
||||
extern "C" {
|
||||
fn c_func(x: *mut *mut libc::c_void);
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
|
||||
extern crate foo;
|
||||
extern crate foo as bar;
|
||||
|
||||
extern "C" {
|
||||
fn c_func(x: *mut *mut libc::c_void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user