Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
InsertCreativityHere authored Mar 8, 2023
2 parents 3570a72 + 34f9ca2 commit 41aac15
Show file tree
Hide file tree
Showing 60 changed files with 857 additions and 291 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ indent_size = unset
indent_style = unset
trim_trailing_whitespace = unset
insert_final_newline = unset

[appveyor.yml]
end_of_line = unset
4 changes: 0 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
tempdir,
futures-rs,
rust-clippy,
failure,
]
include:
# Allowed Failures
Expand Down Expand Up @@ -63,9 +62,6 @@ jobs:
# Original comment was: temporal build failure due to breaking changes in the nightly compiler
- integration: rust-semverver
allow-failure: true
# Can be moved back to include section after https://github.com/rust-lang-nursery/failure/pull/298 is merged
- integration: failure
allow-failure: true

steps:
- name: checkout
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/upload-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ jobs:
shell: bash

- name: Build release binaries
uses: actions-rs/cargo@v1
with:
command: build
args: --release
run: cargo build --release

- name: Build archive
shell: bash
Expand Down
77 changes: 0 additions & 77 deletions .travis.yml

This file was deleted.

26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

## [Unreleased]

## [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.1] 2022-06-24

**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.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "rustfmt-nightly"
version = "1.5.1"
version = "1.5.2"
description = "Tool to find and fix Rust formatting issues"
repository = "https://github.com/rust-lang/rustfmt"
readme = "README.md"
Expand Down
22 changes: 21 additions & 1 deletion Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ fn example() {

## `comment_width`

Maximum length of comments. No effect unless`wrap_comments = true`.
Maximum length of comments. No effect unless `wrap_comments = true`.

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

Break comments to fit on the line

Note that no wrapping will happen if:
1. The comment is the start of a markdown header doc comment
2. An URL was found in the comment

- **Default value**: `false`
- **Possible values**: `true`, `false`
- **Stable**: No (tracking issue: [#3347](https://github.com/rust-lang/rustfmt/issues/3347))
Expand All @@ -3011,6 +3015,11 @@ Break comments to fit on the line
// commodo consequat.

// 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.

// 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.

/// # 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.
struct Foo {}
```

#### `true`:
Expand All @@ -3021,6 +3030,17 @@ Break comments to fit on the line
// magna aliqua. Ut enim ad minim veniam, quis nostrud
// exercitation ullamco laboris nisi ut aliquip ex ea
// commodo consequat.

// 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.

// 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.

/// # 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.
struct Foo {}
```

# Internal Options
Expand Down
4 changes: 0 additions & 4 deletions Processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,3 @@ git tag -s v1.2.3 -m "Release 1.2.3"
`cargo publish`

## 5. Create a PR to rust-lang/rust to update the rustfmt submodule

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.

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).
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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)
# 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)

A tool for formatting Rust code according to style guidelines.

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

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

## Quick start

Expand Down Expand Up @@ -135,7 +133,7 @@ completed without error (whether or not changes were made).
* [Emacs](https://github.com/rust-lang/rust-mode)
* [Sublime Text 3](https://packagecontrol.io/packages/RustFmt)
* [Atom](atom.md)
* 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.
* [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
* [IntelliJ or CLion](intellij.md)


Expand Down
4 changes: 2 additions & 2 deletions atom.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Running Rustfmt from Atom

## RLS
## rust-analyzer

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

`apm install ide-rust`

Expand Down
18 changes: 16 additions & 2 deletions ci/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,28 @@ case ${INTEGRATION} in
cd -
;;
crater)
git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
cd ${INTEGRATION}
show_head
check_fmt_with_lib_tests
cd -
;;
bitflags)
git clone --depth=1 https://github.com/bitflags/${INTEGRATION}.git
cd ${INTEGRATION}
show_head
check_fmt_with_all_tests
cd -
;;
error-chain | tempdir)
git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION}.git
cd ${INTEGRATION}
show_head
check_fmt_with_all_tests
cd -
;;
*)
git clone --depth=1 https://github.com/rust-lang-nursery/${INTEGRATION}.git
git clone --depth=1 https://github.com/rust-lang/${INTEGRATION}.git
cd ${INTEGRATION}
show_head
check_fmt_with_all_tests
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-08-06"
components = ["rustc-dev"]
channel = "nightly-2023-01-24"
components = ["llvm-tools", "rustc-dev"]
34 changes: 19 additions & 15 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
}

