Merge pull request #5788 from calebcartwright/subtree-sync-2023-06-19
sync subtree in prep for next release
This commit is contained in:
commit
ec8a4d41f1
26
CHANGELOG.md
26
CHANGELOG.md
@ -37,6 +37,32 @@
|
||||
- Prevent ICE when parsing invalid attributes in `cfg_if!` macros [#5728](https://github.com/rust-lang/rustfmt/issues/5728)
|
||||
|
||||
|
||||
## [1.5.2] 2023-01-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Resolve issue when comments are found within const generic defaults in unit structs [#5668](https://github.com/rust-lang/rustfmt/issues/5668)
|
||||
- Resolve issue when block comments are found within trait generics [#5358](https://github.com/rust-lang/rustfmt/issues/5358)
|
||||
- Correctly handle alignment of comments containing unicode characters [#5504](https://github.com/rust-lang/rustfmt/issues/5504)
|
||||
- Properly indent a single generic bound that requires being written across multiple lines [#4689](https://github.com/rust-lang/rustfmt/issues/4689) (n.b. this change is version gated and will only appear when the `version` configuration option is set to `Two`)
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed `fn_args_layout` configuration option to `fn_params_layout` [#4149](https://github.com/rust-lang/rustfmt/issues/4149). Note that `fn_args_layout` has only been soft deprecated: `fn_args_layout` will continue to work without issue, but rustfmt will display a warning to encourage users to switch to the new name
|
||||
|
||||
### Added
|
||||
|
||||
- New configuration option (`skip_macro_invocations`)[https://rust-lang.github.io/rustfmt/?version=master&search=#skip_macro_invocations] [#5347](https://github.com/rust-lang/rustfmt/pull/5347) that can be used to globally define a single enumerated list of macro calls that rustfmt should skip formatting. rustfmt [currently also supports this via a custom tool attribute](https://github.com/rust-lang/rustfmt#tips), however, these cannot be used in all contexts because [custom inner attributes are unstable](https://github.com/rust-lang/rust/issues/54726)
|
||||
|
||||
### Misc
|
||||
|
||||
- rustfmt now internally supports the ability to have both stable and unstable variants of a configuration option [#5378](https://github.com/rust-lang/rustfmt/issues/5378). This ability will allow the rustfmt team to make certain configuration options available on stable toolchains more quickly because we no longer have to wait for _every_ variant to be stable-ready before stabilizing _any_ variant.
|
||||
|
||||
### Install/Download Options
|
||||
- **rustup (nightly)** - nightly-2023-01-24
|
||||
- **GitHub Release Binaries** - [Release v1.5.2](https://github.com/rust-lang/rustfmt/releases/tag/v1.5.2)
|
||||
- **Build from source** - [Tag v1.5.2](https://github.com/rust-lang/rustfmt/tree/v1.5.2), see instructions for how to [install rustfmt from source][install-from-source]
|
||||
|
||||
## [1.5.2] 2023-01-24
|
||||
|
||||
### Fixed
|
||||
|
@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2023-01-24"
|
||||
channel = "nightly-2023-06-19"
|
||||
components = ["llvm-tools", "rustc-dev"]
|
||||
|
16
src/attr.rs
16
src/attr.rs
@ -2,7 +2,7 @@
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::HasAttrs;
|
||||
use rustc_span::{symbol::sym, Span, Symbol};
|
||||
use rustc_span::{symbol::sym, Span};
|
||||
|
||||
use self::doc_comment::DocCommentFormatter;
|
||||
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};
|
||||
@ -19,20 +19,6 @@ use crate::utils::{count_newlines, mk_sp};
|
||||
|
||||
mod doc_comment;
|
||||
|
||||
pub(crate) fn contains_name(attrs: &[ast::Attribute], name: Symbol) -> bool {
|
||||
attrs.iter().any(|attr| attr.has_name(name))
|
||||
}
|
||||
|
||||
pub(crate) fn first_attr_value_str_by_name(
|
||||
attrs: &[ast::Attribute],
|
||||
name: Symbol,
|
||||
) -> Option<Symbol> {
|
||||
attrs
|
||||
.iter()
|
||||
.find(|attr| attr.has_name(name))
|
||||
.and_then(|attr| attr.value_str())
|
||||
}
|
||||
|
||||
/// Returns attributes on the given statement.
|
||||
pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
|
||||
stmt.attrs()
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(rustc_private)]
|
||||
|
||||
use anyhow::{format_err, Result};
|
||||
|
||||
use io::Error as IoError;
|
||||
@ -19,7 +21,14 @@ use crate::rustfmt::{
|
||||
FormatReportFormatterBuilder, Input, Session, Verbosity,
|
||||
};
|
||||
|
||||
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rustfmt/issues/new?labels=bug";
|
||||
|
||||
// N.B. these crates are loaded from the sysroot, so they need extern crate.
|
||||
extern crate rustc_driver;
|
||||
|
||||
fn main() {
|
||||
rustc_driver::install_ice_hook(BUG_REPORT_URL, |_| ());
|
||||
|
||||
env_logger::Builder::from_env("RUSTFMT_LOG").init();
|
||||
let opts = make_opts();
|
||||
|
||||
|
@ -74,6 +74,8 @@ use crate::utils::{
|
||||
rewrite_ident, trimmed_last_line_width, wrap_str,
|
||||
};
|
||||
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
/// Provides the original input contents from the span
|
||||
/// of a chain element with trailing spaces trimmed.
|
||||
fn format_overflow_style(span: Span, context: &RewriteContext<'_>) -> Option<String> {
|
||||
@ -168,7 +170,7 @@ enum ChainItemKind {
|
||||
MethodCall(
|
||||
ast::PathSegment,
|
||||
Vec<ast::GenericArg>,
|
||||
Vec<ptr::P<ast::Expr>>,
|
||||
ThinVec<ptr::P<ast::Expr>>,
|
||||
),
|
||||
StructField(symbol::Ident),
|
||||
TupleField(symbol::Ident, bool),
|
||||
@ -230,7 +232,7 @@ impl ChainItemKind {
|
||||
let span = mk_sp(nested.span.hi(), field.span.hi());
|
||||
(kind, span)
|
||||
}
|
||||
ast::ExprKind::Await(ref nested) => {
|
||||
ast::ExprKind::Await(ref nested, _) => {
|
||||
let span = mk_sp(nested.span.hi(), expr.span.hi());
|
||||
(ChainItemKind::Await, span)
|
||||
}
|
||||
@ -457,7 +459,7 @@ impl Chain {
|
||||
ast::ExprKind::MethodCall(ref call) => Some(Self::convert_try(&call.receiver, context)),
|
||||
ast::ExprKind::Field(ref subexpr, _)
|
||||
| ast::ExprKind::Try(ref subexpr)
|
||||
| ast::ExprKind::Await(ref subexpr) => Some(Self::convert_try(subexpr, context)),
|
||||
| ast::ExprKind::Await(ref subexpr, _) => Some(Self::convert_try(subexpr, context)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use rustc_ast::{ast, ptr};
|
||||
use rustc_span::Span;
|
||||
use thin_vec::thin_vec;
|
||||
|
||||
use crate::attr::get_attrs_from_stmt;
|
||||
use crate::config::lists::*;
|
||||
@ -150,7 +151,7 @@ fn rewrite_closure_with_block(
|
||||
}
|
||||
|
||||
let block = ast::Block {
|
||||
stmts: vec![ast::Stmt {
|
||||
stmts: thin_vec![ast::Stmt {
|
||||
id: ast::NodeId::root(),
|
||||
kind: ast::StmtKind::Expr(ptr::P(body.clone())),
|
||||
span: body.span,
|
||||
@ -194,7 +195,6 @@ fn rewrite_closure_expr(
|
||||
| ast::ExprKind::Struct(..) => true,
|
||||
|
||||
ast::ExprKind::AddrOf(_, _, ref expr)
|
||||
| ast::ExprKind::Box(ref expr)
|
||||
| ast::ExprKind::Try(ref expr)
|
||||
| ast::ExprKind::Unary(_, ref expr)
|
||||
| ast::ExprKind::Cast(ref expr, _) => allow_multi_line(expr),
|
||||
@ -440,7 +440,6 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
|
||||
ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true,
|
||||
ast::ExprKind::Loop(..) if version == Version::Two => true,
|
||||
ast::ExprKind::AddrOf(_, _, ref expr)
|
||||
| ast::ExprKind::Box(ref expr)
|
||||
| ast::ExprKind::Try(ref expr)
|
||||
| ast::ExprKind::Unary(_, ref expr)
|
||||
| ast::ExprKind::Cast(ref expr, _) => is_block_closure_forced_inner(expr, version),
|
||||
|
18
src/expr.rs
18
src/expr.rs
@ -218,7 +218,7 @@ pub(crate) fn format_expr(
|
||||
ast::ExprKind::Try(..)
|
||||
| ast::ExprKind::Field(..)
|
||||
| ast::ExprKind::MethodCall(..)
|
||||
| ast::ExprKind::Await(_) => rewrite_chain(expr, context, shape),
|
||||
| ast::ExprKind::Await(_, _) => rewrite_chain(expr, context, shape),
|
||||
ast::ExprKind::MacCall(ref mac) => {
|
||||
rewrite_macro(mac, None, context, shape, MacroPosition::Expression).or_else(|| {
|
||||
wrap_str(
|
||||
@ -236,7 +236,6 @@ pub(crate) fn format_expr(
|
||||
ast::ExprKind::Yeet(Some(ref expr)) => {
|
||||
rewrite_unary_prefix(context, "do yeet ", &**expr, shape)
|
||||
}
|
||||
ast::ExprKind::Box(ref expr) => rewrite_unary_prefix(context, "box ", &**expr, shape),
|
||||
ast::ExprKind::AddrOf(borrow_kind, mutability, ref expr) => {
|
||||
rewrite_expr_addrof(context, borrow_kind, mutability, expr, shape)
|
||||
}
|
||||
@ -367,7 +366,7 @@ pub(crate) fn format_expr(
|
||||
))
|
||||
}
|
||||
}
|
||||
ast::ExprKind::Async(capture_by, _node_id, ref block) => {
|
||||
ast::ExprKind::Async(capture_by, ref block) => {
|
||||
let mover = if capture_by == ast::CaptureBy::Value {
|
||||
"move "
|
||||
} else {
|
||||
@ -400,7 +399,12 @@ pub(crate) fn format_expr(
|
||||
}
|
||||
}
|
||||
ast::ExprKind::Underscore => Some("_".to_owned()),
|
||||
ast::ExprKind::IncludedBytes(..) => unreachable!(),
|
||||
ast::ExprKind::FormatArgs(..)
|
||||
| ast::ExprKind::IncludedBytes(..)
|
||||
| ast::ExprKind::OffsetOf(..) => {
|
||||
// These do not occur in the AST because macros aren't expanded.
|
||||
unreachable!()
|
||||
}
|
||||
ast::ExprKind::Err => None,
|
||||
};
|
||||
|
||||
@ -1296,7 +1300,6 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
|
||||
ast::ExprKind::Lit(..) => true,
|
||||
ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1,
|
||||
ast::ExprKind::AddrOf(_, _, ref expr)
|
||||
| ast::ExprKind::Box(ref expr)
|
||||
| ast::ExprKind::Cast(ref expr, _)
|
||||
| ast::ExprKind::Field(ref expr, _)
|
||||
| ast::ExprKind::Try(ref expr)
|
||||
@ -1358,7 +1361,6 @@ pub(crate) fn can_be_overflowed_expr(
|
||||
|
||||
// Handle unary-like expressions
|
||||
ast::ExprKind::AddrOf(_, _, ref expr)
|
||||
| ast::ExprKind::Box(ref expr)
|
||||
| ast::ExprKind::Try(ref expr)
|
||||
| ast::ExprKind::Unary(_, ref expr)
|
||||
| ast::ExprKind::Cast(ref expr, _) => can_be_overflowed_expr(context, expr, args_len),
|
||||
@ -1370,7 +1372,6 @@ pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool {
|
||||
match expr.kind {
|
||||
ast::ExprKind::Call(..) | ast::ExprKind::MacCall(..) => true,
|
||||
ast::ExprKind::AddrOf(_, _, ref expr)
|
||||
| ast::ExprKind::Box(ref expr)
|
||||
| ast::ExprKind::Try(ref expr)
|
||||
| ast::ExprKind::Unary(_, ref expr)
|
||||
| ast::ExprKind::Cast(ref expr, _) => is_nested_call(expr),
|
||||
@ -1890,7 +1891,7 @@ impl<'ast> RhsAssignKind<'ast> {
|
||||
ast::ExprKind::Try(..)
|
||||
| ast::ExprKind::Field(..)
|
||||
| ast::ExprKind::MethodCall(..)
|
||||
| ast::ExprKind::Await(_)
|
||||
| ast::ExprKind::Await(_, _)
|
||||
)
|
||||
}
|
||||
_ => false,
|
||||
@ -2132,7 +2133,6 @@ pub(crate) fn is_method_call(expr: &ast::Expr) -> bool {
|
||||
match expr.kind {
|
||||
ast::ExprKind::MethodCall(..) => true,
|
||||
ast::ExprKind::AddrOf(_, _, ref expr)
|
||||
| ast::ExprKind::Box(ref expr)
|
||||
| ast::ExprKind::Cast(ref expr, _)
|
||||
| ast::ExprKind::Try(ref expr)
|
||||
| ast::ExprKind::Unary(_, ref expr) => is_method_call(expr),
|
||||
|
26
src/items.rs
26
src/items.rs
@ -1823,13 +1823,15 @@ pub(crate) struct StaticParts<'a> {
|
||||
|
||||
impl<'a> StaticParts<'a> {
|
||||
pub(crate) fn from_item(item: &'a ast::Item) -> Self {
|
||||
let (defaultness, prefix, ty, mutability, expr) = match item.kind {
|
||||
ast::ItemKind::Static(ref ty, mutability, ref expr) => {
|
||||
(None, "static", ty, mutability, expr)
|
||||
}
|
||||
ast::ItemKind::Const(defaultness, ref ty, ref expr) => {
|
||||
(Some(defaultness), "const", ty, ast::Mutability::Not, expr)
|
||||
}
|
||||
let (defaultness, prefix, ty, mutability, expr) = match &item.kind {
|
||||
ast::ItemKind::Static(s) => (None, "static", &s.ty, s.mutability, &s.expr),
|
||||
ast::ItemKind::Const(c) => (
|
||||
Some(c.defaultness),
|
||||
"const",
|
||||
&c.ty,
|
||||
ast::Mutability::Not,
|
||||
&c.expr,
|
||||
),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
StaticParts {
|
||||
@ -1845,10 +1847,8 @@ impl<'a> StaticParts<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn from_trait_item(ti: &'a ast::AssocItem) -> Self {
|
||||
let (defaultness, ty, expr_opt) = match ti.kind {
|
||||
ast::AssocItemKind::Const(defaultness, ref ty, ref expr_opt) => {
|
||||
(defaultness, ty, expr_opt)
|
||||
}
|
||||
let (defaultness, ty, expr_opt) = match &ti.kind {
|
||||
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
StaticParts {
|
||||
@ -1864,8 +1864,8 @@ impl<'a> StaticParts<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn from_impl_item(ii: &'a ast::AssocItem) -> Self {
|
||||
let (defaultness, ty, expr) = match ii.kind {
|
||||
ast::AssocItemKind::Const(defaultness, ref ty, ref expr) => (defaultness, ty, expr),
|
||||
let (defaultness, ty, expr) = match &ii.kind {
|
||||
ast::AssocItemKind::Const(c) => (c.defaultness, &c.ty, &c.expr),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
StaticParts {
|
||||
|
@ -20,6 +20,7 @@ extern crate rustc_expand;
|
||||
extern crate rustc_parse;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
extern crate thin_vec;
|
||||
|
||||
// Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta
|
||||
// files.
|
||||
|
@ -13,7 +13,7 @@ use std::collections::HashMap;
|
||||
use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
|
||||
use rustc_ast::token::{BinOpToken, Delimiter, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{Cursor, TokenStream, TokenTree};
|
||||
use rustc_ast::tokenstream::{TokenStream, TokenTree, TokenTreeCursor};
|
||||
use rustc_ast::{ast, ptr};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_span::{
|
||||
@ -736,7 +736,7 @@ impl MacroArgParser {
|
||||
self.buf.clear();
|
||||
}
|
||||
|
||||
fn add_meta_variable(&mut self, iter: &mut Cursor) -> Option<()> {
|
||||
fn add_meta_variable(&mut self, iter: &mut TokenTreeCursor) -> Option<()> {
|
||||
match iter.next() {
|
||||
Some(TokenTree::Token(
|
||||
Token {
|
||||
@ -768,7 +768,7 @@ impl MacroArgParser {
|
||||
&mut self,
|
||||
inner: Vec<ParsedMacroArg>,
|
||||
delim: Delimiter,
|
||||
iter: &mut Cursor,
|
||||
iter: &mut TokenTreeCursor,
|
||||
) -> Option<()> {
|
||||
let mut buffer = String::new();
|
||||
let mut first = true;
|
||||
@ -1120,11 +1120,11 @@ pub(crate) fn macro_style(mac: &ast::MacCall, context: &RewriteContext<'_>) -> D
|
||||
// A very simple parser that just parses a macros 2.0 definition into its branches.
|
||||
// Currently we do not attempt to parse any further than that.
|
||||
struct MacroParser {
|
||||
toks: Cursor,
|
||||
toks: TokenTreeCursor,
|
||||
}
|
||||
|
||||
impl MacroParser {
|
||||
const fn new(toks: Cursor) -> Self {
|
||||
const fn new(toks: TokenTreeCursor) -> Self {
|
||||
Self { toks }
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,6 @@ fn can_flatten_block_around_this(body: &ast::Expr) -> bool {
|
||||
| ast::ExprKind::Struct(..)
|
||||
| ast::ExprKind::Tup(..) => true,
|
||||
ast::ExprKind::AddrOf(_, _, ref expr)
|
||||
| ast::ExprKind::Box(ref expr)
|
||||
| ast::ExprKind::Try(ref expr)
|
||||
| ast::ExprKind::Unary(_, ref expr)
|
||||
| ast::ExprKind::Index(ref expr, _)
|
||||
|
@ -6,6 +6,7 @@ use rustc_ast::ast;
|
||||
use rustc_ast::visit::Visitor;
|
||||
use rustc_span::symbol::{self, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use thin_vec::ThinVec;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::attr::MetaVisitor;
|
||||
@ -25,7 +26,7 @@ type FileModMap<'ast> = BTreeMap<FileName, Module<'ast>>;
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct Module<'a> {
|
||||
ast_mod_kind: Option<Cow<'a, ast::ModKind>>,
|
||||
pub(crate) items: Cow<'a, Vec<rustc_ast::ptr::P<ast::Item>>>,
|
||||
pub(crate) items: Cow<'a, ThinVec<rustc_ast::ptr::P<ast::Item>>>,
|
||||
inner_attr: ast::AttrVec,
|
||||
pub(crate) span: Span,
|
||||
}
|
||||
@ -34,7 +35,7 @@ impl<'a> Module<'a> {
|
||||
pub(crate) fn new(
|
||||
mod_span: Span,
|
||||
ast_mod_kind: Option<Cow<'a, ast::ModKind>>,
|
||||
mod_items: Cow<'a, Vec<rustc_ast::ptr::P<ast::Item>>>,
|
||||
mod_items: Cow<'a, ThinVec<rustc_ast::ptr::P<ast::Item>>>,
|
||||
mod_attrs: Cow<'a, ast::AttrVec>,
|
||||
) -> Self {
|
||||
let inner_attr = mod_attrs
|
||||
@ -157,7 +158,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
||||
Module::new(
|
||||
module_item.item.span,
|
||||
Some(Cow::Owned(sub_mod_kind.clone())),
|
||||
Cow::Owned(vec![]),
|
||||
Cow::Owned(ThinVec::new()),
|
||||
Cow::Owned(ast::AttrVec::new()),
|
||||
),
|
||||
)?;
|
||||
@ -169,7 +170,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
||||
/// Visit modules defined inside macro calls.
|
||||
fn visit_mod_outside_ast(
|
||||
&mut self,
|
||||
items: Vec<rustc_ast::ptr::P<ast::Item>>,
|
||||
items: ThinVec<rustc_ast::ptr::P<ast::Item>>,
|
||||
) -> Result<(), ModuleResolutionError> {
|
||||
for item in items {
|
||||
if is_cfg_if(&item) {
|
||||
@ -184,7 +185,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
||||
Module::new(
|
||||
span,
|
||||
Some(Cow::Owned(sub_mod_kind.clone())),
|
||||
Cow::Owned(vec![]),
|
||||
Cow::Owned(ThinVec::new()),
|
||||
Cow::Owned(ast::AttrVec::new()),
|
||||
),
|
||||
)?;
|
||||
@ -210,7 +211,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
||||
Module::new(
|
||||
span,
|
||||
Some(Cow::Borrowed(sub_mod_kind)),
|
||||
Cow::Owned(vec![]),
|
||||
Cow::Owned(ThinVec::new()),
|
||||
Cow::Borrowed(&item.attrs),
|
||||
),
|
||||
)?;
|
||||
|
@ -2,12 +2,12 @@ use std::panic::{catch_unwind, AssertUnwindSafe};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rustc_ast::token::TokenKind;
|
||||
use rustc_ast::{ast, ptr};
|
||||
use rustc_ast::{ast, attr, ptr};
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_parse::{new_parser_from_file, parser::Parser as RawParser};
|
||||
use rustc_span::{sym, Span};
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
use crate::attr::first_attr_value_str_by_name;
|
||||
use crate::parse::session::ParseSess;
|
||||
use crate::Input;
|
||||
|
||||
@ -92,7 +92,7 @@ pub(crate) enum ParserError {
|
||||
|
||||
impl<'a> Parser<'a> {
|
||||
pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
|
||||
let path_sym = first_attr_value_str_by_name(attrs, sym::path)?;
|
||||
let path_sym = attr::first_attr_value_str_by_name(attrs, sym::path)?;
|
||||
let path_str = path_sym.as_str();
|
||||
|
||||
// On windows, the base path might have the form
|
||||
@ -109,7 +109,7 @@ impl<'a> Parser<'a> {
|
||||
sess: &'a ParseSess,
|
||||
path: &Path,
|
||||
span: Span,
|
||||
) -> Result<(ast::AttrVec, Vec<ptr::P<ast::Item>>, Span), ParserError> {
|
||||
) -> Result<(ast::AttrVec, ThinVec<ptr::P<ast::Item>>, Span), ParserError> {
|
||||
let result = catch_unwind(AssertUnwindSafe(|| {
|
||||
let mut parser = new_parser_from_file(sess.inner(), path, Some(span));
|
||||
match parser.parse_mod(&TokenKind::Eof) {
|
||||
|
@ -4,7 +4,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use rustc_data_structures::sync::{Lrc, Send};
|
||||
use rustc_errors::emitter::{Emitter, EmitterWriter};
|
||||
use rustc_errors::translation::Translate;
|
||||
use rustc_errors::{ColorConfig, Diagnostic, Handler, Level as DiagnosticLevel};
|
||||
use rustc_errors::{ColorConfig, Diagnostic, Handler, Level as DiagnosticLevel, TerminalUrl};
|
||||
use rustc_session::parse::ParseSess as RawParseSess;
|
||||
use rustc_span::{
|
||||
source_map::{FilePathMapping, SourceMap},
|
||||
@ -135,8 +135,10 @@ fn default_handler(
|
||||
let emitter = if hide_parse_errors {
|
||||
silent_emitter()
|
||||
} else {
|
||||
let fallback_bundle =
|
||||
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
|
||||
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
|
||||
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
||||
false,
|
||||
);
|
||||
Box::new(EmitterWriter::stderr(
|
||||
emit_color,
|
||||
Some(source_map.clone()),
|
||||
@ -147,6 +149,7 @@ fn default_handler(
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
TerminalUrl::No,
|
||||
))
|
||||
};
|
||||
Handler::with_emitter(
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
use std::cmp::{Ord, Ordering};
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::{ast, attr};
|
||||
use rustc_span::{symbol::sym, Span};
|
||||
|
||||
use crate::config::{Config, GroupImportsTactic};
|
||||
@ -167,7 +167,7 @@ fn rewrite_reorderable_or_regroupable_items(
|
||||
}
|
||||
|
||||
fn contains_macro_use_attr(item: &ast::Item) -> bool {
|
||||
crate::attr::contains_name(&item.attrs, sym::macro_use)
|
||||
attr::contains_name(&item.attrs, sym::macro_use)
|
||||
}
|
||||
|
||||
/// Divides imports into three groups, corresponding to standard, external
|
||||
|
@ -552,6 +552,12 @@ impl Rewrite for ast::GenericBound {
|
||||
ast::TraitBoundModifier::MaybeConstMaybe => poly_trait_ref
|
||||
.rewrite(context, shape.offset_left(8)?)
|
||||
.map(|s| format!("~const ?{}", s)),
|
||||
ast::TraitBoundModifier::Negative => poly_trait_ref
|
||||
.rewrite(context, shape.offset_left(1)?)
|
||||
.map(|s| format!("!{}", s)),
|
||||
ast::TraitBoundModifier::MaybeConstNegative => poly_trait_ref
|
||||
.rewrite(context, shape.offset_left(8)?)
|
||||
.map(|s| format!("~const !{}", s)),
|
||||
};
|
||||
rewrite.map(|s| if has_paren { format!("({})", s) } else { s })
|
||||
}
|
||||
|
@ -463,6 +463,7 @@ pub(crate) fn first_line_ends_with(s: &str, c: char) -> bool {
|
||||
pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr: &str) -> bool {
|
||||
match expr.kind {
|
||||
ast::ExprKind::MacCall(..)
|
||||
| ast::ExprKind::FormatArgs(..)
|
||||
| ast::ExprKind::Call(..)
|
||||
| ast::ExprKind::MethodCall(..)
|
||||
| ast::ExprKind::Array(..)
|
||||
@ -491,7 +492,6 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
|
||||
| ast::ExprKind::Assign(..)
|
||||
| ast::ExprKind::AssignOp(..)
|
||||
| ast::ExprKind::Await(..)
|
||||
| ast::ExprKind::Box(..)
|
||||
| ast::ExprKind::Break(..)
|
||||
| ast::ExprKind::Cast(..)
|
||||
| ast::ExprKind::Continue(..)
|
||||
@ -499,6 +499,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
|
||||
| ast::ExprKind::Field(..)
|
||||
| ast::ExprKind::IncludedBytes(..)
|
||||
| ast::ExprKind::InlineAsm(..)
|
||||
| ast::ExprKind::OffsetOf(..)
|
||||
| ast::ExprKind::Let(..)
|
||||
| ast::ExprKind::Path(..)
|
||||
| ast::ExprKind::Range(..)
|
||||
|
@ -3,7 +3,6 @@
|
||||
// Test expressions
|
||||
|
||||
fn foo() -> bool {
|
||||
let boxed: Box<i32> = box 5;
|
||||
let referenced = &5 ;
|
||||
|
||||
let very_long_variable_name = ( a + first + simple + test );
|
||||
@ -132,12 +131,6 @@ fn qux() {
|
||||
}
|
||||
}
|
||||
|
||||
fn issue227() {
|
||||
{
|
||||
let handler = box DocumentProgressHandler::new(addr, DocumentProgressTask::DOMContentLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
fn issue184(source: &str) {
|
||||
for c in source.chars() {
|
||||
if index < 'a' {
|
||||
@ -413,10 +406,6 @@ fn issue2704() {
|
||||
.concat(&requires1)
|
||||
.concat(&requires2)
|
||||
.distinct_total());
|
||||
let requires = requires.set(box requires0
|
||||
.concat(&requires1)
|
||||
.concat(&requires2)
|
||||
.distinct_total());
|
||||
let requires = requires.set(requires0
|
||||
.concat(&requires1)
|
||||
.concat(&requires2)
|
||||
|
@ -1,10 +0,0 @@
|
||||
|
||||
fn main() {
|
||||
let xxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy : SomeTrait<AA, BB, CC>;
|
||||
|
||||
let xxxxxxxxxxxxxxx = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
|
||||
|
||||
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww): AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
|
||||
|
||||
x : u32 - 1u32 / 10f32 : u32
|
||||
}
|
@ -108,12 +108,6 @@ fn main() {
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
|
||||
));
|
||||
|
||||
// Box
|
||||
foo(box Bar {
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
|
||||
});
|
||||
|
||||
// Unary
|
||||
foo(!bar(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
||||
|
@ -96,12 +96,6 @@ fn main() {
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
|
||||
));
|
||||
|
||||
// Box
|
||||
foo(box Bar {
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
|
||||
});
|
||||
|
||||
// Unary
|
||||
foo(!bar(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
||||
|
@ -1,10 +1,6 @@
|
||||
// rustfmt-format_macro_bodies: true
|
||||
|
||||
macro_rules! foo {
|
||||
($a: ident : $b: ty) => {
|
||||
$a(42): $b;
|
||||
};
|
||||
($a: ident $b: ident $c: ident) => {
|
||||
$a = $b + $c;
|
||||
};
|
||||
($a: ident : $b: ty) => { $a(42): $b; };
|
||||
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
|
||||
}
|
||||
|
@ -1,10 +1,6 @@
|
||||
// rustfmt-format_macro_matchers: false
|
||||
|
||||
macro_rules! foo {
|
||||
($a: ident : $b: ty) => {
|
||||
$a(42): $b;
|
||||
};
|
||||
($a: ident $b: ident $c: ident) => {
|
||||
$a = $b + $c;
|
||||
};
|
||||
($a: ident : $b: ty) => { $a(42): $b; };
|
||||
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
|
||||
}
|
||||
|
@ -1,10 +1,6 @@
|
||||
// rustfmt-format_macro_matchers: true
|
||||
|
||||
macro_rules! foo {
|
||||
($a:ident : $b:ty) => {
|
||||
$a(42): $b;
|
||||
};
|
||||
($a:ident $b:ident $c:ident) => {
|
||||
$a = $b + $c;
|
||||
};
|
||||
($a: ident : $b: ty) => { $a(42): $b; };
|
||||
($a: ident $b: ident $c: ident) => { $a=$b+$c; };
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
// Test expressions
|
||||
|
||||
fn foo() -> bool {
|
||||
let boxed: Box<i32> = box 5;
|
||||
let referenced = &5;
|
||||
|
||||
let very_long_variable_name = (a + first + simple + test);
|
||||
@ -179,13 +178,6 @@ fn qux() {
|
||||
}
|
||||
}
|
||||
|
||||
fn issue227() {
|
||||
{
|
||||
let handler =
|
||||
box DocumentProgressHandler::new(addr, DocumentProgressTask::DOMContentLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
fn issue184(source: &str) {
|
||||
for c in source.chars() {
|
||||
if index < 'a' {
|
||||
@ -454,12 +446,6 @@ fn issue2704() {
|
||||
.concat(&requires2)
|
||||
.distinct_total(),
|
||||
);
|
||||
let requires = requires.set(
|
||||
box requires0
|
||||
.concat(&requires1)
|
||||
.concat(&requires2)
|
||||
.distinct_total(),
|
||||
);
|
||||
let requires = requires.set(
|
||||
requires0
|
||||
.concat(&requires1)
|
||||
|
@ -122,7 +122,7 @@ fn main() {
|
||||
20, 21, 22);
|
||||
|
||||
// #1092
|
||||
chain!(input, a: take!(max_size), || []);
|
||||
chain!(input, a:take!(max_size), || []);
|
||||
|
||||
// #2727
|
||||
foo!("bar");
|
||||
@ -156,17 +156,13 @@ fn issue1178() {
|
||||
}
|
||||
|
||||
fn issue1739() {
|
||||
sql_function!(
|
||||
add_rss_item,
|
||||
sql_function!(add_rss_item,
|
||||
add_rss_item_t,
|
||||
(
|
||||
a: types::Integer,
|
||||
(a: types::Integer,
|
||||
b: types::Timestamptz,
|
||||
c: types::Text,
|
||||
d: types::Text,
|
||||
e: types::Text
|
||||
)
|
||||
);
|
||||
e: types::Text));
|
||||
|
||||
w.slice_mut(s![
|
||||
..,
|
||||
@ -232,7 +228,7 @@ fn issue_3174() {
|
||||
"debugMessage": debug.message,
|
||||
})
|
||||
} else {
|
||||
json!({ "errorKind": format!("{:?}", error.err_kind()) })
|
||||
json!({"errorKind": format!("{:?}", error.err_kind())})
|
||||
};
|
||||
}
|
||||
|
||||
|
11
tests/target/negative-bounds.rs
Normal file
11
tests/target/negative-bounds.rs
Normal file
@ -0,0 +1,11 @@
|
||||
fn negative()
|
||||
where
|
||||
i32: !Copy,
|
||||
{
|
||||
}
|
||||
|
||||
fn maybe_const_negative()
|
||||
where
|
||||
i32: ~const !Copy,
|
||||
{
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
fn main() {
|
||||
let xxxxxxxxxxx =
|
||||
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: SomeTrait<AA, BB, CC>;
|
||||
|
||||
let xxxxxxxxxxxxxxx =
|
||||
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
|
||||
|
||||
let z = funk(yyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzz, wwwwww):
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
|
||||
|
||||
x: u32 - 1u32 / 10f32: u32
|
||||
}
|
@ -129,7 +129,7 @@ fn issue3117() {
|
||||
fn issue3139() {
|
||||
assert_eq!(
|
||||
to_json_value(&None::<i32>).unwrap(),
|
||||
json!({ "test": None::<i32> })
|
||||
json!( { "test": None :: <i32> } )
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user