mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 10:33:34 +00:00
Merge pull request #2971 from topecongiro/issue-2969
Use span_ends_with_comma to find a trailing comma in an attribute
This commit is contained in:
commit
4484609583
@ -217,11 +217,8 @@ impl Rewrite for ast::MetaItem {
|
||||
ast::MetaItemKind::List(ref list) => {
|
||||
let path = rewrite_path(context, PathContext::Type, None, &self.ident, shape)?;
|
||||
|
||||
let snippet = context.snippet(self.span);
|
||||
// 2 = )] (this might go wrong if there is whitespace between the brackets, but
|
||||
// it's close enough).
|
||||
let snippet = snippet[..snippet.len() - 2].trim();
|
||||
let trailing_comma = if snippet.ends_with(',') { "," } else { "" };
|
||||
let has_comma = ::expr::span_ends_with_comma(context, self.span);
|
||||
let trailing_comma = if has_comma { "," } else { "" };
|
||||
let combine = list.len() == 1 && match list[0].node {
|
||||
ast::NestedMetaItemKind::Literal(..) => false,
|
||||
ast::NestedMetaItemKind::MetaItem(ref inner_meta_item) => {
|
||||
|
@ -190,3 +190,23 @@ pub struct Params {
|
||||
job: Option<Job>
|
||||
}
|
||||
}
|
||||
|
||||
// #2969
|
||||
#[cfg(not(all(feature="std",
|
||||
any(target_os = "linux", target_os = "android",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "haiku",
|
||||
target_os = "emscripten",
|
||||
target_os = "solaris",
|
||||
target_os = "cloudabi",
|
||||
target_os = "macos", target_os = "ios",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd", target_os = "bitrig",
|
||||
target_os = "redox",
|
||||
target_os = "fuchsia",
|
||||
windows,
|
||||
all(target_arch = "wasm32", feature = "stdweb"),
|
||||
all(target_arch = "wasm32", feature = "wasm-bindgen"),
|
||||
))))]
|
||||
type Os = NoSource;
|
||||
|
@ -219,3 +219,29 @@ mod issue_2620 {
|
||||
job: Option<Job>,
|
||||
}
|
||||
}
|
||||
|
||||
// #2969
|
||||
#[cfg(not(all(
|
||||
feature = "std",
|
||||
any(
|
||||
target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "haiku",
|
||||
target_os = "emscripten",
|
||||
target_os = "solaris",
|
||||
target_os = "cloudabi",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "bitrig",
|
||||
target_os = "redox",
|
||||
target_os = "fuchsia",
|
||||
windows,
|
||||
all(target_arch = "wasm32", feature = "stdweb"),
|
||||
all(target_arch = "wasm32", feature = "wasm-bindgen"),
|
||||
)
|
||||
)))]
|
||||
type Os = NoSource;
|
||||
|
Loading…
Reference in New Issue
Block a user