diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-29 08:13:50 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-29 08:26:52 +1000 |
| commit | 84ac80f1921afc243d71fd0caaa4f2838c294102 (patch) | |
| tree | 29006db815bf547dfd0129910b23b8c54675bd98 /compiler/rustc_errors | |
| parent | 118f9350c5b902e462a6dcc4325670f3da701600 (diff) | |
| download | rust-84ac80f1921afc243d71fd0caaa4f2838c294102.tar.gz rust-84ac80f1921afc243d71fd0caaa4f2838c294102.zip | |
Reformat `use` declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 27 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic_impls.rs | 28 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 38 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/error.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/json.rs | 32 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/json/tests.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 45 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lock.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/markdown/parse.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/markdown/tests/parse.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/markdown/tests/term.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/registry.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/snippet.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/tests.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/translation.rs | 12 |
16 files changed, 122 insertions, 116 deletions
diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index b71b93cc67c..df4e9792f95 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -5,6 +5,12 @@ //! //! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/ +use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation}; +use rustc_data_structures::sync::Lrc; +use rustc_error_messages::FluentArgs; +use rustc_span::source_map::SourceMap; +use rustc_span::SourceFile; + use crate::emitter::FileWithAnnotatedLines; use crate::snippet::Line; use crate::translation::{to_fluent_args, Translate}; @@ -12,11 +18,6 @@ use crate::{ CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, Style, Subdiag, }; -use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation}; -use rustc_data_structures::sync::Lrc; -use rustc_error_messages::FluentArgs; -use rustc_span::source_map::SourceMap; -use rustc_span::SourceFile; /// Generates diagnostics using annotate-snippet pub struct AnnotateSnippetEmitter { diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index d500f6d88a0..e1dcbf5b280 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -1,16 +1,3 @@ -use crate::snippet::Style; -use crate::{ - CodeSuggestion, DiagCtxtHandle, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level, - MultiSpan, StashKey, SubdiagMessage, Substitution, SubstitutionPart, SuggestionStyle, -}; -use rustc_data_structures::fx::FxIndexMap; -use rustc_error_messages::fluent_value_from_str_list_sep_by_and; -use rustc_error_messages::FluentValue; -use rustc_lint_defs::{Applicability, LintExpectationId}; -use rustc_macros::{Decodable, Encodable}; -use rustc_span::source_map::Spanned; -use rustc_span::symbol::Symbol; -use rustc_span::{Span, DUMMY_SP}; use std::borrow::Cow; use std::fmt::{self, Debug}; use std::hash::{Hash, Hasher}; @@ -18,8 +5,22 @@ use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::panic; use std::thread::panicking; + +use rustc_data_structures::fx::FxIndexMap; +use rustc_error_messages::{fluent_value_from_str_list_sep_by_and, FluentValue}; +use rustc_lint_defs::{Applicability, LintExpectationId}; +use rustc_macros::{Decodable, Encodable}; +use rustc_span::source_map::Spanned; +use rustc_span::symbol::Symbol; +use rustc_span::{Span, DUMMY_SP}; use tracing::debug; +use crate::snippet::Style; +use crate::{ + CodeSuggestion, DiagCtxtHandle, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level, + MultiSpan, StashKey, SubdiagMessage, Substitution, SubstitutionPart, SuggestionStyle, +}; + /// Error type for `DiagInner`'s `suggestions` field, indicating that /// `.disable_suggestions()` was called on the `DiagInner`. #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index e6ca1bf7bc4..3e22786a01f 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -1,12 +1,11 @@ -use crate::diagnostic::DiagLocation; -use crate::{fluent_generated as fluent, DiagCtxtHandle, Subdiagnostic}; -use crate::{ - Diag, DiagArgValue, Diagnostic, EmissionGuarantee, ErrCode, IntoDiagArg, Level, - SubdiagMessageOp, -}; -use rustc_ast as ast; +use std::backtrace::Backtrace; +use std::borrow::Cow; +use std::fmt; +use std::num::ParseIntError; +use std::path::{Path, PathBuf}; +use std::process::ExitStatus; + use rustc_ast_pretty::pprust; -use rustc_hir as hir; use rustc_macros::Subdiagnostic; use rustc_span::edition::Edition; use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol}; @@ -14,12 +13,13 @@ use rustc_span::Span; use rustc_target::abi::TargetDataLayoutErrors; use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple}; use rustc_type_ir::{ClosureKind, FloatTy}; -use std::backtrace::Backtrace; -use std::borrow::Cow; -use std::fmt; -use std::num::ParseIntError; -use std::path::{Path, PathBuf}; -use std::process::ExitStatus; +use {rustc_ast as ast, rustc_hir as hir}; + +use crate::diagnostic::DiagLocation; +use crate::{ + fluent_generated as fluent, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, + ErrCode, IntoDiagArg, Level, SubdiagMessageOp, Subdiagnostic, +}; pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display); diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 58220c65490..73908e58085 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -7,35 +7,35 @@ //! //! The output types are defined in `rustc_session::config::ErrorOutputType`. +use std::borrow::Cow; +use std::cmp::{max, min, Reverse}; +use std::error::Report; +use std::io::prelude::*; +use std::io::{self, IsTerminal}; +use std::iter; +use std::path::Path; + +use derive_setters::Setters; +use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; +use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc}; +use rustc_error_messages::{FluentArgs, SpanLabel}; +use rustc_lint_defs::pluralize; +use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::source_map::SourceMap; use rustc_span::{char_width, FileLines, FileName, SourceFile, Span}; +use termcolor::{Buffer, BufferWriter, Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; +use tracing::{debug, instrument, trace, warn}; +use crate::diagnostic::DiagLocation; use crate::snippet::{ Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString, }; use crate::styled_buffer::StyledBuffer; use crate::translation::{to_fluent_args, Translate}; use crate::{ - diagnostic::DiagLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagMessage, ErrCode, - FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight, - SuggestionStyle, TerminalUrl, + CodeSuggestion, DiagCtxt, DiagInner, DiagMessage, ErrCode, FluentBundle, LazyFallbackBundle, + Level, MultiSpan, Subdiag, SubstitutionHighlight, SuggestionStyle, TerminalUrl, }; -use derive_setters::Setters; -use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; -use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc}; -use rustc_error_messages::{FluentArgs, SpanLabel}; -use rustc_lint_defs::pluralize; -use rustc_span::hygiene::{ExpnKind, MacroKind}; -use std::borrow::Cow; -use std::cmp::{max, min, Reverse}; -use std::error::Report; -use std::io::prelude::*; -use std::io::{self, IsTerminal}; -use std::iter; -use std::path::Path; -use termcolor::{Buffer, BufferWriter, ColorChoice, ColorSpec, StandardStream}; -use termcolor::{Color, WriteColor}; -use tracing::{debug, instrument, trace, warn}; /// Default column width, used in tests and when terminal dimensions cannot be determined. const DEFAULT_COLUMN_WIDTH: usize = 140; diff --git a/compiler/rustc_errors/src/error.rs b/compiler/rustc_errors/src/error.rs index ca818a4d832..462467d9fa0 100644 --- a/compiler/rustc_errors/src/error.rs +++ b/compiler/rustc_errors/src/error.rs @@ -1,11 +1,10 @@ -use rustc_error_messages::{ - fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}, - FluentArgs, FluentError, -}; use std::borrow::Cow; use std::error::Error; use std::fmt; +use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}; +use rustc_error_messages::{FluentArgs, FluentError}; + #[derive(Debug)] pub enum TranslateError<'args> { One { diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 764134d5335..42a28bc7890 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -9,16 +9,12 @@ // FIXME: spec the JSON output properly. -use crate::emitter::{ - should_show_source_code, ColorConfig, Destination, Emitter, HumanEmitter, - HumanReadableErrorType, -}; -use crate::registry::Registry; -use crate::translation::{to_fluent_args, Translate}; -use crate::{ - diagnostic::IsLint, CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, - Subdiag, TerminalUrl, -}; +use std::error::Report; +use std::io::{self, Write}; +use std::path::Path; +use std::sync::{Arc, Mutex}; +use std::vec; + use derive_setters::Setters; use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; use rustc_error_messages::FluentArgs; @@ -27,13 +23,19 @@ use rustc_span::hygiene::ExpnData; use rustc_span::source_map::SourceMap; use rustc_span::Span; use serde::Serialize; -use std::error::Report; -use std::io::{self, Write}; -use std::path::Path; -use std::sync::{Arc, Mutex}; -use std::vec; use termcolor::{ColorSpec, WriteColor}; +use crate::diagnostic::IsLint; +use crate::emitter::{ + should_show_source_code, ColorConfig, Destination, Emitter, HumanEmitter, + HumanReadableErrorType, +}; +use crate::registry::Registry; +use crate::translation::{to_fluent_args, Translate}; +use crate::{ + CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, Subdiag, TerminalUrl, +}; + #[cfg(test)] mod tests; diff --git a/compiler/rustc_errors/src/json/tests.rs b/compiler/rustc_errors/src/json/tests.rs index e4b29fc9103..e3549fc3aa5 100644 --- a/compiler/rustc_errors/src/json/tests.rs +++ b/compiler/rustc_errors/src/json/tests.rs @@ -1,13 +1,12 @@ -use super::*; +use std::str; -use crate::DiagCtxt; use rustc_span::source_map::FilePathMapping; use rustc_span::BytePos; - -use std::str; - use serde::Deserialize; +use super::*; +use crate::DiagCtxt; + #[derive(Deserialize, Debug, PartialEq, Eq)] struct TestData { spans: Vec<SpanTestData>, diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 2a850d9303c..09855394cdb 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -28,6 +28,17 @@ extern crate self as rustc_errors; +use std::backtrace::{Backtrace, BacktraceStatus}; +use std::borrow::Cow; +use std::cell::Cell; +use std::error::Report; +use std::hash::Hash; +use std::io::Write; +use std::num::NonZero; +use std::ops::DerefMut; +use std::path::{Path, PathBuf}; +use std::{fmt, panic}; + pub use codes::*; pub use diagnostic::{ BugAbort, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, DiagStyledString, @@ -39,42 +50,28 @@ pub use diagnostic_impls::{ IndicateAnonymousLifetime, SingleLabelManySpans, }; pub use emitter::ColorConfig; +use emitter::{is_case_difference, DynEmitter, Emitter}; +use registry::Registry; +use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; +use rustc_data_structures::stable_hasher::{Hash128, StableHasher}; +use rustc_data_structures::sync::{Lock, Lrc}; +use rustc_data_structures::AtomicRef; pub use rustc_error_messages::{ fallback_fluent_bundle, fluent_bundle, DiagMessage, FluentBundle, LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage, }; +use rustc_lint_defs::LintExpectationId; pub use rustc_lint_defs::{pluralize, Applicability}; +use rustc_macros::{Decodable, Encodable}; pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker}; +use rustc_span::source_map::SourceMap; pub use rustc_span::ErrorGuaranteed; +use rustc_span::{Loc, Span, DUMMY_SP}; pub use snippet::Style; - // Used by external projects such as `rust-gpu`. // See https://github.com/rust-lang/rust/pull/115393. pub use termcolor::{Color, ColorSpec, WriteColor}; - -use emitter::{is_case_difference, DynEmitter, Emitter}; -use registry::Registry; -use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; -use rustc_data_structures::stable_hasher::{Hash128, StableHasher}; -use rustc_data_structures::sync::{Lock, Lrc}; -use rustc_data_structures::AtomicRef; -use rustc_lint_defs::LintExpectationId; -use rustc_macros::{Decodable, Encodable}; -use rustc_span::source_map::SourceMap; -use rustc_span::{Loc, Span, DUMMY_SP}; -use std::backtrace::{Backtrace, BacktraceStatus}; -use std::borrow::Cow; -use std::cell::Cell; -use std::error::Report; -use std::fmt; -use std::hash::Hash; -use std::io::Write; -use std::num::NonZero; -use std::ops::DerefMut; -use std::panic; -use std::path::{Path, PathBuf}; use tracing::debug; - use Level::*; pub mod annotate_snippet_emitter_writer; diff --git a/compiler/rustc_errors/src/lock.rs b/compiler/rustc_errors/src/lock.rs index 0aeb511214b..915542c9092 100644 --- a/compiler/rustc_errors/src/lock.rs +++ b/compiler/rustc_errors/src/lock.rs @@ -16,10 +16,10 @@ pub fn acquire_global_lock(name: &str) -> Box<dyn Any> { use std::ffi::CString; use std::io; - use windows::{ - core::PCSTR, - Win32::Foundation::{CloseHandle, HANDLE, WAIT_ABANDONED, WAIT_OBJECT_0}, - Win32::System::Threading::{CreateMutexA, ReleaseMutex, WaitForSingleObject, INFINITE}, + use windows::core::PCSTR; + use windows::Win32::Foundation::{CloseHandle, HANDLE, WAIT_ABANDONED, WAIT_OBJECT_0}; + use windows::Win32::System::Threading::{ + CreateMutexA, ReleaseMutex, WaitForSingleObject, INFINITE, }; struct Handle(HANDLE); diff --git a/compiler/rustc_errors/src/markdown/parse.rs b/compiler/rustc_errors/src/markdown/parse.rs index 69e7120e714..c44f136120a 100644 --- a/compiler/rustc_errors/src/markdown/parse.rs +++ b/compiler/rustc_errors/src/markdown/parse.rs @@ -1,6 +1,7 @@ -use crate::markdown::{MdStream, MdTree}; use std::{iter, mem, str}; +use crate::markdown::{MdStream, MdTree}; + /// Short aliases that we can use in match patterns. If an end pattern is not /// included, this type may be variable const ANC_E: &[u8] = b">"; diff --git a/compiler/rustc_errors/src/markdown/tests/parse.rs b/compiler/rustc_errors/src/markdown/tests/parse.rs index e2e3f354ff6..bfcb3de16fa 100644 --- a/compiler/rustc_errors/src/markdown/tests/parse.rs +++ b/compiler/rustc_errors/src/markdown/tests/parse.rs @@ -1,6 +1,7 @@ -use super::*; use ParseOpt as PO; +use super::*; + #[test] fn test_parse_simple() { let buf = "**abcd** rest"; diff --git a/compiler/rustc_errors/src/markdown/tests/term.rs b/compiler/rustc_errors/src/markdown/tests/term.rs index bab47dcc175..e025870f055 100644 --- a/compiler/rustc_errors/src/markdown/tests/term.rs +++ b/compiler/rustc_errors/src/markdown/tests/term.rs @@ -1,5 +1,6 @@ use std::io::BufWriter; use std::path::PathBuf; + use termcolor::{BufferWriter, ColorChoice}; use super::*; diff --git a/compiler/rustc_errors/src/registry.rs b/compiler/rustc_errors/src/registry.rs index 8834d04d971..baca7700d90 100644 --- a/compiler/rustc_errors/src/registry.rs +++ b/compiler/rustc_errors/src/registry.rs @@ -1,6 +1,7 @@ -use crate::ErrCode; use rustc_data_structures::fx::FxHashMap; +use crate::ErrCode; + #[derive(Debug)] pub struct InvalidErrorCode; diff --git a/compiler/rustc_errors/src/snippet.rs b/compiler/rustc_errors/src/snippet.rs index d6119fb41d2..50abf8a49c2 100644 --- a/compiler/rustc_errors/src/snippet.rs +++ b/compiler/rustc_errors/src/snippet.rs @@ -1,8 +1,9 @@ // Code for annotating snippets. -use crate::{Level, Loc}; use rustc_macros::{Decodable, Encodable}; +use crate::{Level, Loc}; + #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] pub struct Line { pub line_index: usize, diff --git a/compiler/rustc_errors/src/tests.rs b/compiler/rustc_errors/src/tests.rs index 50d58aec36a..bfe4c9f2a3a 100644 --- a/compiler/rustc_errors/src/tests.rs +++ b/compiler/rustc_errors/src/tests.rs @@ -1,11 +1,11 @@ +use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; +use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}; +use rustc_error_messages::{langid, DiagMessage}; + use crate::error::{TranslateError, TranslateErrorKind}; use crate::fluent_bundle::*; use crate::translation::Translate; use crate::FluentBundle; -use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; -use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}; -use rustc_error_messages::langid; -use rustc_error_messages::DiagMessage; struct Dummy { bundle: FluentBundle, diff --git a/compiler/rustc_errors/src/translation.rs b/compiler/rustc_errors/src/translation.rs index 445e9b4fd6e..a44e794ee12 100644 --- a/compiler/rustc_errors/src/translation.rs +++ b/compiler/rustc_errors/src/translation.rs @@ -1,13 +1,15 @@ -use crate::error::{TranslateError, TranslateErrorKind}; -use crate::snippet::Style; -use crate::{DiagArg, DiagMessage, FluentBundle}; -use rustc_data_structures::sync::Lrc; -pub use rustc_error_messages::FluentArgs; use std::borrow::Cow; use std::env; use std::error::Report; + +use rustc_data_structures::sync::Lrc; +pub use rustc_error_messages::FluentArgs; use tracing::{debug, trace}; +use crate::error::{TranslateError, TranslateErrorKind}; +use crate::snippet::Style; +use crate::{DiagArg, DiagMessage, FluentBundle}; + /// Convert diagnostic arguments (a rustc internal type that exists to implement /// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform translation. /// |
