summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/tools/rustfmt
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rustfmt')
-rw-r--r--src/tools/rustfmt/src/expr.rs2
-rw-r--r--src/tools/rustfmt/src/parse/session.rs16
-rw-r--r--src/tools/rustfmt/src/types.rs2
-rw-r--r--src/tools/rustfmt/tests/target/anonymous-types.rs19
4 files changed, 30 insertions, 9 deletions
diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs
index c3c07f310..03cdddc41 100644
--- a/src/tools/rustfmt/src/expr.rs
+++ b/src/tools/rustfmt/src/expr.rs
@@ -664,7 +664,7 @@ struct ControlFlow<'a> {
fn extract_pats_and_cond(expr: &ast::Expr) -> (Option<&ast::Pat>, &ast::Expr) {
match expr.kind {
- ast::ExprKind::Let(ref pat, ref cond, _) => (Some(pat), cond),
+ ast::ExprKind::Let(ref pat, ref cond, _, _) => (Some(pat), cond),
_ => (None, expr),
}
}
diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs
index 945e3e42f..3f94bb299 100644
--- a/src/tools/rustfmt/src/parse/session.rs
+++ b/src/tools/rustfmt/src/parse/session.rs
@@ -1,8 +1,8 @@
use std::path::Path;
use std::sync::atomic::{AtomicBool, Ordering};
-use rustc_data_structures::sync::{Lrc, Send};
-use rustc_errors::emitter::{Emitter, EmitterWriter};
+use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
+use rustc_errors::emitter::{DynEmitter, Emitter, EmitterWriter};
use rustc_errors::translation::Translate;
use rustc_errors::{ColorConfig, Diagnostic, Handler, Level as DiagnosticLevel};
use rustc_session::parse::ParseSess as RawParseSess;
@@ -48,15 +48,15 @@ impl Emitter for SilentEmitter {
fn emit_diagnostic(&mut self, _db: &Diagnostic) {}
}
-fn silent_emitter() -> Box<dyn Emitter + Send> {
+fn silent_emitter() -> Box<DynEmitter> {
Box::new(SilentEmitter {})
}
/// Emit errors against every files expect ones specified in the `ignore_path_set`.
struct SilentOnIgnoredFilesEmitter {
- ignore_path_set: Lrc<IgnorePathSet>,
+ ignore_path_set: IntoDynSyncSend<Lrc<IgnorePathSet>>,
source_map: Lrc<SourceMap>,
- emitter: Box<dyn Emitter + Send>,
+ emitter: Box<DynEmitter>,
has_non_ignorable_parser_errors: bool,
can_reset: Lrc<AtomicBool>,
}
@@ -145,7 +145,7 @@ fn default_handler(
has_non_ignorable_parser_errors: false,
source_map,
emitter,
- ignore_path_set,
+ ignore_path_set: IntoDynSyncSend(ignore_path_set),
can_reset,
}))
}
@@ -268,7 +268,7 @@ impl ParseSess {
let source_file = self.parse_sess.source_map().lookup_char_pos(span.lo()).file;
SnippetProvider::new(
source_file.start_pos,
- source_file.end_pos,
+ source_file.end_position(),
Lrc::clone(source_file.src.as_ref().unwrap()),
)
}
@@ -396,7 +396,7 @@ mod tests {
has_non_ignorable_parser_errors: false,
source_map,
emitter: Box::new(emitter_writer),
- ignore_path_set,
+ ignore_path_set: IntoDynSyncSend(ignore_path_set),
can_reset,
}
}
diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs
index 18a08f17b..5e8edd8f8 100644
--- a/src/tools/rustfmt/src/types.rs
+++ b/src/tools/rustfmt/src/types.rs
@@ -819,6 +819,8 @@ impl Rewrite for ast::Ty {
ast::TyKind::Tup(ref items) => {
rewrite_tuple(context, items.iter(), self.span, shape, items.len() == 1)
}
+ ast::TyKind::AnonStruct(_) => Some(context.snippet(self.span).to_owned()),
+ ast::TyKind::AnonUnion(_) => Some(context.snippet(self.span).to_owned()),
ast::TyKind::Path(ref q_self, ref path) => {
rewrite_path(context, PathContext::Type, q_self, path, shape)
}
diff --git a/src/tools/rustfmt/tests/target/anonymous-types.rs b/src/tools/rustfmt/tests/target/anonymous-types.rs
new file mode 100644
index 000000000..8e08c314e
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/anonymous-types.rs
@@ -0,0 +1,19 @@
+// Test for issue 85480
+// Pretty print anonymous struct and union types
+
+// pp-exact
+// pretty-compare-only
+
+struct Foo {
+ _: union {
+ _: struct {
+ a: u8,
+ b: u16,
+ },
+ c: u32,
+ },
+ d: u64,
+ e: f32,
+}
+
+fn main() {}