/// Returns attributes that are within `outer_span`.
pub(crate) fn filter_inline_attrs(
attrs: &[ast::Attribute],
outer_span: Span,
) -> Vec<ast::Attribute> {
pub(crate) fn filter_inline_attrs(attrs: &[ast::Attribute], outer_span: Span) -> ast::AttrVec {
attrs
.iter()
.filter(|a| outer_span.lo() <= a.span.lo() && a.span.hi() <= outer_span.hi())
Expand Down Expand Up @@ -263,7 +260,9 @@ impl Rewrite for ast::NestedMetaItem {
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
match self {
ast::NestedMetaItem::MetaItem(ref meta_item) => meta_item.rewrite(context, shape),
ast::NestedMetaItem::Literal(ref l) => rewrite_literal(context, l, shape),
ast::NestedMetaItem::Lit(ref l) => {
rewrite_literal(context, l.as_token_lit(), l.span, shape)
}
}
}
}
Expand Down Expand Up @@ -291,10 +290,10 @@ impl Rewrite for ast::MetaItem {
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
Some(match self.kind {
ast::MetaItemKind::Word => {
rewrite_path(context, PathContext::Type, None, &self.path, shape)?
rewrite_path(context, PathContext::Type, &None, &self.path, shape)?
}
ast::MetaItemKind::List(ref list) => {
let path = rewrite_path(context, PathContext::Type, None, &self.path, shape)?;
let path = rewrite_path(context, PathContext::Type, &None, &self.path, shape)?;
let has_trailing_comma = crate::expr::span_ends_with_comma(context, self.span);
overflow::rewrite_with_parens(
context,
Expand All @@ -311,18 +310,18 @@ impl Rewrite for ast::MetaItem {
}),
)?
}
ast::MetaItemKind::NameValue(ref literal) => {
let path = rewrite_path(context, PathContext::Type, None, &self.path, shape)?;
ast::MetaItemKind::NameValue(ref lit) => {
let path = rewrite_path(context, PathContext::Type, &None, &self.path, shape)?;
// 3 = ` = `
let lit_shape = shape.shrink_left(path.len() + 3)?;
// `rewrite_literal` returns `None` when `literal` exceeds max
// `rewrite_literal` returns `None` when `lit` exceeds max
// width. Since a literal is basically unformattable unless it
// is a string literal (and only if `format_strings` is set),
// we might be better off ignoring the fact that the attribute
// is longer than the max width and continue on formatting.
// See #2479 for example.
let value = rewrite_literal(context, literal, lit_shape)
.unwrap_or_else(|| context.snippet(literal.span).to_owned());
let value = rewrite_literal(context, lit.as_token_lit(), lit.span, lit_shape)
.unwrap_or_else(|| context.snippet(lit.span).to_owned());
format!("{} = {}", path, value)
}
})
Expand Down Expand Up @@ -528,14 +527,19 @@ pub(crate) trait MetaVisitor<'ast> {

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

fn visit_meta_name_value(&mut self, _meta_item: &'ast ast::MetaItem, _lit: &'ast ast::Lit) {}
fn visit_meta_name_value(
&mut self,
_meta_item: &'ast ast::MetaItem,
_lit: &'ast ast::MetaItemLit,
) {
}

fn visit_nested_meta_item(&mut self, nm: &'ast ast::NestedMetaItem) {
match nm {
ast::NestedMetaItem::MetaItem(ref meta_item) => self.visit_meta_item(meta_item),
ast::NestedMetaItem::Literal(ref lit) => self.visit_literal(lit),
ast::NestedMetaItem::Lit(ref lit) => self.visit_meta_item_lit(lit),
}
}

fn visit_literal(&mut self, _lit: &'ast ast::Lit) {}
fn visit_meta_item_lit(&mut self, _lit: &'ast ast::MetaItemLit) {}
}
2 changes: 1 addition & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub enum OperationError {
#[error("{0}")]
IoError(IoError),
/// Attempt to use --emit with a mode which is not currently
/// supported with stdandard input.
/// supported with standard input.
#[error("Emit mode {0} not supported with standard output.")]
StdinBadEmit(EmitMode),
}
Expand Down
Loading

0 comments on commit 41aac15

Please sign in to comment.