Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
21b80fe
Remove the `Translator` type
JonathanBrouwer Feb 10, 2026
d414736
Rollup merge of #152455 - JonathanBrouwer:remove_translation, r=jdons…
JonathanBrouwer Feb 20, 2026
110da1a
Merge commit 'cebab3e99259be82ff069e5ae89e91855d79e534' into rustfmt-…
ytmimi Feb 26, 2026
0f08005
add field representing types
BennoLossin Feb 20, 2026
fe2abe5
rustfmt `impl` restriction
CoCo-Japan-pan Feb 23, 2026
7d0e8d3
Rollup merge of #152730 - BennoLossin:field-projections-lang-item, r=…
JonathanBrouwer Feb 28, 2026
432e65e
rustfmt: add test for field representing type builtin syntax
BennoLossin Feb 28, 2026
ea87573
Remember whether a struct literal had syntax errors.
kpreid Mar 1, 2026
433a0a1
Rollup merge of #153227 - kpreid:struct-missing-field, r=estebank
JonathanBrouwer Mar 3, 2026
2e044a7
Rollup merge of #152943 - CoCo-Japan-pan:impl-restriction-parse, r=Ur…
JonathanBrouwer Mar 3, 2026
ebebf24
Consider try blocks as block-like for overflowed expr
ia0 Mar 5, 2026
b8b325e
Move `Spanned`.
nnethercote Mar 10, 2026
d33fa8b
Add macro matcher for `guard` fragment specifier
SpriteOvO Mar 11, 2026
9ab635c
remove usages of to-be-deprecated numeric constants
cyrgani Mar 15, 2026
6304720
Rollup merge of #153702 - SpriteOvO:guard-matcher, r=davidtwco
JonathanBrouwer Mar 25, 2026
e7cbc03
fix: [rustfmt] prevent panic when rewritng associated item delegations
ytmimi Mar 27, 2026
1ae8918
Use fine grained component-wise span tracking in use trees
oli-obk Feb 21, 2026
7fe33db
Update `rustfmt`
CoCo-Japan-pan Apr 18, 2026
78b8a6f
Update AST pretty printing
CoCo-Japan-pan Apr 18, 2026
1ded930
support `ast::ExprKind::Move` in rustfmt
TaKO8Ki Apr 9, 2026
5fe11a2
fix tidy errors
TaKO8Ki Apr 16, 2026
61b29c1
Rustfmt: format const trait impls to `const impl` for syntax transition
fee1-dead May 22, 2026
d09d15e
rustfmt `mut` restriction
CoCo-Japan-pan May 20, 2026
e18b33f
Replace code of conduct with link
apiraino May 24, 2026
1583113
Rollup merge of #156824 - CoCo-Japan-pan:mut-restriction-parse, r=Urg…
jhpratt May 24, 2026
65d4854
Rollup merge of #156879 - apiraino:link-coc-rustfmt, r=ytmimi
JonathanBrouwer May 25, 2026
9896513
Syntactically reject equality predicates
fmease Mar 6, 2026
56e911d
Merge remote-tracking branch 'origin/main' into subtree-push-nightly-…
ytmimi Jun 11, 2026
a932f6d
chore: bump toolchain to nightly-2026-06-10
ytmimi Jun 11, 2026
2fdf133
Revert "Let empty files be empty files"
ytmimi Jun 11, 2026
8aa08f3
fix: update failing tests after reverting changes in the last commit
ytmimi Jun 11, 2026
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
39 changes: 1 addition & 38 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
# The Rust Code of Conduct

A version of this document [can be found online](https://www.rust-lang.org/conduct.html).

## Conduct

**Contact**: [rust-mods@rust-lang.org](mailto:rust-mods@rust-lang.org)

* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic.
* On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all.
* Please be kind and courteous. There's no need to be mean or rude.
* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer.
* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works.
* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the <a href="https://github.com/stumpsyn/policies/blob/master/citizen_code_of_conduct.md/">Citizen Code of Conduct</a>; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups.
* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back.
* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.

## Moderation


These are the policies for upholding our community's standards of conduct. If you feel that a thread needs moderation, please contact the [Rust moderation team][mod_team].

1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.)
2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed.
3. Moderators will first respond to such remarks with a warning.
4. If the warning is unheeded, the user will be "kicked," i.e., kicked out of the communication channel to cool off.
5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded.
6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended party a genuine apology.
7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a different moderator, **in private**. Complaints about bans in-channel are not allowed.
8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate situation, they should expect less leeway than others.

