Skip to content

Commit 41aac15

Browse files
Merge branch 'master' into master
2 parents 3570a72 + 34f9ca2 commit 41aac15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+857
-291
lines changed

.editorconfig

-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,3 @@ indent_size = unset
2121
indent_style = unset
2222
trim_trailing_whitespace = unset
2323
insert_final_newline = unset
24-
25-
[appveyor.yml]
26-
end_of_line = unset

.github/workflows/integration.yml

-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
tempdir,
2828
futures-rs,
2929
rust-clippy,
30-
failure,
3130
]
3231
include:
3332
# Allowed Failures
@@ -63,9 +62,6 @@ jobs:
6362
# Original comment was: temporal build failure due to breaking changes in the nightly compiler
6463
- integration: rust-semverver
6564
allow-failure: true
66-
# Can be moved back to include section after https://github.com/rust-lang-nursery/failure/pull/298 is merged
67-
- integration: failure
68-
allow-failure: true
6965

7066
steps:
7167
- name: checkout

.github/workflows/upload-assets.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ jobs:
4646
shell: bash
4747

4848
- name: Build release binaries
49-
uses: actions-rs/cargo@v1
50-
with:
51-
command: build
52-
args: --release
49+
run: cargo build --release
5350

5451
- name: Build archive
5552
shell: bash

.travis.yml

-77
This file was deleted.

CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22

33
## [Unreleased]
44

