Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subtree-push nightly-2024-06-07 #6188

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ae760e6
Address unused tuple struct fields in rustfmt
shepmaster Nov 29, 2023
4a1b418
Rename `unused_tuple_struct_fields` in rustfmt
shepmaster Nov 30, 2023
840824f
Rename `EmitterWriter` as `HumanEmitter`.
nnethercote Jan 4, 2024
250d7e7
Rollup merge of #119601 - nnethercote:Emitter-cleanups, r=oli-obk
compiler-errors Jan 5, 2024
141b31a
Make `DiagnosticBuilder::emit` consuming.
nnethercote Jan 3, 2024
192c4a0
Change how `force-warn` lint diagnostics are recorded.
nnethercote Jan 9, 2024
381ef81
Stop using `DiagnosticBuilder::buffer` in the parser.
nnethercote Jan 11, 2024
6078b96
Delegation implementation: step 1
Bryanskiy Nov 26, 2023
255d2cf
Add `PatKind::Err`
ShE3py Jan 17, 2024
b92320c
Check that a token can begin a nonterminal kind before parsing it as …
compiler-errors Jan 22, 2024
f8847ff
Do not eagerly recover malformed AST in rustfmt
compiler-errors Jan 22, 2024
a095808
Actually, just use nonterminal_may_begin_with
compiler-errors Jan 22, 2024
18f51f7
Make `Emitter::emit_diagnostic` consuming.
nnethercote Feb 2, 2024
88c5838
Lower anonymous structs or unions to HIR
frank-king Jan 4, 2024
16250ea
Add rustfmt test from #117942
frank-king Jan 6, 2024
bed3883
Format async bounds in rustfmt
compiler-errors Feb 13, 2024
e504c64
Rollup merge of #121035 - compiler-errors:rustfmt-asyncness, r=calebc…
GuillaumeGomez Feb 14, 2024
6674be9
Add an `ErrorGuaranteed` to `ast::TyKind::Err`.
nnethercote Feb 14, 2024
aba5f54
errors: only eagerly translate subdiagnostics
davidtwco Feb 14, 2024
2639101
Allow newly added non_local_definitions in rustfmt
Urgau Jan 27, 2024
163c3eb
Rollup merge of #121085 - davidtwco:always-eager-diagnostics, r=nneth…
matthiaskrgr Feb 17, 2024
ce71137
Explicitly call `emit_stashed_diagnostics`.
nnethercote Feb 23, 2024
8c33745
Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
bors Feb 25, 2024
7d82dd0
Add `ast::ExprKind::Dummy`
ShE3py Feb 25, 2024
1bbfb76
Add `ErrorGuaranteed` to `ast::ExprKind::Err`
ShE3py Feb 25, 2024
90af751
Move `emit_stashed_diagnostic` call in rustfmt.
nnethercote Feb 25, 2024
50987bb
Auto merge of #120586 - ShE3py:exprkind-err, r=fmease
bors Feb 26, 2024
c18226d
Rollup merge of #121615 - nnethercote:fix-121517, r=oli-obk
matthiaskrgr Feb 26, 2024
f9dba39
Auto merge of #121636 - matthiaskrgr:rollup-1tt2o5n, r=matthiaskrgr
bors Feb 26, 2024
d84567c
Rename `Diagnostic` as `DiagInner`.
nnethercote Feb 22, 2024
4026fd7
Rename `DiagnosticBuilder` as `Diag`.
nnethercote Feb 22, 2024
45aad17
Reinstate `emit_stashed_diagnostics` in `DiagCtxtInner::drop`.
nnethercote Feb 28, 2024
0811e8f
Rename `DiagCtxt::with_emitter` as `DiagCtxt::new`.
nnethercote Feb 29, 2024
9c85ae8
Inline and remove `HumanEmitter::stderr`.
nnethercote Feb 29, 2024
6f2722b
Rollup merge of #121783 - nnethercote:emitter-cleanups, r=oli-obk
GuillaumeGomez Feb 29, 2024
fc64cbd
AST: Refactor type alias where clauses
fmease Feb 19, 2024
050610e
Rollup merge of #121326 - fmease:detect-empty-leading-where-clauses-o…
matthiaskrgr Feb 29, 2024
0b56261
Tweak `parse_asm_args`.
nnethercote Dec 20, 2023
78c99eb
Rename all `ParseSess` variables/fields/lifetimes as `psess`.
nnethercote Mar 4, 2024
fe9ceab
Rename `DiagnosticMessage` as `DiagMessage`.
nnethercote Feb 29, 2024
124808b
errors: share `SilentEmitter` between rustc and rustfmt
davidtwco Feb 19, 2024
677c1d8
Rewrite the `untranslatable_diagnostic` lint.
nnethercote Feb 20, 2024
f3892a0
Add MatchKind member to the Match expr for pretty printing & fmt
RossSmyth Feb 17, 2024
1709dd5
Add basic rustfmt implementation & test
RossSmyth Feb 17, 2024
5f8d353
Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnosti…
matthiaskrgr Mar 6, 2024
fe0415e
Rename `ast::StmtKind::Local` into `ast::StmtKind::Let`
GuillaumeGomez Mar 14, 2024
911f6a4
conditionally ignore fatal diagnostic in the SilentEmitter
ytmimi Mar 19, 2024
8f62a2d
step cfgs
Mark-Simulacrum Mar 19, 2024
f670f3b
Implement macro-based deref!() syntax for deref patterns
compiler-errors Mar 20, 2024
0aa66d1
Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkov
matthiaskrgr Mar 22, 2024
5e141e0
Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnosti…
matthiaskrgr Mar 24, 2024
645b94c
Implement `mut ref`/`mut ref mut`
Jules-Bertholet Mar 24, 2024
31a4eae
Add rustfmt test for mut ref mut
Jules-Bertholet Mar 27, 2024
fd20426
Rename ModSep to PathSep
fmease Apr 4, 2024
7af33b3
Add pattern types to ast
oli-obk Jan 30, 2023
afa482e
store the span of the nested part of the use tree in the ast
pietroalbini Apr 1, 2024
9400b99
Rustfmt, clippy
compiler-errors Apr 5, 2024
dac1a22
Rollup merge of #123462 - fmease:rn-mod-sep-to-path-sep, r=nnethercote
fmease Apr 15, 2024
a568985
Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obk
bors Apr 16, 2024
932f3ab
Rename `BindingAnnotation` to `BindingMode`
Jules-Bertholet Apr 16, 2024
966dd60
Disallow ambiguous attributes on expressions
voidc Apr 17, 2024
9c0e5f2
Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, r=davi…
matthiaskrgr Apr 23, 2024
20e40d5
Error on using `yield` without also using `#[coroutine]` on the closure
oli-obk Apr 11, 2024
e606bb6
Remove direct dependencies on lazy_static, once_cell and byteorder
GKFX Apr 28, 2024
997d5f2
Move rustfmt changes out
GKFX Apr 28, 2024
fafa690
Add StaticForeignItem and use it on ForeignItemKind
spastorino Apr 29, 2024
27d320d
Rollup merge of #124524 - spastorino:make-foreign-static-use-struct, …
matthiaskrgr Apr 30, 2024
2c70167
Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=Nilstrieb
matthiaskrgr May 8, 2024
05a2db7
delegation: Implement list delegation
petrochenkov Mar 15, 2024
97bdbd9
Rename Unsafe to Safety
spastorino May 17, 2024
a2c6f80
Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup
fmease May 27, 2024
6478d9e
Handle safety keyword for extern block inner items
spastorino May 23, 2024
eeefcd6
Remove `stream_to_parser`.
nnethercote May 31, 2024
5962aa9
Make top-level `rustc_parse` functions fallible.
nnethercote May 31, 2024
ecb2dd1
rustfmt: Remove an unnecessary `catch_unwind` use.
nnethercote Jun 3, 2024
c1ea878
Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk
bors Jun 6, 2024
6f43681
Merge remote-tracking branch 'upstream/master' into subtree-push-nigh…
ytmimi Jun 7, 2024
514a492
bump toolchain to nightly-2024-06-07
ytmimi Jun 7, 2024
1d10f02
make minor tweaks to matching on anon_const based on AST changes
ytmimi Jun 7, 2024
fd3a5cb
allow dead code for `StyleEditionDefault`
ytmimi Jun 7, 2024
b0771aa
Bumped bytecount 0.6.4 -> 0.6.8
ytmimi Jun 7, 2024
fba50ab
remove archived `error-chain` crate from integration tests
ytmimi Apr 20, 2024
e5f5cad
don't apply formatting to builtin type ascription syntax
ytmimi May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
matrix:
integration: [
bitflags,
error-chain,
log,
mdbook,
packed_simd,
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
## [Unreleased]

- Updating `dirs 4.0.0 -> 5.0.1` and `cargo_metadata 0.15.4 -> 0.18.0` [#6033] (https://github.com/rust-lang/rustfmt/issues/6033)
- Bumped bytecount `0.6.4` -> `0.6.8` to fix compilation issues with the `generic-simd` feature. See [bytecount#92] and [bytecount#93]

[bytecount#92]: https://github.com/llogiq/bytecount/pull/92
[bytecount#93]: https://github.com/llogiq/bytecount/pull/93

- Output correct syntax for type ascription builtin [#6159](https://github.com/rust-lang/rustfmt/issues/6159)
```rust
fn main() {
builtin # type_ascribe(10, usize)
}
```

## [1.7.0] 2023-10-22

Expand Down
33 changes: 2 additions & 31 deletions 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
Expand Up @@ -35,7 +35,7 @@ generic-simd = ["bytecount/generic-simd"]
[dependencies]
annotate-snippets = { version = "0.9", features = ["color"] }
anyhow = "1.0"
bytecount = "0.6.4"
bytecount = "0.6.8"
cargo_metadata = "0.18"
clap = { version = "4.4.2", features = ["derive"] }
clap-cargo = "0.12.0"
Expand Down
2 changes: 1 addition & 1 deletion ci/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ case ${INTEGRATION} in
check_fmt_with_all_tests
cd -
;;
error-chain | tempdir)
tempdir)
git clone --depth=1 https://github.com/rust-lang-deprecated/${INTEGRATION}.git
cd ${INTEGRATION}
show_head
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-12-28"
channel = "nightly-2024-06-07"
components = ["llvm-tools", "rustc-dev"]
2 changes: 1 addition & 1 deletion src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {

pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
match stmt.kind {
ast::StmtKind::Local(ref local) => local.span,
ast::StmtKind::Let(ref local) => local.span,
ast::StmtKind::Item(ref item) => item.span,
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => expr.span,
ast::StmtKind::MacCall(ref mac_stmt) => mac_stmt.mac.span(),
Expand Down
4 changes: 2 additions & 2 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1714,10 +1714,10 @@ pub(crate) fn recover_comment_removed(
// We missed some comments. Warn and keep the original text.
if context.config.error_on_unformatted() {
context.report.append(
context.parse_sess.span_to_filename(span),
context.psess.span_to_filename(span),
vec![FormattingError::from_span(
span,
context.parse_sess,
context.psess,
ErrorKind::LostComment,
)],
);
Expand Down
1 change: 1 addition & 0 deletions src/config/style_edition.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::config::StyleEdition;

/// Defines the default value for the given style edition
#[allow(dead_code)]
pub(crate) trait StyleEditionDefault {
type ConfigType;
fn style_edition_default(style_edition: StyleEdition) -> Self::ConfigType;
Expand Down
23 changes: 8 additions & 15 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::cmp::min;

use itertools::Itertools;
use rustc_ast::token::{Delimiter, Lit, LitKind};
use rustc_ast::{ast, ptr, token, ForLoopKind};
use rustc_ast::{ast, ptr, token, ForLoopKind, MatchKind};
use rustc_span::{BytePos, Span};

use crate::chains::rewrite_chain;
Expand Down Expand Up @@ -139,7 +139,7 @@ pub(crate) fn format_expr(
| ast::ExprKind::While(..) => to_control_flow(expr, expr_type)
.and_then(|control_flow| control_flow.rewrite(context, shape)),
ast::ExprKind::ConstBlock(ref anon_const) => {
let rewrite = match anon_const.value.kind {
let rewrite = match anon_const.kind {
ast::ExprKind::Block(ref block, opt_label) => {
// Inner attributes are associated with the `ast::ExprKind::ConstBlock` node,
// not the `ast::Block` node we're about to rewrite. To prevent dropping inner
Expand Down Expand Up @@ -180,8 +180,8 @@ pub(crate) fn format_expr(
}
}
}
ast::ExprKind::Match(ref cond, ref arms) => {
rewrite_match(context, cond, arms, shape, expr.span, &expr.attrs)
ast::ExprKind::Match(ref cond, ref arms, kind) => {
rewrite_match(context, cond, arms, shape, expr.span, &expr.attrs, kind)
}
ast::ExprKind::Path(ref qself, ref path) => {
rewrite_path(context, PathContext::Expr, qself, path, shape)
Expand Down Expand Up @@ -263,14 +263,6 @@ pub(crate) fn format_expr(
shape,
SeparatorPlace::Front,
),
ast::ExprKind::Type(ref expr, ref ty) => rewrite_pair(
&**expr,
&**ty,
PairParts::infix(": "),
context,
shape,
SeparatorPlace::Back,
),
ast::ExprKind::Index(ref expr, ref index, _) => {
rewrite_index(&**expr, &**index, context, shape)
}
Expand Down Expand Up @@ -412,6 +404,7 @@ pub(crate) fn format_expr(
}
ast::ExprKind::Underscore => Some("_".to_owned()),
ast::ExprKind::FormatArgs(..)
| ast::ExprKind::Type(..)
| ast::ExprKind::IncludedBytes(..)
| ast::ExprKind::OffsetOf(..) => {
// These don't normally occur in the AST because macros aren't expanded. However,
Expand All @@ -420,7 +413,7 @@ pub(crate) fn format_expr(
// Also, rustfmt might get passed the output from `-Zunpretty=expanded`.
None
}
ast::ExprKind::Err => None,
ast::ExprKind::Err(_) | ast::ExprKind::Dummy => None,
};

expr_rw
Expand Down Expand Up @@ -641,7 +634,7 @@ pub(crate) fn rewrite_cond(
shape: Shape,
) -> Option<String> {
match expr.kind {
ast::ExprKind::Match(ref cond, _) => {
ast::ExprKind::Match(ref cond, _, MatchKind::Prefix) => {
// `match `cond` {`
let cond_shape = match context.config.indent_style() {
IndentStyle::Visual => shape.shrink_left(6).and_then(|s| s.sub_width(2))?,
Expand Down Expand Up @@ -1963,7 +1956,7 @@ fn rewrite_unary_op(
}

pub(crate) enum RhsAssignKind<'ast> {
Expr(&'ast ast::ExprKind, Span),
Expr(&'ast ast::ExprKind, #[allow(dead_code)] Span),
Bounds,
Ty,
}
Expand Down
54 changes: 23 additions & 31 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn should_skip_module<T: FormatHandler>(
// FIXME(calebcartwright) - we need to determine how we'll handle the
// `format_generated_files` option with stdin based input.
if !input_is_stdin && !config.format_generated_files() {
let source_file = context.parse_session.span_to_file_contents(module.span);
let source_file = context.psess.span_to_file_contents(module.span);
let src = source_file.src.as_ref().expect("SourceFile without src");

if is_generated_file(src, config) {
Expand Down Expand Up @@ -109,15 +109,16 @@ fn format_project<T: FormatHandler>(
let main_file = input.file_name();
let input_is_stdin = main_file == FileName::Stdin;

let parse_session = ParseSess::new(config)?;
if config.skip_children() && parse_session.ignore_file(&main_file) {
let psess = ParseSess::new(config)?;
if config.skip_children() && psess.ignore_file(&main_file) {
return Ok(FormatReport::new());
}

// Parse the crate.
let mut report = FormatReport::new();
let directory_ownership = input.to_directory_ownership();
let krate = match Parser::parse_crate(input, &parse_session) {

let krate = match Parser::parse_crate(input, &psess) {
Ok(krate) => krate,
// Surface parse error via Session (errors are merged there from report)
Err(e) => {
Expand All @@ -130,9 +131,9 @@ fn format_project<T: FormatHandler>(
}
};

let mut context = FormatContext::new(&krate, report, parse_session, config, handler);
let mut context = FormatContext::new(&krate, report, psess, config, handler);
let files = modules::ModResolver::new(
&context.parse_session,
&context.psess,
directory_ownership.unwrap_or(DirectoryOwnership::UnownedViaBlock),
!input_is_stdin && !config.skip_children(),
)
Expand All @@ -147,16 +148,11 @@ fn format_project<T: FormatHandler>(
timer = timer.done_parsing();

// Suppress error output if we have to do any further parsing.
context.parse_session.set_silent_emitter();
context.psess.set_silent_emitter();

for (path, module) in files {
if input_is_stdin && contains_skip(module.attrs()) {
return echo_back_stdin(
context
.parse_session
.snippet_provider(module.span)
.entire_snippet(),
);
return echo_back_stdin(context.psess.snippet_provider(module.span).entire_snippet());
}
should_emit_verbose(input_is_stdin, config, || println!("Formatting {}", path));
context.format_file(path, &module, is_macro_def)?;
Expand All @@ -178,7 +174,7 @@ fn format_project<T: FormatHandler>(
struct FormatContext<'a, T: FormatHandler> {
krate: &'a ast::Crate,
report: FormatReport,
parse_session: ParseSess,
psess: ParseSess,
config: &'a Config,
handler: &'a mut T,
}
Expand All @@ -187,21 +183,21 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
fn new(
krate: &'a ast::Crate,
report: FormatReport,
parse_session: ParseSess,
psess: ParseSess,
config: &'a Config,
handler: &'a mut T,
) -> Self {
FormatContext {
krate,
report,
parse_session,
psess,
config,
handler,
}
}

fn ignore_file(&self, path: &FileName) -> bool {
self.parse_session.ignore_file(path)
self.psess.ignore_file(path)
}

// Formats a single file/module.
Expand All @@ -211,9 +207,9 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
module: &Module<'_>,
is_macro_def: bool,
) -> Result<(), ErrorKind> {
let snippet_provider = self.parse_session.snippet_provider(module.span);
let mut visitor = FmtVisitor::from_parse_sess(
&self.parse_session,
let snippet_provider = self.psess.snippet_provider(module.span);
let mut visitor = FmtVisitor::from_psess(
&self.psess,
self.config,
&snippet_provider,
self.report.clone(),
Expand Down Expand Up @@ -256,7 +252,7 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
.add_non_formatted_ranges(visitor.skipped_range.borrow().clone());

self.handler.handle_formatted_file(
&self.parse_session,
&self.psess,
path,
visitor.buffer.to_owned(),
&mut self.report,
Expand All @@ -268,7 +264,7 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
trait FormatHandler {
fn handle_formatted_file(
&mut self,
parse_session: &ParseSess,
psess: &ParseSess,
path: FileName,
result: String,
report: &mut FormatReport,
Expand All @@ -279,14 +275,14 @@ impl<'b, T: Write + 'b> FormatHandler for Session<'b, T> {
// Called for each formatted file.
fn handle_formatted_file(
&mut self,
parse_session: &ParseSess,
psess: &ParseSess,
path: FileName,
result: String,
report: &mut FormatReport,
) -> Result<(), ErrorKind> {
if let Some(ref mut out) = self.out {
match source_file::write_file(
Some(parse_session),
Some(psess),
&path,
&result,
out,
Expand Down Expand Up @@ -317,17 +313,13 @@ pub(crate) struct FormattingError {
}

impl FormattingError {
pub(crate) fn from_span(
span: Span,
parse_sess: &ParseSess,
kind: ErrorKind,
) -> FormattingError {
pub(crate) fn from_span(span: Span, psess: &ParseSess, kind: ErrorKind) -> FormattingError {
FormattingError {
line: parse_sess.line_of_byte_pos(span.lo()),
line: psess.line_of_byte_pos(span.lo()),
is_comment: kind.is_comment(),
kind,
is_string: false,
line_buffer: parse_sess.span_to_first_line_string(span),
line_buffer: psess.span_to_first_line_string(span),
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ impl UseTree {
version,
});
}
UseTreeKind::Nested(ref list) => {
UseTreeKind::Nested {
items: ref list, ..
} => {
// Extract comments between nested use items.
// This needs to be done before sorting use items.
let items = itemize_list(
Expand Down
Loading
Loading