In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely.

And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust.

The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion.

*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).*

[mod_team]: https://www.rust-lang.org/team.html#Moderation-team
The Code of Conduct for this repository [can be found online](https://www.rust-lang.org/conduct.html).
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-2026-02-19"
channel = "nightly-2026-06-10"
components = ["llvm-tools", "rustc-dev"]
17 changes: 15 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ pub(crate) fn format_expr(
let callee_str = callee.rewrite_result(context, shape)?;
rewrite_call(context, &callee_str, args, inner_span, shape)
}
ast::ExprKind::Move(ref subexpr, move_kw_span) => {
let inner_span = mk_sp(move_kw_span.hi(), expr.span.hi());
rewrite_call(
context,
"move",
std::slice::from_ref(subexpr),
inner_span,
shape,
)
}
ast::ExprKind::Paren(ref subexpr) => rewrite_paren(context, subexpr, shape, expr.span),
ast::ExprKind::Binary(op, ref lhs, ref rhs) => {
// FIXME: format comments between operands and operator
Expand Down Expand Up @@ -1489,7 +1499,10 @@ pub(crate) fn can_be_overflowed_expr(
}

// Handle always block-like expressions
ast::ExprKind::Gen(..) | ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => true,
ast::ExprKind::Gen(..)
| ast::ExprKind::Block(..)
| ast::ExprKind::Closure(..)
| ast::ExprKind::TryBlock(..) => true,

// Handle `[]` and `{}`-like expressions
ast::ExprKind::Array(..) | ast::ExprKind::Struct(..) => {
Expand Down Expand Up @@ -1745,7 +1758,7 @@ fn rewrite_struct_lit<'a>(
match struct_rest {
ast::StructRest::Base(expr) => Some(StructLitField::Base(&**expr)),
ast::StructRest::Rest(span) => Some(StructLitField::Rest(*span)),
ast::StructRest::None => None,
ast::StructRest::None | ast::StructRest::NoneWithError(_) => None,
}
.into_iter(),
);
Expand Down
2 changes: 1 addition & 1 deletion src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
.file_lines()
.contains_line(&path, num_newlines + 1)
{
source_file::append_newline(&mut visitor.buffer, self.config.style_edition());
source_file::append_newline(&mut visitor.buffer);
}

format_lines(
Expand Down
14 changes: 7 additions & 7 deletions src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ impl UseTree {
attrs: Option<ast::AttrVec>,
) -> UseTree {
let span = if let Some(lo) = opt_lo {
mk_sp(lo, a.span.hi())
mk_sp(lo, a.hi_span().hi())
} else {
a.span
a.span()
};
let mut result = UseTree {
path: vec![],
Expand All @@ -456,7 +456,7 @@ impl UseTree {
let style_edition = context.config.style_edition();

match a.kind {
UseTreeKind::Glob => {
UseTreeKind::Glob(_) => {
// in case of a global path and the glob starts at the root, e.g., "::*"
if a.prefix.segments.len() == 1 && leading_modsep {
let kind = UseSegmentKind::Ident("".to_owned(), None);
Expand All @@ -480,11 +480,11 @@ impl UseTree {
list.iter().map(|(tree, _)| tree),
"}",
",",
|tree| tree.span.lo(),
|tree| tree.span.hi(),
|tree| tree.prefix.span.lo(),
|tree| tree.hi_span().hi(),
|_| Ok("".to_owned()), // We only need comments for now.
context.snippet_provider.span_after(a.span, "{"),
a.span.hi(),
context.snippet_provider.span_after(a.span(), "{"),
a.hi_span().hi(),
false,
);

Expand Down
11 changes: 7 additions & 4 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ fn format_impl_ref_and_type(

if let Some(of_trait) = of_trait.as_deref() {
result.push_str(format_defaultness(of_trait.defaultness));
result.push_str(format_constness(*constness));
result.push_str(format_safety(of_trait.safety));
} else {
result.push_str(format_constness(*constness));
Expand All @@ -980,7 +981,6 @@ fn format_impl_ref_and_type(

let trait_ref_overhead;
if let Some(of_trait) = of_trait.as_deref() {
result.push_str(format_constness_right(*constness));
let polarity_str = match of_trait.polarity {
ast::ImplPolarity::Negative(_) => "!",
ast::ImplPolarity::Positive => "",
Expand Down Expand Up @@ -1155,6 +1155,7 @@ pub(crate) fn format_trait(
offset: Indent,
) -> RewriteResult {
let ast::Trait {
ref impl_restriction,
constness,
is_auto,
safety,
Expand All @@ -1166,8 +1167,9 @@ pub(crate) fn format_trait(

let mut result = String::with_capacity(128);
let header = format!(
"{}{}{}{}trait ",
"{}{}{}{}{}trait ",
format_visibility(context, &item.vis),
format_impl_restriction(context, impl_restriction),
format_constness(constness),
format_safety(safety),
format_auto(is_auto),
Expand Down Expand Up @@ -1887,15 +1889,16 @@ pub(crate) fn rewrite_struct_field_prefix(
field: &ast::FieldDef,
) -> RewriteResult {
let vis = format_visibility(context, &field.vis);
let mut_restriction = format_mut_restriction(context, &field.mut_restriction);
let safety = format_safety(field.safety);
let type_annotation_spacing = type_annotation_spacing(context.config);
Ok(match field.ident {
Some(name) => format!(
"{vis}{safety}{}{}:",
"{vis}{mut_restriction}{safety}{}{}:",
rewrite_ident(context, name),
type_annotation_spacing.0
),
None => format!("{vis}{safety}"),
None => format!("{vis}{mut_restriction}{safety}"),
})
}

Expand Down
10 changes: 5 additions & 5 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ fn rewrite_match_body(
// The `if ...` guard on a match arm.
fn rewrite_guard(
context: &RewriteContext<'_>,
guard: &Option<Box<ast::Expr>>,
guard: &Option<Box<ast::Guard>>,
shape: Shape,
// The amount of space used up on this line for the pattern in
// the arm (excludes offset).
Expand All @@ -586,7 +586,7 @@ fn rewrite_guard(
.and_then(|s| s.sub_width_opt(5));
if !multiline_pattern {
if let Some(cond_shape) = cond_shape {
if let Ok(cond_str) = guard.rewrite_result(context, cond_shape) {
if let Ok(cond_str) = guard.cond.rewrite_result(context, cond_shape) {
if !cond_str.contains('\n') || pattern_width <= context.config.tab_spaces() {
return Ok(format!(" if {cond_str}"));
}
Expand All @@ -597,9 +597,9 @@ fn rewrite_guard(
// Not enough space to put the guard after the pattern, try a newline.
// 3 = `if `, 5 = ` => {`
let cond_shape = Shape::indented(shape.indent.block_indent(context.config), context.config)
.offset_left(3, guard.span)?
.sub_width(5, guard.span)?;
let cond_str = guard.rewrite_result(context, cond_shape)?;
.offset_left(3, guard.span())?
.sub_width(5, guard.span())?;
let cond_str = guard.cond.rewrite_result(context, cond_shape)?;
Ok(format!(
"{}if {}",
cond_shape.indent.to_string_with_newline(context.config),
Expand Down
15 changes: 2 additions & 13 deletions src/parse/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::sync::atomic::{AtomicBool, Ordering};
use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
use rustc_errors::emitter::{DynEmitter, Emitter, SilentEmitter, stderr_destination};
use rustc_errors::translation::Translator;
use rustc_errors::{ColorConfig, Diag, DiagCtxt, DiagInner, Level as DiagnosticLevel};
use rustc_session::parse::ParseSess as RawParseSess;
use rustc_span::{
Expand Down Expand Up @@ -74,10 +73,6 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
}
self.handle_non_ignoreable_error(diag);
}

fn translator(&self) -> &Translator {
self.emitter.translator()
}
}

impl From<Color> for ColorConfig {
Expand All @@ -104,15 +99,13 @@ fn default_dcx(
ColorConfig::Never
};

let translator = rustc_driver::default_translator();

let emitter: Box<DynEmitter> = if show_parse_errors {
Box::new(
AnnotateSnippetEmitter::new(stderr_destination(emit_color), translator)
AnnotateSnippetEmitter::new(stderr_destination(emit_color))
.sm(Some(source_map.clone())),
)
} else {
Box::new(SilentEmitter { translator })
Box::new(SilentEmitter)
};
DiagCtxt::new(Box::new(SilentOnIgnoredFilesEmitter {
has_non_ignorable_parser_errors: false,
Expand Down Expand Up @@ -342,10 +335,6 @@ mod tests {
fn emit_diagnostic(&mut self, _diag: DiagInner) {
self.num_emitted_errors.fetch_add(1, Ordering::Release);
}

fn translator(&self) -> &Translator {
panic!("test emitter attempted to translate a diagnostic");
}
}

fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> DiagInner {
Expand Down
21 changes: 2 additions & 19 deletions src/source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::io::{self, Write};
use std::path::Path;
use std::sync::Arc;

use crate::NewlineStyle;
use crate::config::FileName;
use crate::emitter::{self, Emitter};
use crate::parse::session::ParseSess;
use crate::{NewlineStyle, StyleEdition};

#[cfg(test)]
use crate::config::Config;
Expand All @@ -16,27 +16,10 @@ use crate::create_emitter;
use crate::formatting::FileRecord;

// Append a newline to the end of each file.
pub(crate) fn append_newline(s: &mut String, style_edition: StyleEdition) {
if style_edition >= StyleEdition::Edition2027 && s.is_empty() {
return;
}
pub(crate) fn append_newline(s: &mut String) {
s.push('\n');
}

#[test]
fn append_newline_adds_newlines_before_2027() {
let mut text = String::new();
append_newline(&mut text, StyleEdition::Edition2024);
assert_eq!(text, "\n");
}

#[test]
fn append_newline_leaves_empty_files_empty_in_2027() {
let mut text = String::new();
append_newline(&mut text, StyleEdition::Edition2027);
assert!(text.is_empty());
}

#[cfg(test)]
pub(crate) fn write_all_files<T>(
source_file: &[FileRecord],
Expand Down
4 changes: 2 additions & 2 deletions src/spanned.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::cmp::max;

use rustc_ast::ast;
use rustc_span::{Span, source_map};
use rustc_span::Span;

use crate::macros::MacroArg;
use crate::utils::{mk_sp, outer_attributes};
Expand All @@ -17,7 +17,7 @@ impl<T: Spanned> Spanned for Box<T> {
}
}

impl<T> Spanned for source_map::Spanned<T> {
impl<T> Spanned for rustc_span::Spanned<T> {
fn span(&self) -> Span {
self.span
}
Expand Down
1 change: 0 additions & 1 deletion src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const FILE_SKIP_LIST: &[&str] = &[
"cfg_mod/bar.rs",
"cfg_mod/foo.rs",
"cfg_mod/wasm32.rs",
"reorder_modules_2027",
"skip/foo.rs",
];

Expand Down
18 changes: 8 additions & 10 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,6 @@ impl Rewrite for ast::WherePredicate {
ref lifetime,
ref bounds,
}) => rewrite_bounded_lifetime(lifetime, bounds, self.span, context, shape)?,
ast::WherePredicateKind::EqPredicate(ast::WhereEqPredicate {
ref lhs_ty,
ref rhs_ty,
..
}) => {
let lhs_ty_str = lhs_ty
.rewrite_result(context, shape)
.map(|lhs| lhs + " =")?;
rewrite_assign_rhs(context, lhs_ty_str, &**rhs_ty, &RhsAssignKind::Ty, shape)?
}
};

let mut result = String::with_capacity(attrs_str.len() + pred_str.len() + 1);
Expand Down Expand Up @@ -1030,6 +1020,14 @@ impl Rewrite for ast::Ty {
let pat = pat.rewrite_result(context, shape)?;
Ok(format!("{ty} is {pat}"))
}
ast::TyKind::FieldOf(ref ty, ref variant, ref field) => {
let ty = ty.rewrite_result(context, shape)?;
if let Some(variant) = variant {
Ok(format!("builtin # field_of({ty}, {variant}.{field})"))
} else {
Ok(format!("builtin # field_of({ty}, {field})"))
}
}
ast::TyKind::UnsafeBinder(ref binder) => {
let mut result = String::new();
if binder.generic_params.is_empty() {
Expand Down
Loading
Loading