5+
## [1.5.2] 2023-01-24
6+
7+
### Fixed
8+
9+
- Resolve issue when comments are found within const generic defaults in unit structs [#5668](https://github.com/rust-lang/rustfmt/issues/5668)
10+
- Resolve issue when block comments are found within trait generics [#5358](https://github.com/rust-lang/rustfmt/issues/5358)
11+
- Correctly handle alignment of comments containing unicode characters [#5504](https://github.com/rust-lang/rustfmt/issues/5504)
12+
- 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`)
13+
14+
### Changed
15+
16+
- 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
17+
18+
### Added
19+
20+
- 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)
21+
22+
### Misc
23+
24+
- 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.
25+
26+
### Install/Download Options
27+
- **rustup (nightly)** - nightly-2023-01-24
28+
- **GitHub Release Binaries** - [Release v1.5.2](https://github.com/rust-lang/rustfmt/releases/tag/v1.5.2)
29+
- **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]
30+
531
## [1.5.1] 2022-06-24
632

733
**N.B** A bug was introduced in v1.5.0/nightly-2022-06-15 which modified formatting. If you happened to run rustfmt over your code with one of those ~10 nightlies it's possible you may have seen formatting changes, and you may see additional changes after this fix since that bug has now been reverted.

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "rustfmt-nightly"
4-
version = "1.5.1"
4+
version = "1.5.2"
55
description = "Tool to find and fix Rust formatting issues"
66
repository = "https://github.com/rust-lang/rustfmt"
77
readme = "README.md"

Configurations.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ fn example() {
425425

426426
## `comment_width`
427427

428-
Maximum length of comments. No effect unless`wrap_comments = true`.
428+
Maximum length of comments. No effect unless `wrap_comments = true`.
429429

430430
- **Default value**: `80`
431431
- **Possible values**: any positive integer
@@ -2997,6 +2997,10 @@ See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_s
29972997

29982998
Break comments to fit on the line
29992999

3000+
Note that no wrapping will happen if:
3001+
1. The comment is the start of a markdown header doc comment
3002+
2. An URL was found in the comment
3003+
30003004
- **Default value**: `false`
30013005
- **Possible values**: `true`, `false`
30023006
- **Stable**: No (tracking issue: [#3347](https://github.com/rust-lang/rustfmt/issues/3347))
@@ -3011,6 +3015,11 @@ Break comments to fit on the line
30113015
// commodo consequat.
30123016

30133017
// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
3018+
3019+
// Information on the lorem ipsum can be found at the following url: https://en.wikipedia.org/wiki/Lorem_ipsum. Its text is: lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
3020+
3021+
/// # This doc comment is a very long header (it starts with a '#'). Had it not been a header it would have been wrapped. But because it is a header, it will not be. That is because wrapping a markdown header breaks it.
3022+
struct Foo {}
30143023
```
30153024

30163025
#### `true`:
@@ -3021,6 +3030,17 @@ Break comments to fit on the line
30213030
// magna aliqua. Ut enim ad minim veniam, quis nostrud
30223031
// exercitation ullamco laboris nisi ut aliquip ex ea
30233032
// commodo consequat.
3033+
3034+
// Lorem ipsum dolor sit amet, consectetur adipiscing elit,
3035+
// sed do eiusmod tempor incididunt ut labore et dolore
3036+
// magna aliqua. Ut enim ad minim veniam, quis nostrud
3037+
// exercitation ullamco laboris nisi ut aliquip ex ea
3038+
// commodo consequat.
3039+
3040+
// Information on the lorem ipsum can be found at the following url: https://en.wikipedia.org/wiki/Lorem_ipsum. Its text is: lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
3041+
3042+
/// # This doc comment is a very long header (it starts with a '#'). Had it not been a header it would have been wrapped. But because it is a header, it will not be. That is because wrapping a markdown header breaks it.
3043+
struct Foo {}
30243044
```
30253045

30263046
# Internal Options

Processes.md

-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,3 @@ git tag -s v1.2.3 -m "Release 1.2.3"
5151
`cargo publish`
5252

5353
## 5. Create a PR to rust-lang/rust to update the rustfmt submodule
54-
55-
Note that if you are updating `rustc-ap-*` crates, then you need to update **every** submodules in the rust-lang/rust repository that depend on the crates to use the same version of those.
56-
57-
As of 2019/05, there are two such crates: `rls` and `racer` (`racer` depends on `rustc-ap-syntax` and `rls` depends on `racer`, and `rls` is one of submodules of the rust-lang/rust repository).

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# rustfmt [![Build Status](https://travis-ci.com/rust-lang/rustfmt.svg?branch=master)](https://travis-ci.com/rust-lang/rustfmt) [![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-lang/rustfmt?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/rustfmt) [![crates.io](https://img.shields.io/crates/v/rustfmt-nightly.svg)](https://crates.io/crates/rustfmt-nightly) [![Travis Configuration Status](https://img.shields.io/travis/davidalber/rustfmt-travis.svg?label=travis%20example)](https://travis-ci.org/davidalber/rustfmt-travis)
1+
# rustfmt [![linux](https://github.com/rust-lang/rustfmt/actions/workflows/linux.yml/badge.svg?event=push)](https://github.com/rust-lang/rustfmt/actions/workflows/linux.yml) [![mac](https://github.com/rust-lang/rustfmt/actions/workflows/mac.yml/badge.svg?event=push)](https://github.com/rust-lang/rustfmt/actions/workflows/mac.yml) [![windows](https://github.com/rust-lang/rustfmt/actions/workflows/windows.yml/badge.svg?event=push)](https://github.com/rust-lang/rustfmt/actions/workflows/windows.yml) [![crates.io](https://img.shields.io/crates/v/rustfmt-nightly.svg)](https://crates.io/crates/rustfmt-nightly)
22

33
A tool for formatting Rust code according to style guidelines.
44

@@ -7,9 +7,7 @@ If you'd like to help out (and you should, it's a fun project!), see
77
Conduct](CODE_OF_CONDUCT.md).
88

99
You can use rustfmt in Travis CI builds. We provide a minimal Travis CI
10-
configuration (see [here](#checking-style-on-a-ci-server)) and verify its status
11-
using another repository. The status of that repository's build is reported by
12-
the "travis example" badge above.
10+
configuration (see [here](#checking-style-on-a-ci-server)).
1311

1412
## Quick start
1513

@@ -135,7 +133,7 @@ completed without error (whether or not changes were made).
135133
* [Emacs](https://github.com/rust-lang/rust-mode)
136134
* [Sublime Text 3](https://packagecontrol.io/packages/RustFmt)
137135
* [Atom](atom.md)
138-
* Visual Studio Code using [vscode-rust](https://github.com/editor-rs/vscode-rust), [vsc-rustfmt](https://github.com/Connorcpu/vsc-rustfmt) or [rls_vscode](https://github.com/jonathandturner/rls_vscode) through RLS.
136+
* [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
139137
* [IntelliJ or CLion](intellij.md)
140138

141139

atom.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Running Rustfmt from Atom
22

3-
## RLS
3+
## rust-analyzer
44

5-
Rustfmt is included with the Rust Language Server, itself provided by [ide-rust](https://atom.io/packages/ide-rust).
5+
Rustfmt can be utilized from [rust-analyzer](https://rust-analyzer.github.io/) which is provided by [ide-rust](https://atom.io/packages/ide-rust).
66

77
`apm install ide-rust`
88

ci/integration.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,28 @@ case ${INTEGRATION} in
9191
cd -
9292
;;
9393
crater)
94-
git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
94+
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
9595
cd ${INTEGRATION}
9696
show_head
9797
check_fmt_with_lib_tests
9898
cd -
9999
;;
100+
bitflags)
101+
git clone --depth=1 https://github.com/bitflags/${INTEGRATION}.git
102+
cd ${INTEGRATION}
103+
show_head
104+
check_fmt_with_all_tests
105+
cd -
106+
;;
107+
error-chain | tempdir)
108+
git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION}.git
109+
cd ${INTEGRATION}
110+
show_head
111+
check_fmt_with_all_tests
112+
cd -
113+
;;
100114
*)
101-
git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
115+
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
102116
cd ${INTEGRATION}
103117
show_head
104118
check_fmt_with_all_tests

rust-toolchain

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2022-08-06"
3-
components = ["rustc-dev"]
2+
channel = "nightly-2023-01-24"
3+
components = ["llvm-tools", "rustc-dev"]

src/attr.rs

+19-15
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
4949
}
5050

5151
/// Returns attributes that are within `outer_span`.
52-
pub(crate) fn filter_inline_attrs(
53-
attrs: &[ast::Attribute],
54-
outer_span: Span,
55-
) -> Vec<ast::Attribute> {
52+
pub(crate) fn filter_inline_attrs(attrs: &[ast::Attribute], outer_span: Span) -> ast::AttrVec {
5653
attrs
5754
.iter()
5855
.filter(|a| outer_span.lo() <= a.span.lo() && a.span.hi() <= outer_span.hi())
@@ -263,7 +260,9 @@ impl Rewrite for ast::NestedMetaItem {
263260
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
264261
match self {
265262
ast::NestedMetaItem::MetaItem(ref meta_item) => meta_item.rewrite(context, shape),
266-
ast::NestedMetaItem::Literal(ref l) => rewrite_literal(context, l, shape),
263+
ast::NestedMetaItem::Lit(ref l) => {
264+
rewrite_literal(context, l.as_token_lit(), l.span, shape)
265+
}
267266
}
268267
}
269268
}
@@ -291,10 +290,10 @@ impl Rewrite for ast::MetaItem {
291290
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
292291
Some(match self.kind {
293292
ast::MetaItemKind::Word => {
294-
rewrite_path(context, PathContext::Type, None, &self.path, shape)?
293+
rewrite_path(context, PathContext::Type, &None, &self.path, shape)?
295294
}
296295
ast::MetaItemKind::List(ref list) => {
297-
let path = rewrite_path(context, PathContext::Type, None, &self.path, shape)?;
296+
let path = rewrite_path(context, PathContext::Type, &None, &self.path, shape)?;
298297
let has_trailing_comma = crate::expr::span_ends_with_comma(context, self.span);
299298
overflow::rewrite_with_parens(
300299
context,
@@ -311,18 +310,18 @@ impl Rewrite for ast::MetaItem {
311310
}),
312311
)?
313312
}
314-
ast::MetaItemKind::NameValue(ref literal) => {
315-
let path = rewrite_path(context, PathContext::Type, None, &self.path, shape)?;
313+
ast::MetaItemKind::NameValue(ref lit) => {
314+
let path = rewrite_path(context, PathContext::Type, &None, &self.path, shape)?;
316315
// 3 = ` = `
317316
let lit_shape = shape.shrink_left(path.len() + 3)?;
318-
// `rewrite_literal` returns `None` when `literal` exceeds max
317+
// `rewrite_literal` returns `None` when `lit` exceeds max
319318
// width. Since a literal is basically unformattable unless it
320319
// is a string literal (and only if `format_strings` is set),
321320
// we might be better off ignoring the fact that the attribute
322321
// is longer than the max width and continue on formatting.
323322
// See #2479 for example.
324-
let value = rewrite_literal(context, literal, lit_shape)
325-
.unwrap_or_else(|| context.snippet(literal.span).to_owned());
323+
let value = rewrite_literal(context, lit.as_token_lit(), lit.span, lit_shape)
324+
.unwrap_or_else(|| context.snippet(lit.span).to_owned());
326325
format!("{} = {}", path, value)
327326
}
328327
})
@@ -528,14 +527,19 @@ pub(crate) trait MetaVisitor<'ast> {
528527

529528
fn visit_meta_word(&mut self, _meta_item: &'ast ast::MetaItem) {}
530529

531-
fn visit_meta_name_value(&mut self, _meta_item: &'ast ast::MetaItem, _lit: &'ast ast::Lit) {}
530+
fn visit_meta_name_value(
531+
&mut self,
532+
_meta_item: &'ast ast::MetaItem,
533+
_lit: &'ast ast::MetaItemLit,
534+
) {
535+
}
532536

533537
fn visit_nested_meta_item(&mut self, nm: &'ast ast::NestedMetaItem) {
534538
match nm {
535539
ast::NestedMetaItem::MetaItem(ref meta_item) => self.visit_meta_item(meta_item),
536-
ast::NestedMetaItem::Literal(ref lit) => self.visit_literal(lit),
540+
ast::NestedMetaItem::Lit(ref lit) => self.visit_meta_item_lit(lit),
537541
}
538542
}
539543

540-
fn visit_literal(&mut self, _lit: &'ast ast::Lit) {}
544+
fn visit_meta_item_lit(&mut self, _lit: &'ast ast::MetaItemLit) {}
541545
}

src/bin/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub enum OperationError {
7575
#[error("{0}")]
7676
IoError(IoError),
7777
/// Attempt to use --emit with a mode which is not currently
78-
/// supported with stdandard input.
78+
/// supported with standard input.
7979
#[error("Emit mode {0} not supported with standard output.")]
8080
StdinBadEmit(EmitMode),
8181
}

0 commit comments

Comments
 (0)