mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #90188 - matthiaskrgr:rollup-74cwv5c, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - #83233 (Implement split_array and split_array_mut) - #88300 (Stabilise unix_process_wait_more, extra ExitStatusExt methods) - #89416 (nice_region_error: Include lifetime placeholders in error output) - #89468 (Report fatal lexer errors in `--cfg` command line arguments) - #89730 (add feature flag for `type_changing_struct_update`) - #89920 (Implement -Z location-detail flag) - #90070 (Add edition configuration to compiletest) - #90087 (Sync rustfmt subtree) - #90117 (Make RSplit<T, P>: Clone not require T: Clone) - #90122 (CI: make docker cache download and `docker load` time out after 10 minutes) - #90166 (Add comment documenting why we can't use a simpler solution) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
cf708558b7
90
Cargo.lock
90
Cargo.lock
@ -265,6 +265,15 @@ version = "1.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "81a18687293a1546b67c246452202bbbf143d239cb43494cc163da14979082da"
|
checksum = "81a18687293a1546b67c246452202bbbf143d239cb43494cc163da14979082da"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "camino"
|
||||||
|
version = "1.0.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "52d74260d9bf6944e2208aa46841b4b8f0d7ffc0849a06837b2f510337f86b2b"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo"
|
name = "cargo"
|
||||||
version = "0.58.0"
|
version = "0.58.0"
|
||||||
@ -272,7 +281,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"atty",
|
"atty",
|
||||||
"bytesize",
|
"bytesize",
|
||||||
"cargo-platform",
|
"cargo-platform 0.1.2",
|
||||||
"cargo-test-macro",
|
"cargo-test-macro",
|
||||||
"cargo-test-support",
|
"cargo-test-support",
|
||||||
"cargo-util",
|
"cargo-util",
|
||||||
@ -374,6 +383,15 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cargo-platform"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo-test-macro"
|
name = "cargo-test-macro"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -419,18 +437,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cargo_metadata"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "700b3731fd7d357223d0000f4dbf1808401b694609035c3c411fbc0cd375c426"
|
|
||||||
dependencies = [
|
|
||||||
"semver 0.9.0",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo_metadata"
|
name = "cargo_metadata"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
@ -442,6 +448,19 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cargo_metadata"
|
||||||
|
version = "0.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c297bd3135f558552f99a0daa180876984ea2c4ffa7470314540dff8c654109a"
|
||||||
|
dependencies = [
|
||||||
|
"camino",
|
||||||
|
"cargo-platform 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"semver 1.0.3",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargotest2"
|
name = "cargotest2"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -1070,9 +1089,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.6.2"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
|
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"humantime 1.3.0",
|
"humantime 1.3.0",
|
||||||
@ -1083,12 +1102,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.7.1"
|
version = "0.8.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
|
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"humantime 1.3.0",
|
"humantime 2.0.1",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
@ -1698,15 +1717,6 @@ version = "0.1.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
|
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itertools"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@ -4673,19 +4683,19 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustfmt-nightly"
|
name = "rustfmt-nightly"
|
||||||
version = "1.4.37"
|
version = "1.4.38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets",
|
"annotate-snippets",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytecount",
|
"bytecount",
|
||||||
"cargo_metadata 0.8.2",
|
"cargo_metadata 0.14.0",
|
||||||
"derive-new",
|
"derive-new",
|
||||||
"diff",
|
"diff",
|
||||||
"dirs",
|
"dirs",
|
||||||
"env_logger 0.6.2",
|
"env_logger 0.8.4",
|
||||||
"getopts",
|
"getopts",
|
||||||
"ignore",
|
"ignore",
|
||||||
"itertools 0.8.2",
|
"itertools 0.9.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
@ -4768,23 +4778,13 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser 0.7.0",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"semver-parser 0.10.2",
|
"semver-parser",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -4797,12 +4797,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver-parser"
|
name = "semver-parser"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
|
@ -80,10 +80,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
line: u32,
|
line: u32,
|
||||||
col: u32,
|
col: u32,
|
||||||
) -> MPlaceTy<'tcx, M::PointerTag> {
|
) -> MPlaceTy<'tcx, M::PointerTag> {
|
||||||
let file =
|
let loc_details = &self.tcx.sess.opts.debugging_opts.location_detail;
|
||||||
self.allocate_str(&filename.as_str(), MemoryKind::CallerLocation, Mutability::Not);
|
let file = if loc_details.file {
|
||||||
let line = Scalar::from_u32(line);
|
self.allocate_str(&filename.as_str(), MemoryKind::CallerLocation, Mutability::Not)
|
||||||
let col = Scalar::from_u32(col);
|
} else {
|
||||||
|
// FIXME: This creates a new allocation each time. It might be preferable to
|
||||||
|
// perform this allocation only once, and re-use the `MPlaceTy`.
|
||||||
|
// See https://github.com/rust-lang/rust/pull/89920#discussion_r730012398
|
||||||
|
self.allocate_str("<redacted>", MemoryKind::CallerLocation, Mutability::Not)
|
||||||
|
};
|
||||||
|
let line = if loc_details.line { Scalar::from_u32(line) } else { Scalar::from_u32(0) };
|
||||||
|
let col = if loc_details.column { Scalar::from_u32(col) } else { Scalar::from_u32(0) };
|
||||||
|
|
||||||
// Allocate memory for `CallerLocation` struct.
|
// Allocate memory for `CallerLocation` struct.
|
||||||
let loc_ty = self
|
let loc_ty = self
|
||||||
|
@ -15,7 +15,7 @@ use rustc_span::{MultiSpan, SourceFile, Span};
|
|||||||
use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, Style, StyledString};
|
use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, Style, StyledString};
|
||||||
use crate::styled_buffer::StyledBuffer;
|
use crate::styled_buffer::StyledBuffer;
|
||||||
use crate::{
|
use crate::{
|
||||||
CodeSuggestion, Diagnostic, DiagnosticId, Level, SubDiagnostic, SubstitutionHighlight,
|
CodeSuggestion, Diagnostic, DiagnosticId, Handler, Level, SubDiagnostic, SubstitutionHighlight,
|
||||||
SuggestionStyle,
|
SuggestionStyle,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -523,14 +523,27 @@ impl Emitter for EmitterWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An emitter that does nothing when emitting a diagnostic.
|
/// An emitter that does nothing when emitting a non-fatal diagnostic.
|
||||||
pub struct SilentEmitter;
|
/// Fatal diagnostics are forwarded to `fatal_handler` to avoid silent
|
||||||
|
/// failures of rustc, as witnessed e.g. in issue #89358.
|
||||||
|
pub struct SilentEmitter {
|
||||||
|
pub fatal_handler: Handler,
|
||||||
|
pub fatal_note: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Emitter for SilentEmitter {
|
impl Emitter for SilentEmitter {
|
||||||
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
|
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn emit_diagnostic(&mut self, _: &Diagnostic) {}
|
fn emit_diagnostic(&mut self, d: &Diagnostic) {
|
||||||
|
if d.level == Level::Fatal {
|
||||||
|
let mut d = d.clone();
|
||||||
|
if let Some(ref note) = self.fatal_note {
|
||||||
|
d.note(note);
|
||||||
|
}
|
||||||
|
self.fatal_handler.emit_diagnostic(&d);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maximum number of lines we will print for a multiline suggestion; arbitrary.
|
/// Maximum number of lines we will print for a multiline suggestion; arbitrary.
|
||||||
|
@ -684,6 +684,10 @@ declare_features! (
|
|||||||
/// Allows using the `non_exhaustive_omitted_patterns` lint.
|
/// Allows using the `non_exhaustive_omitted_patterns` lint.
|
||||||
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),
|
(active, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554), None),
|
||||||
|
|
||||||
|
/// Allows creation of instances of a struct by moving fields that have
|
||||||
|
/// not changed from prior instances of the same struct (RFC #2528)
|
||||||
|
(incomplete, type_changing_struct_update, "1.58.0", Some(86555), None),
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// feature-group-end: actual feature gates
|
// feature-group-end: actual feature gates
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
@ -9,10 +9,13 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_middle::ty::error::ExpectedFound;
|
use rustc_middle::ty::print::RegionHighlightMode;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitor};
|
||||||
|
|
||||||
use rustc_span::{MultiSpan, Span, Symbol};
|
use rustc_span::{MultiSpan, Span, Symbol};
|
||||||
|
|
||||||
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
/// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`.
|
/// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`.
|
||||||
pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option<ErrorReported> {
|
pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option<ErrorReported> {
|
||||||
@ -69,6 +72,47 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||||||
.tcx()
|
.tcx()
|
||||||
.sess
|
.sess
|
||||||
.struct_span_err(sp, "`impl` item signature doesn't match `trait` item signature");
|
.struct_span_err(sp, "`impl` item signature doesn't match `trait` item signature");
|
||||||
|
|
||||||
|
// Mark all unnamed regions in the type with a number.
|
||||||
|
// This diagnostic is called in response to lifetime errors, so be informative.
|
||||||
|
struct HighlightBuilder<'tcx> {
|
||||||
|
highlight: RegionHighlightMode,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
counter: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HighlightBuilder<'tcx> {
|
||||||
|
fn build(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> RegionHighlightMode {
|
||||||
|
let mut builder =
|
||||||
|
HighlightBuilder { highlight: RegionHighlightMode::default(), counter: 1, tcx };
|
||||||
|
builder.visit_ty(ty);
|
||||||
|
builder.highlight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> ty::fold::TypeVisitor<'tcx> for HighlightBuilder<'tcx> {
|
||||||
|
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
|
||||||
|
Some(self.tcx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
|
if !r.has_name() && self.counter <= 3 {
|
||||||
|
self.highlight.highlighting_region(r, self.counter);
|
||||||
|
self.counter += 1;
|
||||||
|
}
|
||||||
|
r.super_visit_with(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let expected_highlight = HighlightBuilder::build(self.tcx(), expected);
|
||||||
|
let expected = self
|
||||||
|
.infcx
|
||||||
|
.extract_inference_diagnostics_data(expected.into(), Some(expected_highlight))
|
||||||
|
.name;
|
||||||
|
let found_highlight = HighlightBuilder::build(self.tcx(), found);
|
||||||
|
let found =
|
||||||
|
self.infcx.extract_inference_diagnostics_data(found.into(), Some(found_highlight)).name;
|
||||||
|
|
||||||
err.span_label(sp, &format!("found `{}`", found));
|
err.span_label(sp, &format!("found `{}`", found));
|
||||||
err.span_label(trait_sp, &format!("expected `{}`", expected));
|
err.span_label(trait_sp, &format!("expected `{}`", expected));
|
||||||
|
|
||||||
@ -96,15 +140,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((expected, found)) =
|
err.note(&format!("expected `{}`\n found `{}`", expected, found));
|
||||||
self.infcx.expected_found_str_ty(ExpectedFound { expected, found })
|
|
||||||
{
|
|
||||||
// Highlighted the differences when showing the "expected/found" note.
|
|
||||||
err.note_expected_found(&"", expected, &"", found);
|
|
||||||
} else {
|
|
||||||
// This fallback shouldn't be necessary, but let's keep it in just in case.
|
|
||||||
err.note(&format!("expected `{}`\n found `{}`", expected, found));
|
|
||||||
}
|
|
||||||
err.span_help(
|
err.span_help(
|
||||||
type_param_span,
|
type_param_span,
|
||||||
"the lifetime requirements from the `impl` do not correspond to the requirements in \
|
"the lifetime requirements from the `impl` do not correspond to the requirements in \
|
||||||
|
@ -75,7 +75,10 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
|
|||||||
let cfg = cfgspecs
|
let cfg = cfgspecs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
let sess = ParseSess::with_silent_emitter();
|
let sess = ParseSess::with_silent_emitter(Some(format!(
|
||||||
|
"this error occurred on the command line: `--cfg={}`",
|
||||||
|
s
|
||||||
|
)));
|
||||||
let filename = FileName::cfg_spec_source_code(&s);
|
let filename = FileName::cfg_spec_source_code(&s);
|
||||||
let mut parser = new_parser_from_source_str(&sess, filename, s.to_string());
|
let mut parser = new_parser_from_source_str(&sess, filename, s.to_string());
|
||||||
|
|
||||||
|
@ -5,7 +5,9 @@ use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
|
|||||||
use rustc_session::config::InstrumentCoverage;
|
use rustc_session::config::InstrumentCoverage;
|
||||||
use rustc_session::config::Strip;
|
use rustc_session::config::Strip;
|
||||||
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
|
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
|
||||||
use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
|
use rustc_session::config::{
|
||||||
|
rustc_optgroups, ErrorOutputType, ExternLocation, LocationDetail, Options, Passes,
|
||||||
|
};
|
||||||
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
|
use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
|
||||||
use rustc_session::config::{
|
use rustc_session::config::{
|
||||||
Externs, OutputType, OutputTypes, SymbolManglingVersion, WasiExecModel,
|
Externs, OutputType, OutputTypes, SymbolManglingVersion, WasiExecModel,
|
||||||
@ -733,6 +735,7 @@ fn test_debugging_options_tracking_hash() {
|
|||||||
tracked!(instrument_mcount, true);
|
tracked!(instrument_mcount, true);
|
||||||
tracked!(link_only, true);
|
tracked!(link_only, true);
|
||||||
tracked!(llvm_plugins, vec![String::from("plugin_name")]);
|
tracked!(llvm_plugins, vec![String::from("plugin_name")]);
|
||||||
|
tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
|
||||||
tracked!(merge_functions, Some(MergeFunctions::Disabled));
|
tracked!(merge_functions, Some(MergeFunctions::Disabled));
|
||||||
tracked!(mir_emit_retag, true);
|
tracked!(mir_emit_retag, true);
|
||||||
tracked!(mir_opt_level, Some(4));
|
tracked!(mir_opt_level, Some(4));
|
||||||
|
@ -174,6 +174,20 @@ impl LinkerPluginLto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The different settings that can be enabled via the `-Z location-detail` flag.
|
||||||
|
#[derive(Clone, PartialEq, Hash, Debug)]
|
||||||
|
pub struct LocationDetail {
|
||||||
|
pub file: bool,
|
||||||
|
pub line: bool,
|
||||||
|
pub column: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LocationDetail {
|
||||||
|
pub fn all() -> Self {
|
||||||
|
Self { file: true, line: true, column: true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Hash, Debug)]
|
#[derive(Clone, PartialEq, Hash, Debug)]
|
||||||
pub enum SwitchWithOptPath {
|
pub enum SwitchWithOptPath {
|
||||||
Enabled(Option<PathBuf>),
|
Enabled(Option<PathBuf>),
|
||||||
@ -2422,7 +2436,7 @@ crate mod dep_tracking {
|
|||||||
use super::LdImpl;
|
use super::LdImpl;
|
||||||
use super::{
|
use super::{
|
||||||
CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage, LinkerPluginLto,
|
CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage, LinkerPluginLto,
|
||||||
LtoCli, OptLevel, OutputType, OutputTypes, Passes, SourceFileHashAlgorithm,
|
LocationDetail, LtoCli, OptLevel, OutputType, OutputTypes, Passes, SourceFileHashAlgorithm,
|
||||||
SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
|
SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
|
||||||
};
|
};
|
||||||
use crate::lint;
|
use crate::lint;
|
||||||
@ -2513,6 +2527,7 @@ crate mod dep_tracking {
|
|||||||
Option<LdImpl>,
|
Option<LdImpl>,
|
||||||
OutputType,
|
OutputType,
|
||||||
RealFileName,
|
RealFileName,
|
||||||
|
LocationDetail,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<T1, T2> DepTrackingHash for (T1, T2)
|
impl<T1, T2> DepTrackingHash for (T1, T2)
|
||||||
|
@ -368,6 +368,8 @@ mod desc {
|
|||||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
|
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
|
||||||
pub const parse_linker_plugin_lto: &str =
|
pub const parse_linker_plugin_lto: &str =
|
||||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
|
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
|
||||||
|
pub const parse_location_detail: &str =
|
||||||
|
"comma seperated list of location details to track: `file`, `line`, or `column`";
|
||||||
pub const parse_switch_with_opt_path: &str =
|
pub const parse_switch_with_opt_path: &str =
|
||||||
"an optional path to the profiling data output directory";
|
"an optional path to the profiling data output directory";
|
||||||
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
|
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
|
||||||
@ -484,6 +486,25 @@ mod parse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crate fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
|
||||||
|
if let Some(v) = v {
|
||||||
|
ld.line = false;
|
||||||
|
ld.file = false;
|
||||||
|
ld.column = false;
|
||||||
|
for s in v.split(',') {
|
||||||
|
match s {
|
||||||
|
"file" => ld.file = true,
|
||||||
|
"line" => ld.line = true,
|
||||||
|
"column" => ld.column = true,
|
||||||
|
_ => return false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
|
crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
@ -1152,6 +1173,9 @@ options! {
|
|||||||
"a list LLVM plugins to enable (space separated)"),
|
"a list LLVM plugins to enable (space separated)"),
|
||||||
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
|
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"generate JSON tracing data file from LLVM data (default: no)"),
|
"generate JSON tracing data file from LLVM data (default: no)"),
|
||||||
|
location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
|
||||||
|
"comma seperated list of location details to be tracked when using caller_location \
|
||||||
|
valid options are `file`, `line`, and `column` (default: all)"),
|
||||||
ls: bool = (false, parse_bool, [UNTRACKED],
|
ls: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"list the symbols defined by a library crate (default: no)"),
|
"list the symbols defined by a library crate (default: no)"),
|
||||||
macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
|
macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
|
||||||
|
@ -174,9 +174,14 @@ impl ParseSess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_silent_emitter() -> Self {
|
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let handler = Handler::with_emitter(false, None, Box::new(SilentEmitter));
|
let fatal_handler = Handler::with_tty_emitter(ColorConfig::Auto, false, None, None);
|
||||||
|
let handler = Handler::with_emitter(
|
||||||
|
false,
|
||||||
|
None,
|
||||||
|
Box::new(SilentEmitter { fatal_handler, fatal_note }),
|
||||||
|
);
|
||||||
ParseSess::with_span_handler(handler, sm)
|
ParseSess::with_span_handler(handler, sm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,6 +1338,7 @@ symbols! {
|
|||||||
type_alias_enum_variants,
|
type_alias_enum_variants,
|
||||||
type_alias_impl_trait,
|
type_alias_impl_trait,
|
||||||
type_ascription,
|
type_ascription,
|
||||||
|
type_changing_struct_update,
|
||||||
type_id,
|
type_id,
|
||||||
type_length_limit,
|
type_length_limit,
|
||||||
type_macros,
|
type_macros,
|
||||||
|
@ -500,6 +500,84 @@ impl<T, const N: usize> [T; N] {
|
|||||||
// items.
|
// items.
|
||||||
unsafe { collect_into_array_unchecked(&mut self.iter_mut()) }
|
unsafe { collect_into_array_unchecked(&mut self.iter_mut()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Divides one array reference into two at an index.
|
||||||
|
///
|
||||||
|
/// The first will contain all indices from `[0, M)` (excluding
|
||||||
|
/// the index `M` itself) and the second will contain all
|
||||||
|
/// indices from `[M, N)` (excluding the index `N` itself).
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if `M > N`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(split_array)]
|
||||||
|
///
|
||||||
|
/// let v = [1, 2, 3, 4, 5, 6];
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let (left, right) = v.split_array_ref::<0>();
|
||||||
|
/// assert_eq!(left, &[]);
|
||||||
|
/// assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let (left, right) = v.split_array_ref::<2>();
|
||||||
|
/// assert_eq!(left, &[1, 2]);
|
||||||
|
/// assert_eq!(right, &[3, 4, 5, 6]);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let (left, right) = v.split_array_ref::<6>();
|
||||||
|
/// assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
|
||||||
|
/// assert_eq!(right, &[]);
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
#[unstable(
|
||||||
|
feature = "split_array",
|
||||||
|
reason = "return type should have array as 2nd element",
|
||||||
|
issue = "90091"
|
||||||
|
)]
|
||||||
|
#[inline]
|
||||||
|
pub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T]) {
|
||||||
|
(&self[..]).split_array_ref::<M>()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Divides one mutable array reference into two at an index.
|
||||||
|
///
|
||||||
|
/// The first will contain all indices from `[0, M)` (excluding
|
||||||
|
/// the index `M` itself) and the second will contain all
|
||||||
|
/// indices from `[M, N)` (excluding the index `N` itself).
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if `M > N`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(split_array)]
|
||||||
|
///
|
||||||
|
/// let mut v = [1, 0, 3, 0, 5, 6];
|
||||||
|
/// let (left, right) = v.split_array_mut::<2>();
|
||||||
|
/// assert_eq!(left, &mut [1, 0][..]);
|
||||||
|
/// assert_eq!(right, &mut [3, 0, 5, 6]);
|
||||||
|
/// left[1] = 2;
|
||||||
|
/// right[1] = 4;
|
||||||
|
/// assert_eq!(v, [1, 2, 3, 4, 5, 6]);
|
||||||
|
/// ```
|
||||||
|
#[unstable(
|
||||||
|
feature = "split_array",
|
||||||
|
reason = "return type should have array as 2nd element",
|
||||||
|
issue = "90091"
|
||||||
|
)]
|
||||||
|
#[inline]
|
||||||
|
pub fn split_array_mut<const M: usize>(&mut self) -> (&mut [T; M], &mut [T]) {
|
||||||
|
(&mut self[..]).split_array_mut::<M>()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pulls `N` items from `iter` and returns them as an array. If the iterator
|
/// Pulls `N` items from `iter` and returns them as an array. If the iterator
|
||||||
|
@ -839,7 +839,6 @@ impl<T, P> FusedIterator for SplitInclusiveMut<'_, T, P> where P: FnMut(&T) -> b
|
|||||||
/// [`rsplit`]: slice::rsplit
|
/// [`rsplit`]: slice::rsplit
|
||||||
/// [slices]: slice
|
/// [slices]: slice
|
||||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||||
#[derive(Clone)] // Is this correct, or does it incorrectly require `T: Clone`?
|
|
||||||
pub struct RSplit<'a, T: 'a, P>
|
pub struct RSplit<'a, T: 'a, P>
|
||||||
where
|
where
|
||||||
P: FnMut(&T) -> bool,
|
P: FnMut(&T) -> bool,
|
||||||
@ -867,6 +866,17 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(#26925) Remove in favor of `#[derive(Clone)]`
|
||||||
|
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||||
|
impl<T, P> Clone for RSplit<'_, T, P>
|
||||||
|
where
|
||||||
|
P: Clone + FnMut(&T) -> bool,
|
||||||
|
{
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
RSplit { inner: self.inner.clone() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||||
impl<'a, T, P> Iterator for RSplit<'a, T, P>
|
impl<'a, T, P> Iterator for RSplit<'a, T, P>
|
||||||
where
|
where
|
||||||
|
@ -1665,6 +1665,80 @@ impl<T> [T] {
|
|||||||
unsafe { (from_raw_parts_mut(ptr, mid), from_raw_parts_mut(ptr.add(mid), len - mid)) }
|
unsafe { (from_raw_parts_mut(ptr, mid), from_raw_parts_mut(ptr.add(mid), len - mid)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Divides one slice into an array and a remainder slice at an index.
|
||||||
|
///
|
||||||
|
/// The array will contain all indices from `[0, N)` (excluding
|
||||||
|
/// the index `N` itself) and the slice will contain all
|
||||||
|
/// indices from `[N, len)` (excluding the index `len` itself).
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if `N > len`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(split_array)]
|
||||||
|
///
|
||||||
|
/// let v = &[1, 2, 3, 4, 5, 6][..];
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let (left, right) = v.split_array_ref::<0>();
|
||||||
|
/// assert_eq!(left, &[]);
|
||||||
|
/// assert_eq!(right, [1, 2, 3, 4, 5, 6]);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let (left, right) = v.split_array_ref::<2>();
|
||||||
|
/// assert_eq!(left, &[1, 2]);
|
||||||
|
/// assert_eq!(right, [3, 4, 5, 6]);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// let (left, right) = v.split_array_ref::<6>();
|
||||||
|
/// assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
|
||||||
|
/// assert_eq!(right, []);
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
#[unstable(feature = "split_array", reason = "new API", issue = "90091")]
|
||||||
|
#[inline]
|
||||||
|
pub fn split_array_ref<const N: usize>(&self) -> (&[T; N], &[T]) {
|
||||||
|
let (a, b) = self.split_at(N);
|
||||||
|
// SAFETY: a points to [T; N]? Yes it's [T] of length N (checked by split_at)
|
||||||
|
unsafe { (&*(a.as_ptr() as *const [T; N]), b) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Divides one mutable slice into an array and a remainder slice at an index.
|
||||||
|
///
|
||||||
|
/// The array will contain all indices from `[0, N)` (excluding
|
||||||
|
/// the index `N` itself) and the slice will contain all
|
||||||
|
/// indices from `[N, len)` (excluding the index `len` itself).
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if `N > len`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(split_array)]
|
||||||
|
///
|
||||||
|
/// let mut v = &mut [1, 0, 3, 0, 5, 6][..];
|
||||||
|
/// let (left, right) = v.split_array_mut::<2>();
|
||||||
|
/// assert_eq!(left, &mut [1, 0]);
|
||||||
|
/// assert_eq!(right, [3, 0, 5, 6]);
|
||||||
|
/// left[1] = 2;
|
||||||
|
/// right[1] = 4;
|
||||||
|
/// assert_eq!(v, [1, 2, 3, 4, 5, 6]);
|
||||||
|
/// ```
|
||||||
|
#[unstable(feature = "split_array", reason = "new API", issue = "90091")]
|
||||||
|
#[inline]
|
||||||
|
pub fn split_array_mut<const N: usize>(&mut self) -> (&mut [T; N], &mut [T]) {
|
||||||
|
let (a, b) = self.split_at_mut(N);
|
||||||
|
// SAFETY: a points to [T; N]? Yes it's [T] of length N (checked by split_at_mut)
|
||||||
|
unsafe { (&mut *(a.as_mut_ptr() as *mut [T; N]), b) }
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns an iterator over subslices separated by elements that match
|
/// Returns an iterator over subslices separated by elements that match
|
||||||
/// `pred`. The matched element is not contained in the subslices.
|
/// `pred`. The matched element is not contained in the subslices.
|
||||||
///
|
///
|
||||||
|
@ -436,3 +436,36 @@ where
|
|||||||
std::panic::set_hook(prev_hook);
|
std::panic::set_hook(prev_hook);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn array_split_array_mut() {
|
||||||
|
let mut v = [1, 2, 3, 4, 5, 6];
|
||||||
|
|
||||||
|
{
|
||||||
|
let (left, right) = v.split_array_mut::<0>();
|
||||||
|
assert_eq!(left, &mut []);
|
||||||
|
assert_eq!(right, &mut [1, 2, 3, 4, 5, 6]);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let (left, right) = v.split_array_mut::<6>();
|
||||||
|
assert_eq!(left, &mut [1, 2, 3, 4, 5, 6]);
|
||||||
|
assert_eq!(right, &mut []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[should_panic]
|
||||||
|
#[test]
|
||||||
|
fn array_split_array_ref_out_of_bounds() {
|
||||||
|
let v = [1, 2, 3, 4, 5, 6];
|
||||||
|
|
||||||
|
v.split_array_ref::<7>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[should_panic]
|
||||||
|
#[test]
|
||||||
|
fn array_split_array_mut_out_of_bounds() {
|
||||||
|
let mut v = [1, 2, 3, 4, 5, 6];
|
||||||
|
|
||||||
|
v.split_array_mut::<7>();
|
||||||
|
}
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#![feature(integer_atomics)]
|
#![feature(integer_atomics)]
|
||||||
#![feature(int_roundings)]
|
#![feature(int_roundings)]
|
||||||
#![feature(slice_group_by)]
|
#![feature(slice_group_by)]
|
||||||
|
#![feature(split_array)]
|
||||||
#![feature(trusted_random_access)]
|
#![feature(trusted_random_access)]
|
||||||
#![feature(unsize)]
|
#![feature(unsize)]
|
||||||
#![feature(unzip_option)]
|
#![feature(unzip_option)]
|
||||||
|
@ -2191,3 +2191,36 @@ mod swap_panics {
|
|||||||
x.swap(2, 5);
|
x.swap(2, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn slice_split_array_mut() {
|
||||||
|
let v = &mut [1, 2, 3, 4, 5, 6][..];
|
||||||
|
|
||||||
|
{
|
||||||
|
let (left, right) = v.split_array_mut::<0>();
|
||||||
|
assert_eq!(left, &mut []);
|
||||||
|
assert_eq!(right, [1, 2, 3, 4, 5, 6]);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let (left, right) = v.split_array_mut::<6>();
|
||||||
|
assert_eq!(left, &mut [1, 2, 3, 4, 5, 6]);
|
||||||
|
assert_eq!(right, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[should_panic]
|
||||||
|
#[test]
|
||||||
|
fn slice_split_array_ref_out_of_bounds() {
|
||||||
|
let v = &[1, 2, 3, 4, 5, 6][..];
|
||||||
|
|
||||||
|
v.split_array_ref::<7>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[should_panic]
|
||||||
|
#[test]
|
||||||
|
fn slice_split_array_mut_out_of_bounds() {
|
||||||
|
let v = &mut [1, 2, 3, 4, 5, 6][..];
|
||||||
|
|
||||||
|
v.split_array_mut::<7>();
|
||||||
|
}
|
||||||
|
@ -239,27 +239,27 @@ pub trait ExitStatusExt: Sealed {
|
|||||||
fn signal(&self) -> Option<i32>;
|
fn signal(&self) -> Option<i32>;
|
||||||
|
|
||||||
/// If the process was terminated by a signal, says whether it dumped core.
|
/// If the process was terminated by a signal, says whether it dumped core.
|
||||||
#[unstable(feature = "unix_process_wait_more", issue = "80695")]
|
#[stable(feature = "unix_process_wait_more", since = "1.58.0")]
|
||||||
fn core_dumped(&self) -> bool;
|
fn core_dumped(&self) -> bool;
|
||||||
|
|
||||||
/// If the process was stopped by a signal, returns that signal.
|
/// If the process was stopped by a signal, returns that signal.
|
||||||
///
|
///
|
||||||
/// In other words, if `WIFSTOPPED`, this returns `WSTOPSIG`. This is only possible if the status came from
|
/// In other words, if `WIFSTOPPED`, this returns `WSTOPSIG`. This is only possible if the status came from
|
||||||
/// a `wait` system call which was passed `WUNTRACED`, and was then converted into an `ExitStatus`.
|
/// a `wait` system call which was passed `WUNTRACED`, and was then converted into an `ExitStatus`.
|
||||||
#[unstable(feature = "unix_process_wait_more", issue = "80695")]
|
#[stable(feature = "unix_process_wait_more", since = "1.58.0")]
|
||||||
fn stopped_signal(&self) -> Option<i32>;
|
fn stopped_signal(&self) -> Option<i32>;
|
||||||
|
|
||||||
/// Whether the process was continued from a stopped status.
|
/// Whether the process was continued from a stopped status.
|
||||||
///
|
///
|
||||||
/// Ie, `WIFCONTINUED`. This is only possible if the status came from a `wait` system call
|
/// Ie, `WIFCONTINUED`. This is only possible if the status came from a `wait` system call
|
||||||
/// which was passed `WCONTINUED`, and was then converted into an `ExitStatus`.
|
/// which was passed `WCONTINUED`, and was then converted into an `ExitStatus`.
|
||||||
#[unstable(feature = "unix_process_wait_more", issue = "80695")]
|
#[stable(feature = "unix_process_wait_more", since = "1.58.0")]
|
||||||
fn continued(&self) -> bool;
|
fn continued(&self) -> bool;
|
||||||
|
|
||||||
/// Returns the underlying raw `wait` status.
|
/// Returns the underlying raw `wait` status.
|
||||||
///
|
///
|
||||||
/// The returned integer is a **wait status, not an exit status**.
|
/// The returned integer is a **wait status, not an exit status**.
|
||||||
#[unstable(feature = "unix_process_wait_more", issue = "80695")]
|
#[stable(feature = "unix_process_wait_more", since = "1.58.0")]
|
||||||
fn into_raw(self) -> i32;
|
fn into_raw(self) -> i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +281,10 @@ pub fn temp_dir() -> PathBuf {
|
|||||||
#[cfg(not(target_vendor = "uwp"))]
|
#[cfg(not(target_vendor = "uwp"))]
|
||||||
fn home_dir_crt() -> Option<PathBuf> {
|
fn home_dir_crt() -> Option<PathBuf> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
// The magic constant -4 can be used as the token passed to GetUserProfileDirectoryW below
|
||||||
|
// instead of us having to go through these multiple steps to get a token. However this is
|
||||||
|
// not implemented on Windows 7, only Windows 8 and up. When we drop support for Windows 7
|
||||||
|
// we can simplify this code. See #90144 for details.
|
||||||
use crate::sys::handle::Handle;
|
use crate::sys::handle::Handle;
|
||||||
|
|
||||||
let me = c::GetCurrentProcess();
|
let me = c::GetCurrentProcess();
|
||||||
|
@ -70,8 +70,13 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
|
|||||||
echo "Attempting to download $url"
|
echo "Attempting to download $url"
|
||||||
rm -f /tmp/rustci_docker_cache
|
rm -f /tmp/rustci_docker_cache
|
||||||
set +e
|
set +e
|
||||||
retry curl -y 30 -Y 10 --connect-timeout 30 -f -L -C - -o /tmp/rustci_docker_cache "$url"
|
retry curl --max-time 600 -y 30 -Y 10 --connect-timeout 30 -f -L -C - \
|
||||||
loaded_images=$(docker load -i /tmp/rustci_docker_cache | sed 's/.* sha/sha/')
|
-o /tmp/rustci_docker_cache "$url"
|
||||||
|
echo "Loading images into docker"
|
||||||
|
# docker load sometimes hangs in the CI, so time out after 10 minutes with TERM,
|
||||||
|
# KILL after 12 minutes
|
||||||
|
loaded_images=$(/usr/bin/timeout -k 720 600 docker load -i /tmp/rustci_docker_cache \
|
||||||
|
| sed 's/.* sha/sha/')
|
||||||
set -e
|
set -e
|
||||||
echo "Downloaded containers:\n$loaded_images"
|
echo "Downloaded containers:\n$loaded_images"
|
||||||
fi
|
fi
|
||||||
|
43
src/doc/unstable-book/src/compiler-flags/location-detail.md
Normal file
43
src/doc/unstable-book/src/compiler-flags/location-detail.md
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# `location-detail`
|
||||||
|
|
||||||
|
The tracking issue for this feature is: [#70580](https://github.com/rust-lang/rust/issues/70580).
|
||||||
|
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Option `-Z location-detail=val` controls what location details are tracked when
|
||||||
|
using `caller_location`. This allows users to control what location details
|
||||||
|
are printed as part of panic messages, by allowing them to exclude any combination
|
||||||
|
of filenames, line numbers, and column numbers. This option is intended to provide
|
||||||
|
users with a way to mitigate the size impact of `#[track_caller]`.
|
||||||
|
|
||||||
|
This option supports a comma separated list of location details to be included. Valid options
|
||||||
|
within this list are:
|
||||||
|
|
||||||
|
- `file` - the filename of the panic will be included in the panic output
|
||||||
|
- `line` - the source line of the panic will be included in the panic output
|
||||||
|
- `column` - the source column of the panic will be included in the panic output
|
||||||
|
|
||||||
|
Any combination of these three options are supported. If this option is not specified,
|
||||||
|
all three are included by default.
|
||||||
|
|
||||||
|
An example of a panic output when using `-Z location-detail=line`:
|
||||||
|
```text
|
||||||
|
panicked at 'Process blink had a fault', <redacted>:323:0
|
||||||
|
```
|
||||||
|
|
||||||
|
The code size savings from this option are two-fold. First, the `&'static str` values
|
||||||
|
for each path to a file containing a panic are removed from the binary. For projects
|
||||||
|
with deep directory structures and many files with panics, this can add up. This category
|
||||||
|
of savings can only be realized by excluding filenames from the panic output. Second,
|
||||||
|
savings can be realized by allowing multiple panics to be fused into a single panicking
|
||||||
|
branch. It is often the case that within a single file, multiple panics with the same
|
||||||
|
panic message exist -- e.g. two calls to `Option::unwrap()` in a single line, or
|
||||||
|
two calls to `Result::expect()` on adjacent lines. If column and line information
|
||||||
|
are included in the `Location` struct passed to the panic handler, these branches cannot
|
||||||
|
be fused, as the output is different depending on which panic occurs. However if line
|
||||||
|
and column information is identical for all panics, these branches can be fused, which
|
||||||
|
can lead to substantial code size savings, especially for small embedded binaries with
|
||||||
|
many panics.
|
||||||
|
|
||||||
|
The savings from this option are amplified when combined with the use of `-Zbuild-std`, as
|
||||||
|
otherwise paths for panics within the standard library are still included in your binary.
|
5
src/test/ui/conditional-compilation/cfg-arg-invalid-7.rs
Normal file
5
src/test/ui/conditional-compilation/cfg-arg-invalid-7.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// Regression test for issue #89358.
|
||||||
|
|
||||||
|
// compile-flags: --cfg a"
|
||||||
|
// error-pattern: unterminated double quote string
|
||||||
|
// error-pattern: this error occurred on the command line
|
@ -0,0 +1,4 @@
|
|||||||
|
error[E0765]: unterminated double quote string
|
||||||
|
|
|
||||||
|
= note: this error occurred on the command line: `--cfg=a"`
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
#[derive(Debug)]
|
||||||
|
struct Machine<S> {
|
||||||
|
state: S,
|
||||||
|
common_field1: &'static str,
|
||||||
|
common_field2: i32,
|
||||||
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct State1;
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
struct State2;
|
||||||
|
|
||||||
|
fn update_to_state2() {
|
||||||
|
let m1: Machine<State1> = Machine {
|
||||||
|
state: State1,
|
||||||
|
common_field1: "hello",
|
||||||
|
common_field2: 2,
|
||||||
|
};
|
||||||
|
let m2: Machine<State2> = Machine {
|
||||||
|
state: State2,
|
||||||
|
..m1 //~ ERROR mismatched types
|
||||||
|
};
|
||||||
|
// FIXME: this should trigger feature gate
|
||||||
|
assert_eq!(State2, m2.state);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,12 @@
|
|||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/feature-gate-type_changing_struct_update.rs:20:11
|
||||||
|
|
|
||||||
|
LL | ..m1
|
||||||
|
| ^^ expected struct `State2`, found struct `State1`
|
||||||
|
|
|
||||||
|
= note: expected struct `Machine<State2>`
|
||||||
|
found struct `Machine<State1>`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0308`.
|
@ -2,15 +2,15 @@ error: `impl` item signature doesn't match `trait` item signature
|
|||||||
--> $DIR/mismatched_trait_impl-2.rs:8:5
|
--> $DIR/mismatched_trait_impl-2.rs:8:5
|
||||||
|
|
|
|
||||||
LL | fn deref(&self) -> &dyn Trait {
|
LL | fn deref(&self) -> &dyn Trait {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Struct) -> &dyn Trait`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct) -> &'1 (dyn Trait + '1)`
|
||||||
|
|
|
|
||||||
::: $SRC_DIR/core/src/ops/deref.rs:LL:COL
|
::: $SRC_DIR/core/src/ops/deref.rs:LL:COL
|
||||||
|
|
|
|
||||||
LL | fn deref(&self) -> &Self::Target;
|
LL | fn deref(&self) -> &Self::Target;
|
||||||
| --------------------------------- expected `fn(&Struct) -> &(dyn Trait + 'static)`
|
| --------------------------------- expected `fn(&'1 Struct) -> &'1 (dyn Trait + 'static)`
|
||||||
|
|
|
|
||||||
= note: expected `fn(&Struct) -> &(dyn Trait + 'static)`
|
= note: expected `fn(&'1 Struct) -> &'1 (dyn Trait + 'static)`
|
||||||
found `fn(&Struct) -> &dyn Trait`
|
found `fn(&'1 Struct) -> &'1 (dyn Trait + '1)`
|
||||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
|
|||||||
--> $DIR/mismatched_trait_impl.rs:9:5
|
--> $DIR/mismatched_trait_impl.rs:9:5
|
||||||
|
|
|
|
||||||
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
|
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
|
||||||
| ---------------------------------------------- expected `fn(&i32, &'a u32, &u32) -> &'a u32`
|
| ---------------------------------------------- expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||||
...
|
...
|
||||||
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &u32, &u32) -> &u32`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||||
|
|
|
|
||||||
= note: expected `fn(&i32, &'a u32, &u32) -> &'a u32`
|
= note: expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||||
found `fn(&i32, &u32, &u32) -> &u32`
|
found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
|
|||||||
--> $DIR/mismatched_trait_impl.rs:9:5
|
--> $DIR/mismatched_trait_impl.rs:9:5
|
||||||
|
|
|
|
||||||
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
|
LL | fn foo(&self, x: &'a u32, y: &u32) -> &'a u32;
|
||||||
| ---------------------------------------------- expected `fn(&i32, &'a u32, &u32) -> &'a u32`
|
| ---------------------------------------------- expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||||
...
|
...
|
||||||
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
LL | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &u32, &u32) -> &u32`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||||
|
|
|
|
||||||
= note: expected `fn(&i32, &'a u32, &u32) -> &'a u32`
|
= note: expected `fn(&'1 i32, &'a u32, &'2 u32) -> &'a u32`
|
||||||
found `fn(&i32, &u32, &u32) -> &u32`
|
found `fn(&'1 i32, &'2 u32, &'3 u32) -> &'3 u32`
|
||||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||||
|
|
||||||
|
11
src/test/ui/iterators/rsplit-clone.rs
Normal file
11
src/test/ui/iterators/rsplit-clone.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// check-pass
|
||||||
|
|
||||||
|
// RSplit<T, P> previously required T: Clone in order to be Clone
|
||||||
|
|
||||||
|
struct NotClone;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let elements = [NotClone, NotClone, NotClone];
|
||||||
|
let rsplit = elements.rsplit(|_| false);
|
||||||
|
rsplit.clone();
|
||||||
|
}
|
@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
|
|||||||
--> $DIR/lifetime-mismatch-between-trait-and-impl.rs:6:5
|
--> $DIR/lifetime-mismatch-between-trait-and-impl.rs:6:5
|
||||||
|
|
|
|
||||||
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
|
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
|
||||||
| ------------------------------------------- expected `fn(&i32, &'a i32) -> &'a i32`
|
| ------------------------------------------- expected `fn(&'1 i32, &'a i32) -> &'a i32`
|
||||||
...
|
...
|
||||||
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
|
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&i32, &i32) -> &i32`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'1 i32) -> &'1 i32`
|
||||||
|
|
|
|
||||||
= note: expected `fn(&i32, &'a i32) -> &'a i32`
|
= note: expected `fn(&'1 i32, &'a i32) -> &'a i32`
|
||||||
found `fn(&i32, &i32) -> &i32`
|
found `fn(&'1 i32, &'1 i32) -> &'1 i32`
|
||||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
|
|||||||
--> $DIR/issue-75361-mismatched-impl.rs:18:3
|
--> $DIR/issue-75361-mismatched-impl.rs:18:3
|
||||||
|
|
|
|
||||||
LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType>>;
|
LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType>>;
|
||||||
| --------------------------------------------------------------------- expected `fn(&T) -> Box<(dyn MyTrait<Item = &T> + 'static)>`
|
| --------------------------------------------------------------------- expected `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>`
|
||||||
...
|
...
|
||||||
LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType> + '_> {
|
LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType> + '_> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&T) -> Box<dyn MyTrait<Item = &T>>`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>`
|
||||||
|
|
|
|
||||||
= note: expected `fn(&T) -> Box<(dyn MyTrait<Item = &T> + 'static)>`
|
= note: expected `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>`
|
||||||
found `fn(&T) -> Box<dyn MyTrait<Item = &T>>`
|
found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>`
|
||||||
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||||
--> $DIR/issue-75361-mismatched-impl.rs:12:55
|
--> $DIR/issue-75361-mismatched-impl.rs:12:55
|
||||||
|
|
|
|
||||||
|
7
src/test/ui/panics/location-detail-panic-no-column.rs
Normal file
7
src/test/ui/panics/location-detail-panic-no-column.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// run-fail
|
||||||
|
// check-run-results
|
||||||
|
// compile-flags: -Zlocation-detail=line,file
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
panic!("column-redacted");
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
thread 'main' panicked at 'column-redacted', $DIR/location-detail-panic-no-column.rs:6:0
|
||||||
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
7
src/test/ui/panics/location-detail-panic-no-file.rs
Normal file
7
src/test/ui/panics/location-detail-panic-no-file.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// run-fail
|
||||||
|
// check-run-results
|
||||||
|
// compile-flags: -Zlocation-detail=line,column
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
panic!("file-redacted");
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
thread 'main' panicked at 'file-redacted', <redacted>:6:5
|
||||||
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
7
src/test/ui/panics/location-detail-panic-no-line.rs
Normal file
7
src/test/ui/panics/location-detail-panic-no-line.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// run-fail
|
||||||
|
// check-run-results
|
||||||
|
// compile-flags: -Zlocation-detail=file,column
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
panic!("line-redacted");
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
thread 'main' panicked at 'line-redacted', $DIR/location-detail-panic-no-line.rs:0:5
|
||||||
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
8
src/test/ui/panics/location-detail-unwrap-no-file.rs
Normal file
8
src/test/ui/panics/location-detail-unwrap-no-file.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// run-fail
|
||||||
|
// check-run-results
|
||||||
|
// compile-flags: -Zlocation-detail=line,column
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let opt: Option<u32> = None;
|
||||||
|
opt.unwrap();
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', <redacted>:7:9
|
||||||
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
|
|||||||
--> $DIR/param-without-lifetime-constraint.rs:14:5
|
--> $DIR/param-without-lifetime-constraint.rs:14:5
|
||||||
|
|
|
|
||||||
LL | fn get_relation(&self) -> To;
|
LL | fn get_relation(&self) -> To;
|
||||||
| ----------------------------- expected `fn(&Article) -> &ProofReader`
|
| ----------------------------- expected `fn(&'1 Article) -> &'2 ProofReader`
|
||||||
...
|
...
|
||||||
LL | fn get_relation(&self) -> &ProofReader {
|
LL | fn get_relation(&self) -> &ProofReader {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Article) -> &'1 ProofReader`
|
||||||
|
|
|
|
||||||
= note: expected `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&'1 Article) -> &'2 ProofReader`
|
||||||
found `fn(&Article) -> &ProofReader`
|
found `fn(&'1 Article) -> &'1 ProofReader`
|
||||||
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||||
--> $DIR/param-without-lifetime-constraint.rs:10:31
|
--> $DIR/param-without-lifetime-constraint.rs:10:31
|
||||||
|
|
|
|
||||||
|
@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature
|
|||||||
--> $DIR/self-without-lifetime-constraint.rs:45:5
|
--> $DIR/self-without-lifetime-constraint.rs:45:5
|
||||||
|
|
|
|
||||||
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
|
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
|
||||||
| -------------------------------------------------------------------- expected `fn(ValueRef<'_>) -> Result<(&str, &&str), FromSqlError>`
|
| -------------------------------------------------------------------- expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>`
|
||||||
...
|
...
|
||||||
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
|
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'_>) -> Result<(&str, &&str), FromSqlError>`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>`
|
||||||
|
|
|
|
||||||
= note: expected `fn(ValueRef<'_>) -> Result<(&str, &&str), _>`
|
= note: expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>`
|
||||||
found `fn(ValueRef<'_>) -> Result<(&str, &&str), _>`
|
found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>`
|
||||||
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||||
--> $DIR/self-without-lifetime-constraint.rs:41:60
|
--> $DIR/self-without-lifetime-constraint.rs:41:60
|
||||||
|
|
|
|
||||||
|
@ -349,6 +349,9 @@ pub struct Config {
|
|||||||
/// The current Rust channel
|
/// The current Rust channel
|
||||||
pub channel: String,
|
pub channel: String,
|
||||||
|
|
||||||
|
/// The default Rust edition
|
||||||
|
pub edition: Option<String>,
|
||||||
|
|
||||||
// Configuration for various run-make tests frobbing things like C compilers
|
// Configuration for various run-make tests frobbing things like C compilers
|
||||||
// or querying about various LLVM component information.
|
// or querying about various LLVM component information.
|
||||||
pub cc: String,
|
pub cc: String,
|
||||||
|
@ -222,6 +222,7 @@ impl TestProps {
|
|||||||
/// `//[foo]`), then the property is ignored unless `cfg` is
|
/// `//[foo]`), then the property is ignored unless `cfg` is
|
||||||
/// `Some("foo")`.
|
/// `Some("foo")`.
|
||||||
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
|
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
|
||||||
|
let mut has_edition = false;
|
||||||
if !testfile.is_dir() {
|
if !testfile.is_dir() {
|
||||||
let file = File::open(testfile).unwrap();
|
let file = File::open(testfile).unwrap();
|
||||||
|
|
||||||
@ -240,6 +241,7 @@ impl TestProps {
|
|||||||
|
|
||||||
if let Some(edition) = config.parse_edition(ln) {
|
if let Some(edition) = config.parse_edition(ln) {
|
||||||
self.compile_flags.push(format!("--edition={}", edition));
|
self.compile_flags.push(format!("--edition={}", edition));
|
||||||
|
has_edition = true;
|
||||||
if edition == "2021" {
|
if edition == "2021" {
|
||||||
self.compile_flags.push("-Zunstable-options".to_string());
|
self.compile_flags.push("-Zunstable-options".to_string());
|
||||||
}
|
}
|
||||||
@ -391,6 +393,10 @@ impl TestProps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let (Some(edition), false) = (&config.edition, has_edition) {
|
||||||
|
self.compile_flags.push(format!("--edition={}", edition));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_fail_mode(&mut self, ln: &str, config: &Config) {
|
fn update_fail_mode(&mut self, ln: &str, config: &Config) {
|
||||||
|
@ -147,7 +147,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||||||
)
|
)
|
||||||
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
|
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
|
||||||
.optflag("h", "help", "show this message")
|
.optflag("h", "help", "show this message")
|
||||||
.reqopt("", "channel", "current Rust channel", "CHANNEL");
|
.reqopt("", "channel", "current Rust channel", "CHANNEL")
|
||||||
|
.optopt("", "edition", "default Rust edition", "EDITION");
|
||||||
|
|
||||||
let (argv0, args_) = args.split_first().unwrap();
|
let (argv0, args_) = args.split_first().unwrap();
|
||||||
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
|
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
|
||||||
@ -282,6 +283,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||||||
rustfix_coverage: matches.opt_present("rustfix-coverage"),
|
rustfix_coverage: matches.opt_present("rustfix-coverage"),
|
||||||
has_tidy,
|
has_tidy,
|
||||||
channel: matches.opt_str("channel").unwrap(),
|
channel: matches.opt_str("channel").unwrap(),
|
||||||
|
edition: matches.opt_str("edition"),
|
||||||
|
|
||||||
cc: matches.opt_str("cc").unwrap(),
|
cc: matches.opt_str("cc").unwrap(),
|
||||||
cxx: matches.opt_str("cxx").unwrap(),
|
cxx: matches.opt_str("cxx").unwrap(),
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
name: upload
|
name: upload
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
release:
|
release:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-release:
|
build-release:
|
||||||
@ -14,42 +16,40 @@ jobs:
|
|||||||
- build: linux-x86_64
|
- build: linux-x86_64
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
rust: nightly
|
rust: nightly
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
- build: macos-x86_64
|
- build: macos-x86_64
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
rust: nightly
|
rust: nightly
|
||||||
|
target: x86_64-apple-darwin
|
||||||
- build: windows-x86_64-gnu
|
- build: windows-x86_64-gnu
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
rust: nightly-x86_64-gnu
|
rust: nightly-x86_64-gnu
|
||||||
|
target: x86_64-pc-windows-gnu
|
||||||
- build: windows-x86_64-msvc
|
- build: windows-x86_64-msvc
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
rust: nightly-x86_64-msvc
|
rust: nightly-x86_64-msvc
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install Rust
|
# Run build
|
||||||
uses: actions-rs/toolchain@v1
|
- name: install rustup
|
||||||
with:
|
run: |
|
||||||
profile: minimal
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
|
||||||
toolchain: ${{ matrix.rust }}
|
sh rustup-init.sh -y --default-toolchain none
|
||||||
override: true
|
rustup target add ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Add mingw64 to path for x86_64-gnu
|
- name: Add mingw64 to path for x86_64-gnu
|
||||||
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
|
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
|
||||||
if: matrix.rust == 'nightly-x86_64-gnu'
|
if: matrix.rust == 'nightly-x86_64-gnu'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install cargo-make
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: install
|
|
||||||
args: --force cargo-make
|
|
||||||
|
|
||||||
- name: Build release binaries
|
- name: Build release binaries
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: make
|
command: build
|
||||||
args: release
|
args: --release
|
||||||
|
|
||||||
- name: Build archive
|
- name: Build archive
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -70,6 +70,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload Release Asset
|
- name: Upload Release Asset
|
||||||
|
if: github.event_name == 'release'
|
||||||
uses: actions/upload-release-asset@v1
|
uses: actions/upload-release-asset@v1
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
@ -54,9 +54,6 @@ jobs:
|
|||||||
if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
|
if: matrix.target == 'x86_64-pc-windows-gnu' && matrix.channel == 'nightly'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: cargo-make
|
|
||||||
run: cargo install --force cargo-make
|
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
rustc -Vv
|
rustc -Vv
|
||||||
|
1
src/tools/rustfmt/.gitignore
vendored
1
src/tools/rustfmt/.gitignore
vendored
@ -5,6 +5,7 @@
|
|||||||
# Generated by Cargo
|
# Generated by Cargo
|
||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
/target
|
/target
|
||||||
|
tests/cargo-fmt/**/target
|
||||||
|
|
||||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
|
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
|
||||||
|
@ -2,6 +2,73 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.4.38] 2021-10-20
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Switched from `rustc-ap-*` crates to `rustc_private` for consumption model of rustc internals
|
||||||
|
- `annotate-snippets` updated to v0.8 [PR #4762](https://github.com/rust-lang/rustfmt/pull/4762)
|
||||||
|
- Greatly improved the performance of `cargo fmt` in large workspaces utilizing the `--all` flag by updating to a newer version of `cargo_metadata` that leverages updated `cargo` output from v1.51+ [PR #4997](https://github.com/rust-lang/rustfmt/pull/4997)
|
||||||
|
- Improved formatting of long slice patterns [#4530](https://github.com/rust-lang/rustfmt/issues/4530)
|
||||||
|
- **Note you must have `version = Two` in your configuration to take advantage of the new formatting**
|
||||||
|
- Stabilized `match_block_trailing_comma` configuration option [#3380](https://github.com/rust-lang/rustfmt/issues/3380) - [https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#match_block_trailing_comma](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#match_block_trailing_comma)
|
||||||
|
- Stabilized `disable_all_formatting` configuration option [#5026](https://github.com/rust-lang/rustfmt/pull/5026) - [https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#disable_all_formatting](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#disable_all_formatting)
|
||||||
|
- Various improvements to the configuration documentation website [https://rust-lang.github.io/rustfmt/?version=v1.4.38]([https://rust-lang.github.io/rustfmt/?version=v1.4.38])
|
||||||
|
- Addressed various clippy and rustc warnings
|
||||||
|
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Resolved issue where specious whitespace would be inserted when a block style comment was terminated within string literal processing [#4312](https://github.com/rust-lang/rustfmt/issues/4312)
|
||||||
|
- Nested out-of-line mods are again parsed and formatted [#4874](https://github.com/rust-lang/rustfmt/issues/4874)
|
||||||
|
- Accepts `2021` for edition value from rustfmt command line [PR #4847](https://github.com/rust-lang/rustfmt/pull/4847)
|
||||||
|
- Unstable command line options are no longer displayed in `--help` text on stable [PR #4798](https://github.com/rust-lang/rustfmt/issues/4798)
|
||||||
|
- Stopped panicking on patterns in match arms which start with non-ascii characters [#4868](https://github.com/rust-lang/rustfmt/issues/4868)
|
||||||
|
- Stopped stripping defaults on const params [#4816](https://github.com/rust-lang/rustfmt/issues/4816)
|
||||||
|
- Fixed issue with dropped content with GAT aliases with self bounds in impls [#4911](https://github.com/rust-lang/rustfmt/issues/4911)
|
||||||
|
- Stopped removing generic args on associated type constraints [#4943](https://github.com/rust-lang/rustfmt/issues/4943)
|
||||||
|
- Stopped dropping visibility on certain trait and impl items [#4960](https://github.com/rust-lang/rustfmt/issues/4960)
|
||||||
|
- Fixed dropping of qualified paths in struct patterns [#4908](https://github.com/rust-lang/rustfmt/issues/4908) and [#5005](https://github.com/rust-lang/rustfmt/issues/5005)
|
||||||
|
- Fixed bug in line width calculation that was causing specious formatting of certain patterns [#4031](https://github.com/rust-lang/rustfmt/issues/4031)
|
||||||
|
- **Note that this bug fix may cause observable formatting changes in cases where code had been formatted with prior versions of rustfmt that contained the bug**
|
||||||
|
- Fixed bug where rustfmt would drop parameter attributes if they were too long in certain cases [#4579](https://github.com/rust-lang/rustfmt/issues/4579)
|
||||||
|
- Resolved idempotency issue with extern body elements [#4963](https://github.com/rust-lang/rustfmt/issues/4963)
|
||||||
|
- rustfmt will now handle doc-style comments on function parameters, since they could appear with certain macro usage patterns even though it's generally invalid syntax [#4936](https://github.com/rust-lang/rustfmt/issues/4936)
|
||||||
|
- Fixed bug in `match_block_trailing_comma` where commas were not added to the blocks of bodies whose arm had a guard that did not fit on the same line as the pattern [#4998](https://github.com/rust-lang/rustfmt/pull/4998)
|
||||||
|
- Fixed bug in cases where derive attributes started with a block style comment [#4984](https://github.com/rust-lang/rustfmt/issues/4984)
|
||||||
|
- Fixed issue where the struct rest could be lost when `struct_field_align_threshold` was enabled [#4926](https://github.com/rust-lang/rustfmt/issues/4926)
|
||||||
|
- Handles cases where certain control flow type expressions have comments between patterns/keywords and the pattern ident contains the keyword [#5009](https://github.com/rust-lang/rustfmt/issues/5009)
|
||||||
|
- Handles tuple structs that have explicit visibilities and start with a block style comment [#5011](https://github.com/rust-lang/rustfmt/issues/5011)
|
||||||
|
- Handles leading line-style comments in certain types of macro calls [#4615](https://github.com/rust-lang/rustfmt/issues/4615)
|
||||||
|
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Granular width heuristic options made available for user control [PR #4782](https://github.com/rust-lang/rustfmt/pull/4782). This includes the following:
|
||||||
|
- [`array_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#array_width)
|
||||||
|
- [`attr_fn_like_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#attr_fn_like_width)
|
||||||
|
- [`chain_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#chain_width)
|
||||||
|
- [`fn_call_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#fn_call_width)
|
||||||
|
- [`single_line_if_else_max_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#single_line_if_else_max_width)
|
||||||
|
- [`struct_lit_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_lit_width)
|
||||||
|
- [`struct_variant_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_variant_width)
|
||||||
|
|
||||||
|
Note this hit the rustup distributions prior to the v1.4.38 release as part of an out-of-cycle updates, but is listed in this version because the feature was not in the other v1.4.37 releases. See also the `use_small_heuristics` section on the configuration site for more information
|
||||||
|
[https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics)
|
||||||
|
|
||||||
|
- New `One` variant added to `imports_granularity` configuration option which can be used to reformat all imports into a single use statement [#4669](https://github.com/rust-lang/rustfmt/issues/4669)
|
||||||
|
- rustfmt will now skip files that are annotated with `@generated` at the top of the file [#3958](https://github.com/rust-lang/rustfmt/issues/3958)
|
||||||
|
- New configuration option `hex_literal_case` that allows user to control the casing utilized for hex literals [PR #4903](https://github.com/rust-lang/rustfmt/pull/4903)
|
||||||
|
|
||||||
|
See the section on the configuration site for more information
|
||||||
|
https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#hex_literal_case
|
||||||
|
|
||||||
|
- `cargo fmt` now directly supports the `--check` flag, which means it's now possible to run `cargo fmt --check` instead of the more verbose `cargo fmt -- --check` [#3888](https://github.com/rust-lang/rustfmt/issues/3888)
|
||||||
|
|
||||||
|
### Install/Download Options
|
||||||
|
- **rustup (nightly)** - *pending*
|
||||||
|
- **GitHub Release Binaries** - [Release v1.4.38](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.38)
|
||||||
|
- **Build from source** - [Tag v1.4.38](https://github.com/rust-lang/rustfmt/tree/v1.4.38), see instructions for how to [install rustfmt from source][install-from-source]
|
||||||
|
|
||||||
## [1.4.37] 2021-04-03
|
## [1.4.37] 2021-04-03
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -35,21 +35,6 @@ version = "1.0.25"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14"
|
checksum = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arrayref"
|
|
||||||
version = "0.3.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arrayvec"
|
|
||||||
version = "0.4.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9"
|
|
||||||
dependencies = [
|
|
||||||
"nodrop",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.13"
|
version = "0.2.13"
|
||||||
@ -62,40 +47,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "0.1.7"
|
version = "1.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
|
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "backtrace"
|
|
||||||
version = "0.3.40"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
|
|
||||||
dependencies = [
|
|
||||||
"backtrace-sys",
|
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"libc",
|
|
||||||
"rustc-demangle",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "backtrace-sys"
|
|
||||||
version = "0.1.32"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64"
|
|
||||||
version = "0.10.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
@ -103,17 +57,6 @@ version = "1.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "blake2b_simd"
|
|
||||||
version = "0.5.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182"
|
|
||||||
dependencies = [
|
|
||||||
"arrayref",
|
|
||||||
"arrayvec",
|
|
||||||
"constant_time_eq",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bstr"
|
name = "bstr"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
@ -125,37 +68,44 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytecount"
|
name = "bytecount"
|
||||||
version = "0.6.0"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b0017894339f586ccb943b01b9555de56770c11cda818e7e3d8bd93f4ed7f46e"
|
checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"packed_simd",
|
"packed_simd_2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "camino"
|
||||||
version = "1.3.2"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
checksum = "52d74260d9bf6944e2208aa46841b4b8f0d7ffc0849a06837b2f510337f86b2b"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cargo-platform"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo_metadata"
|
name = "cargo_metadata"
|
||||||
version = "0.8.2"
|
version = "0.14.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "700b3731fd7d357223d0000f4dbf1808401b694609035c3c411fbc0cd375c426"
|
checksum = "c297bd3135f558552f99a0daa180876984ea2c4ffa7470314540dff8c654109a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"camino",
|
||||||
|
"cargo-platform",
|
||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cc"
|
|
||||||
version = "1.0.46"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
@ -183,48 +133,14 @@ dependencies = [
|
|||||||
"vec_map",
|
"vec_map",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cloudabi"
|
|
||||||
version = "0.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "constant_time_eq"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-channel"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-utils 0.7.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.6.6"
|
version = "0.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
|
checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49"
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"lazy_static",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-utils"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 1.0.0",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -257,11 +173,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys"
|
name = "dirs-sys"
|
||||||
version = "0.3.4"
|
version = "0.3.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b"
|
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"libc",
|
"libc",
|
||||||
"redox_users",
|
"redox_users",
|
||||||
"winapi",
|
"winapi",
|
||||||
@ -275,9 +190,9 @@ checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.6.2"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
|
checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"humantime",
|
"humantime",
|
||||||
@ -286,40 +201,12 @@ dependencies = [
|
|||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "failure"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
|
|
||||||
dependencies = [
|
|
||||||
"backtrace",
|
|
||||||
"failure_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "failure_derive"
|
|
||||||
version = "0.1.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
"synstructure",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fuchsia-cprng"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getopts"
|
name = "getopts"
|
||||||
version = "0.2.21"
|
version = "0.2.21"
|
||||||
@ -330,10 +217,21 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "globset"
|
name = "getrandom"
|
||||||
version = "0.4.4"
|
version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2"
|
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "globset"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"bstr",
|
"bstr",
|
||||||
@ -353,36 +251,33 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "humantime"
|
name = "humantime"
|
||||||
version = "1.3.0"
|
version = "2.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
dependencies = [
|
|
||||||
"quick-error",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ignore"
|
name = "ignore"
|
||||||
version = "0.4.11"
|
version = "0.4.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "522daefc3b69036f80c7d2990b28ff9e0471c683bad05ca258e0a01dd22c5a1e"
|
checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-channel",
|
"crossbeam-utils",
|
||||||
"globset",
|
"globset",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex",
|
"regex",
|
||||||
"same-file",
|
"same-file",
|
||||||
"thread_local 1.0.1",
|
"thread_local",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
|
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
"either",
|
||||||
]
|
]
|
||||||
@ -405,6 +300,12 @@ version = "0.2.77"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
|
checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.14"
|
version = "0.4.14"
|
||||||
@ -421,18 +322,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
|
checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nodrop"
|
name = "packed_simd_2"
|
||||||
version = "0.1.14"
|
version = "0.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
|
checksum = "3278e0492f961fd4ae70909f56b2723a7e8d01a228427294e19cdfdebda89a17"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "packed_simd"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a85ea9fc0d4ac0deb6fe7911d38786b32fc11119afd9e9d38b84ff691ce64220"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
|
"libm",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -463,19 +359,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.6"
|
version = "1.0.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
|
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quick-error"
|
|
||||||
version = "1.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
@ -485,96 +375,42 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.4.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_os"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
|
|
||||||
dependencies = [
|
|
||||||
"cloudabi",
|
|
||||||
"fuchsia-cprng",
|
|
||||||
"libc",
|
|
||||||
"rand_core 0.4.2",
|
|
||||||
"rdrand",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rdrand"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.1.56"
|
version = "0.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_users"
|
name = "redox_users"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d"
|
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"failure",
|
"getrandom",
|
||||||
"rand_os",
|
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"rust-argon2",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.3.1"
|
version = "1.4.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"
|
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
"thread_local 0.3.6",
|
"thread_local",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.6.12"
|
version = "0.6.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
|
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rust-argon2"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf"
|
|
||||||
dependencies = [
|
|
||||||
"base64",
|
|
||||||
"blake2b_simd",
|
|
||||||
"crossbeam-utils 0.6.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-demangle"
|
|
||||||
version = "0.1.16"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-workspace-hack"
|
name = "rustc-workspace-hack"
|
||||||
@ -593,7 +429,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustfmt-nightly"
|
name = "rustfmt-nightly"
|
||||||
version = "1.4.37"
|
version = "1.4.38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets",
|
"annotate-snippets",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@ -639,34 +475,27 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "0.9.0"
|
version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"semver-parser",
|
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.101"
|
version = "1.0.126"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd"
|
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.101"
|
version = "1.0.126"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e"
|
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -675,9 +504,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.41"
|
version = "1.0.59"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2"
|
checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
@ -716,9 +545,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.11"
|
version = "1.0.65"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238"
|
checksum = "f3a1d708c221c5a612956ef9f75b37e454e88d1f7b899fbd3a18d4252012d663"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -736,18 +565,6 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "synstructure"
|
|
||||||
version = "0.12.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "term"
|
name = "term"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
@ -796,15 +613,6 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thread_local"
|
|
||||||
version = "0.3.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thread_local"
|
name = "thread_local"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@ -870,6 +678,12 @@ dependencies = [
|
|||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.2+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
|
|
||||||
name = "rustfmt-nightly"
|
name = "rustfmt-nightly"
|
||||||
version = "1.4.37"
|
version = "1.4.38"
|
||||||
description = "Tool to find and fix Rust formatting issues"
|
description = "Tool to find and fix Rust formatting issues"
|
||||||
repository = "https://github.com/rust-lang/rustfmt"
|
repository = "https://github.com/rust-lang/rustfmt"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -33,7 +33,7 @@ rustfmt-format-diff = []
|
|||||||
generic-simd = ["bytecount/generic-simd"]
|
generic-simd = ["bytecount/generic-simd"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
itertools = "0.8"
|
itertools = "0.9"
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
@ -42,15 +42,15 @@ regex = "1.0"
|
|||||||
term = "0.6"
|
term = "0.6"
|
||||||
diff = "0.1"
|
diff = "0.1"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
env_logger = "0.6"
|
env_logger = "0.8"
|
||||||
getopts = "0.2"
|
getopts = "0.2"
|
||||||
derive-new = "0.5"
|
derive-new = "0.5"
|
||||||
cargo_metadata = "0.8"
|
cargo_metadata = "0.14"
|
||||||
bytecount = "0.6"
|
bytecount = "0.6"
|
||||||
unicode-width = "0.1.5"
|
unicode-width = "0.1.5"
|
||||||
unicode_categories = "0.1.1"
|
unicode_categories = "0.1.1"
|
||||||
dirs = "2.0.1"
|
dirs = "2.0.1"
|
||||||
ignore = "0.4.11"
|
ignore = "0.4.17"
|
||||||
annotate-snippets = { version = "0.8", features = ["color"] }
|
annotate-snippets = { version = "0.8", features = ["color"] }
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
|
rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
|
||||||
|
@ -521,11 +521,13 @@ fn main() {
|
|||||||
|
|
||||||
## `disable_all_formatting`
|
## `disable_all_formatting`
|
||||||
|
|
||||||
Don't reformat anything
|
Don't reformat anything.
|
||||||
|
|
||||||
|
Note that this option may be soft-deprecated in the future once the [ignore](#ignore) option is stabilized. Nightly toolchain users are encouraged to use [ignore](#ignore) instead when possible.
|
||||||
|
|
||||||
- **Default value**: `false`
|
- **Default value**: `false`
|
||||||
- **Possible values**: `true`, `false`
|
- **Possible values**: `true`, `false`
|
||||||
- **Stable**: No (tracking issue: #3388)
|
- **Stable**: Yes
|
||||||
|
|
||||||
## `edition`
|
## `edition`
|
||||||
|
|
||||||
@ -924,6 +926,15 @@ fn add_one(x: i32) -> i32 {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `format_generated_files`
|
||||||
|
|
||||||
|
Format generated files. A file is considered generated
|
||||||
|
if any of the first five lines contains `@generated` marker.
|
||||||
|
|
||||||
|
- **Default value**: `false`
|
||||||
|
- **Possible values**: `true`, `false`
|
||||||
|
- **Stable**: No
|
||||||
|
|
||||||
## `format_macro_matchers`
|
## `format_macro_matchers`
|
||||||
|
|
||||||
Format the metavariable matching patterns in macros.
|
Format the metavariable matching patterns in macros.
|
||||||
@ -1047,6 +1058,13 @@ fn lorem() -> usize {
|
|||||||
|
|
||||||
See also: [`tab_spaces`](#tab_spaces).
|
See also: [`tab_spaces`](#tab_spaces).
|
||||||
|
|
||||||
|
## `hex_literal_case`
|
||||||
|
|
||||||
|
Control the case of the letters in hexadecimal literal values
|
||||||
|
|
||||||
|
- **Default value**: `Preserve`
|
||||||
|
- **Possible values**: `Upper`, `Lower`
|
||||||
|
- **Stable**: No
|
||||||
|
|
||||||
## `hide_parse_errors`
|
## `hide_parse_errors`
|
||||||
|
|
||||||
@ -1610,7 +1628,7 @@ Put a trailing comma after a block based match arm (non-block arms are not affec
|
|||||||
|
|
||||||
- **Default value**: `false`
|
- **Default value**: `false`
|
||||||
- **Possible values**: `true`, `false`
|
- **Possible values**: `true`, `false`
|
||||||
- **Stable**: No (tracking issue: #3380)
|
- **Stable**: Yes
|
||||||
|
|
||||||
#### `false` (default):
|
#### `false` (default):
|
||||||
|
|
||||||
@ -1668,6 +1686,9 @@ pub enum Foo {}
|
|||||||
#### `false`:
|
#### `false`:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
||||||
|
pub enum Bar {}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Eq, PartialEq)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@ -1679,7 +1700,7 @@ pub enum Foo {}
|
|||||||
How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
|
How imports should be grouped into `use` statements. Imports will be merged or split to the configured level of granularity.
|
||||||
|
|
||||||
- **Default value**: `Preserve`
|
- **Default value**: `Preserve`
|
||||||
- **Possible values**: `Preserve`, `Crate`, `Module`, `Item`
|
- **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One`
|
||||||
- **Stable**: No
|
- **Stable**: No
|
||||||
|
|
||||||
#### `Preserve` (default):
|
#### `Preserve` (default):
|
||||||
@ -1733,6 +1754,23 @@ use qux::h;
|
|||||||
use qux::i;
|
use qux::i;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `One`:
|
||||||
|
|
||||||
|
Merge all imports into a single `use` statement as long as they have the same visibility.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
pub use foo::{x, y};
|
||||||
|
use {
|
||||||
|
bar::{
|
||||||
|
a,
|
||||||
|
b::{self, f, g},
|
||||||
|
c,
|
||||||
|
d::e,
|
||||||
|
},
|
||||||
|
qux::{h, i},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## `merge_imports`
|
## `merge_imports`
|
||||||
|
|
||||||
This option is deprecated. Use `imports_granularity = "Crate"` instead.
|
This option is deprecated. Use `imports_granularity = "Crate"` instead.
|
||||||
@ -1824,6 +1862,9 @@ Convert `#![doc]` and `#[doc]` attributes to `//!` and `///` doc comments.
|
|||||||
#![doc = "Example documentation"]
|
#![doc = "Example documentation"]
|
||||||
|
|
||||||
#[doc = "Example item documentation"]
|
#[doc = "Example item documentation"]
|
||||||
|
pub enum Bar {}
|
||||||
|
|
||||||
|
/// Example item documentation
|
||||||
pub enum Foo {}
|
pub enum Foo {}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1938,6 +1979,8 @@ fn main() {
|
|||||||
#### `false`:
|
#### `false`:
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
|
(foo());
|
||||||
|
|
||||||
((((foo()))));
|
((((foo()))));
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -1963,6 +2006,14 @@ impl Iterator for Dummy {
|
|||||||
|
|
||||||
type Item = i32;
|
type Item = i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Iterator for Dummy {
|
||||||
|
type Item = i32;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `true`
|
#### `true`
|
||||||
@ -2519,7 +2570,8 @@ fn main() {
|
|||||||
let x = 1;
|
let x = 1;
|
||||||
let y = 2;
|
let y = 2;
|
||||||
let z = 3;
|
let z = 3;
|
||||||
let a = Foo { x: x, y: y, z: z };
|
let a = Foo { x, y, z };
|
||||||
|
let b = Foo { x: x, y: y, z: z };
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -2688,6 +2740,8 @@ Replace uses of the try! macro by the ? shorthand
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let lorem = ipsum.map(|dolor| dolor.sit())?;
|
||||||
|
|
||||||
let lorem = try!(ipsum.map(|dolor| dolor.sit()));
|
let lorem = try!(ipsum.map(|dolor| dolor.sit()));
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -2759,6 +2813,12 @@ Break comments to fit on the line
|
|||||||
#### `false` (default):
|
#### `false` (default):
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
// 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.
|
||||||
|
|
||||||
// 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.
|
// 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.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,55 +1,8 @@
|
|||||||
# This is based on https://github.com/japaric/rust-everywhere/blob/master/appveyor.yml
|
|
||||||
# and modified (mainly removal of deployment) to suit rustfmt.
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
global:
|
global:
|
||||||
PROJECT_NAME: rustfmt
|
PROJECT_NAME: rustfmt
|
||||||
matrix:
|
|
||||||
# Stable channel
|
|
||||||
# - TARGET: i686-pc-windows-gnu
|
|
||||||
# CHANNEL: stable
|
|
||||||
# - TARGET: i686-pc-windows-msvc
|
|
||||||
# CHANNEL: stable
|
|
||||||
# - TARGET: x86_64-pc-windows-gnu
|
|
||||||
# CHANNEL: stable
|
|
||||||
# - TARGET: x86_64-pc-windows-msvc
|
|
||||||
# CHANNEL: stable
|
|
||||||
# Beta channel
|
|
||||||
# - TARGET: i686-pc-windows-gnu
|
|
||||||
# CHANNEL: beta
|
|
||||||
# - TARGET: i686-pc-windows-msvc
|
|
||||||
# CHANNEL: beta
|
|
||||||
# - TARGET: x86_64-pc-windows-gnu
|
|
||||||
# CHANNEL: beta
|
|
||||||
# - TARGET: x86_64-pc-windows-msvc
|
|
||||||
# CHANNEL: beta
|
|
||||||
# Nightly channel
|
|
||||||
- TARGET: i686-pc-windows-gnu
|
|
||||||
CHANNEL: nightly
|
|
||||||
- TARGET: i686-pc-windows-msvc
|
|
||||||
CHANNEL: nightly
|
|
||||||
- TARGET: x86_64-pc-windows-gnu
|
|
||||||
CHANNEL: nightly
|
|
||||||
- TARGET: x86_64-pc-windows-msvc
|
|
||||||
CHANNEL: nightly
|
|
||||||
|
|
||||||
# Install Rust and Cargo
|
|
||||||
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
|
|
||||||
install:
|
|
||||||
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
|
|
||||||
- if "%TARGET%" == "i686-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw32\bin
|
|
||||||
- if "%TARGET%" == "x86_64-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw64\bin
|
|
||||||
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
|
|
||||||
- rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y
|
|
||||||
- rustc -Vv
|
|
||||||
- cargo -V
|
|
||||||
|
|
||||||
# ???
|
|
||||||
build: false
|
build: false
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- set CFG_RELEASE_CHANNEL=nightly
|
- echo Why does no one have access to delete me?
|
||||||
- set CFG_RELEASE=nightly
|
|
||||||
- cargo build --verbose
|
|
||||||
- cargo test
|
|
||||||
- cargo test -- --ignored
|
|
||||||
|
@ -2,9 +2,13 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width">
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<title>Rustfmt</title>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.css" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.css" />
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/github-gist.min.css">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
|
||||||
|
<script src="https://unpkg.com/vue-async-computed@3.8.1"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/highlight.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
@ -38,6 +42,15 @@
|
|||||||
.searchCondition > div {
|
.searchCondition > div {
|
||||||
margin-right: 30px;
|
margin-right: 30px;
|
||||||
}
|
}
|
||||||
|
.header-link {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.header-link:hover::before {
|
||||||
|
position: absolute;
|
||||||
|
left: -2em;
|
||||||
|
padding-right: 0.5em;
|
||||||
|
content: '\2002\00a7\2002';
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -59,6 +72,14 @@
|
|||||||
<label for="stable">stable: </label>
|
<label for="stable">stable: </label>
|
||||||
<input type="checkbox" id="stable" v-model="shouldStable">
|
<input type="checkbox" id="stable" v-model="shouldStable">
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="viewVersion">version: </label>
|
||||||
|
<select name="viewVersion" id="viewVersion" v-model="viewVersion">
|
||||||
|
<option v-for="option in versionOptions" v-bind:value="option">
|
||||||
|
{{ option }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-html="aboutHtml"></div>
|
<div v-html="aboutHtml"></div>
|
||||||
<div v-html="configurationAboutHtml"></div>
|
<div v-html="configurationAboutHtml"></div>
|
||||||
@ -66,63 +87,155 @@
|
|||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
const ConfigurationMdUrl = 'https://raw.githubusercontent.com/rust-lang/rustfmt/master/Configurations.md';
|
const RusfmtTagsUrl = 'https://api.github.com/repos/rust-lang/rustfmt/tags';
|
||||||
|
const RustfmtLatestUrl = 'https://api.github.com/repos/rust-lang/rustfmt/releases/latest';
|
||||||
const UrlHash = window.location.hash.replace(/^#/, '');
|
const UrlHash = window.location.hash.replace(/^#/, '');
|
||||||
|
const queryParams = new URLSearchParams(window.location.search);
|
||||||
|
const searchParam = queryParams.get('search');
|
||||||
|
const searchTerm = null !== searchParam ? searchParam : '';
|
||||||
|
const versionParam = queryParams.get('version');
|
||||||
|
const parseVersionParam = (version) => {
|
||||||
|
if (version === 'master') return 'master';
|
||||||
|
if (version.startsWith('v')) return version;
|
||||||
|
return `v${version}`;
|
||||||
|
};
|
||||||
|
const versionNumber = null !== versionParam ? parseVersionParam(versionParam) : 'master';
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data() {
|
data: {
|
||||||
const configurationDescriptions = [];
|
aboutHtml: '',
|
||||||
configurationDescriptions.links = {};
|
configurationAboutHtml: '',
|
||||||
return {
|
configurationDescriptions: [],
|
||||||
aboutHtml: '',
|
searchCondition: searchTerm,
|
||||||
configurationAboutHtml: '',
|
shouldStable: false,
|
||||||
searchCondition: UrlHash,
|
viewVersion: versionNumber,
|
||||||
configurationDescriptions,
|
oldViewVersion: undefined,
|
||||||
shouldStable: false
|
versionOptions: ['master'],
|
||||||
}
|
scrolledOnce: false,
|
||||||
},
|
},
|
||||||
computed: {
|
asyncComputed: {
|
||||||
outputHtml() {
|
async updateVersion() {
|
||||||
const ast = this.configurationDescriptions
|
let latest;
|
||||||
.filter(({ head, text, stable }) => {
|
try {
|
||||||
|
latest = (await axios.get(RustfmtLatestUrl)).data;
|
||||||
|
} catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (versionParam == null) {
|
||||||
|
this.viewVersion = latest.name;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async outputHtml() {
|
||||||
|
if (this.viewVersion !== this.oldViewVersion) {
|
||||||
|
const ConfigurationMdUrl =
|
||||||
|
`https://raw.githubusercontent.com/rust-lang/rustfmt/${this.viewVersion}/Configurations.md`;
|
||||||
|
let res;
|
||||||
|
try {
|
||||||
|
res = await axios.get(ConfigurationMdUrl).catch(e => { throw e });
|
||||||
|
} catch(e) {
|
||||||
|
this.handleReqFailure(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const {
|
||||||
|
about,
|
||||||
|
configurationAbout,
|
||||||
|
configurationDescriptions
|
||||||
|
} = parseMarkdownAst(res.data);
|
||||||
|
this.aboutHtml = marked.parser(about);
|
||||||
|
this.configurationAboutHtml = marked.parser(configurationAbout);
|
||||||
|
this.configurationDescriptions = configurationDescriptions;
|
||||||
|
this.oldViewVersion = this.viewVersion;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
const ast = this.configurationDescriptions
|
||||||
text.includes(this.searchCondition) === false &&
|
.filter(({ head, text, stable }) => {
|
||||||
head.includes(this.searchCondition) === false
|
if (text.includes(this.searchCondition) === false &&
|
||||||
) {
|
head.includes(this.searchCondition) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (this.shouldStable)
|
return (this.shouldStable)
|
||||||
? stable === true
|
? stable === true
|
||||||
: true;
|
: true;
|
||||||
})
|
})
|
||||||
.reduce((stack, { value }) => {
|
.reduce((stack, { value }) => {
|
||||||
return stack.concat(value);
|
return stack.concat(value);
|
||||||
}, []);
|
}, []);
|
||||||
ast.links = {};
|
ast.links = {};
|
||||||
return marked.parser(ast);
|
|
||||||
|
queryParams.set('version', this.viewVersion);
|
||||||
|
queryParams.set('search', this.searchCondition);
|
||||||
|
const curUrl = window.location.pathname +
|
||||||
|
'?' + queryParams.toString() + window.location.hash;
|
||||||
|
history.pushState(null, '', curUrl);
|
||||||
|
|
||||||
|
const renderer = new marked.Renderer();
|
||||||
|
renderer.heading = function(text, level) {
|
||||||
|
const id = htmlToId(text);
|
||||||
|
return `<h${level}>
|
||||||
|
<a id="${id}" href="#${id}" name="${id}" class="header-link">${text}</a>
|
||||||
|
</h${level}>`;
|
||||||
|
};
|
||||||
|
|
||||||
|
return marked.parser(ast, {
|
||||||
|
highlight(code, lang) {
|
||||||
|
return hljs.highlight(lang ? lang : 'rust', code).value;
|
||||||
|
},
|
||||||
|
headerIds: true,
|
||||||
|
headerPrefix: '',
|
||||||
|
renderer,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function() {
|
created: async function() {
|
||||||
const res = await axios.get(ConfigurationMdUrl);
|
let tags;
|
||||||
const {
|
try {
|
||||||
about,
|
tags = (await axios.get(RusfmtTagsUrl)).data;
|
||||||
configurationAbout,
|
} catch(e) {
|
||||||
configurationDescriptions
|
this.handleReqFailure(e);
|
||||||
} = parseMarkdownAst(res.data);
|
return;
|
||||||
this.aboutHtml = marked.parser(about);
|
}
|
||||||
this.configurationAboutHtml = marked.parser(configurationAbout);
|
|
||||||
this.configurationDescriptions = configurationDescriptions;
|
const excludedTagVersions = new Set(['v0.7', 'v0.8.1']);
|
||||||
|
|
||||||
|
const tagOptions = tags
|
||||||
|
.map(tag => tag.name)
|
||||||
|
.filter(tag => tag.startsWith('v') && !excludedTagVersions.has(tag));
|
||||||
|
this.versionOptions = this.versionOptions.concat(tagOptions);
|
||||||
},
|
},
|
||||||
mounted() {
|
updated() {
|
||||||
if (UrlHash === '') return;
|
if (UrlHash === '') return;
|
||||||
const interval = setInterval(() => {
|
this.$nextTick(() => {
|
||||||
const target = document.querySelector(`#${UrlHash}`);
|
const target = document.querySelector(`#${UrlHash}`);
|
||||||
if (target != null) {
|
if (target != null && !this.scrolledOnce) {
|
||||||
target.scrollIntoView(true);
|
target.scrollIntoView(true);
|
||||||
clearInterval(interval);
|
this.scrolledOnce = true;
|
||||||
}
|
}
|
||||||
}, 100);
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleReqFailure(e) {
|
||||||
|
if (e.response.status === 404) {
|
||||||
|
this.aboutHtml =
|
||||||
|
"<p>Failed to get configuration options for this version, please select the version from the dropdown above.</p>";
|
||||||
|
} else if (
|
||||||
|
e.response.status === 403 &&
|
||||||
|
e.response.headers["X-RateLimit-Remaining"] === 0
|
||||||
|
) {
|
||||||
|
const resetDate = new Date(
|
||||||
|
e.response.headers['X-RateLimit-Reset'] * 1000
|
||||||
|
).toLocaleString();
|
||||||
|
this.aboutHtml =
|
||||||
|
`<p>You have hit the GitHub API rate limit; documentation cannot be updated.` +
|
||||||
|
`<p>The rate limit will be reset at ${resetDate}.</p>`;
|
||||||
|
} else {
|
||||||
|
this.aboutHtml =
|
||||||
|
`<p>Ecountered an error when fetching documentation data:</p>` +
|
||||||
|
`<pre><code>${e.response.data}</code></pre>` +
|
||||||
|
`<p>We would appreciate <a href="https://github.com/rust-lang/rustfmt/issues/new?template=bug_report.md">a bug report</a>.` +
|
||||||
|
`<p>Try refreshing the page.</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const extractDepthOnes = (ast) => {
|
const extractDepthOnes = (ast) => {
|
||||||
@ -155,7 +268,9 @@
|
|||||||
head: val[0].text,
|
head: val[0].text,
|
||||||
value: val,
|
value: val,
|
||||||
stable: val.some((elem) => {
|
stable: val.some((elem) => {
|
||||||
return !!elem.text && elem.text.includes("**Stable**: Yes")
|
return elem.type === "list" &&
|
||||||
|
!!elem.raw &&
|
||||||
|
elem.raw.includes("**Stable**: Yes");
|
||||||
}),
|
}),
|
||||||
text: val.reduce((result, next) => {
|
text: val.reduce((result, next) => {
|
||||||
return next.text != null
|
return next.text != null
|
||||||
@ -186,6 +301,11 @@
|
|||||||
configurationDescriptions
|
configurationDescriptions
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function htmlToId(text) {
|
||||||
|
const tmpl = document.createElement('template');
|
||||||
|
tmpl.innerHTML = text.trim();
|
||||||
|
return encodeURIComponent(CSS.escape(tmpl.content.textContent));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2021-07-23"
|
channel = "nightly-2021-10-20"
|
||||||
components = ["rustc-dev"]
|
components = ["rustc-dev"]
|
||||||
|
@ -13,6 +13,7 @@ use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting,
|
|||||||
use crate::overflow;
|
use crate::overflow;
|
||||||
use crate::rewrite::{Rewrite, RewriteContext};
|
use crate::rewrite::{Rewrite, RewriteContext};
|
||||||
use crate::shape::Shape;
|
use crate::shape::Shape;
|
||||||
|
use crate::source_map::SpanUtils;
|
||||||
use crate::types::{rewrite_path, PathContext};
|
use crate::types::{rewrite_path, PathContext};
|
||||||
use crate::utils::{count_newlines, mk_sp};
|
use crate::utils::{count_newlines, mk_sp};
|
||||||
|
|
||||||
@ -116,7 +117,9 @@ fn format_derive(
|
|||||||
|span| span.lo(),
|
|span| span.lo(),
|
||||||
|span| span.hi(),
|
|span| span.hi(),
|
||||||
|span| Some(context.snippet(*span).to_owned()),
|
|span| Some(context.snippet(*span).to_owned()),
|
||||||
attr.span.lo(),
|
// We update derive attribute spans to start after the opening '('
|
||||||
|
// This helps us focus parsing to just what's inside #[derive(...)]
|
||||||
|
context.snippet_provider.span_after(attr.span, "("),
|
||||||
attr.span.hi(),
|
attr.span.hi(),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -121,7 +121,7 @@ fn make_opts() -> Options {
|
|||||||
found reverts to the input file path",
|
found reverts to the input file path",
|
||||||
"[Path for the configuration file]",
|
"[Path for the configuration file]",
|
||||||
);
|
);
|
||||||
opts.optopt("", "edition", "Rust edition to use", "[2015|2018]");
|
opts.optopt("", "edition", "Rust edition to use", "[2015|2018|2021]");
|
||||||
opts.optopt(
|
opts.optopt(
|
||||||
"",
|
"",
|
||||||
"color",
|
"color",
|
||||||
|
@ -17,6 +17,10 @@ use std::str;
|
|||||||
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
#[path = "test/mod.rs"]
|
||||||
|
#[cfg(test)]
|
||||||
|
mod cargo_fmt_tests;
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(StructOpt, Debug)]
|
||||||
#[structopt(
|
#[structopt(
|
||||||
bin_name = "cargo fmt",
|
bin_name = "cargo fmt",
|
||||||
@ -36,7 +40,7 @@ pub struct Opts {
|
|||||||
#[structopt(long = "version")]
|
#[structopt(long = "version")]
|
||||||
version: bool,
|
version: bool,
|
||||||
|
|
||||||
/// Specify package to format (only usable in workspaces)
|
/// Specify package to format
|
||||||
#[structopt(short = "p", long = "package", value_name = "package")]
|
#[structopt(short = "p", long = "package", value_name = "package")]
|
||||||
packages: Vec<String>,
|
packages: Vec<String>,
|
||||||
|
|
||||||
@ -53,9 +57,13 @@ pub struct Opts {
|
|||||||
#[structopt(name = "rustfmt_options", raw(true))]
|
#[structopt(name = "rustfmt_options", raw(true))]
|
||||||
rustfmt_options: Vec<String>,
|
rustfmt_options: Vec<String>,
|
||||||
|
|
||||||
/// Format all packages (only usable in workspaces)
|
/// Format all packages, and also their local path-based dependencies
|
||||||
#[structopt(long = "all")]
|
#[structopt(long = "all")]
|
||||||
format_all: bool,
|
format_all: bool,
|
||||||
|
|
||||||
|
/// Run rustfmt in check mode
|
||||||
|
#[structopt(long = "check")]
|
||||||
|
check: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -104,6 +112,12 @@ fn execute() -> i32 {
|
|||||||
|
|
||||||
let strategy = CargoFmtStrategy::from_opts(&opts);
|
let strategy = CargoFmtStrategy::from_opts(&opts);
|
||||||
let mut rustfmt_args = opts.rustfmt_options;
|
let mut rustfmt_args = opts.rustfmt_options;
|
||||||
|
if opts.check {
|
||||||
|
let check_flag = "--check";
|
||||||
|
if !rustfmt_args.iter().any(|o| o == check_flag) {
|
||||||
|
rustfmt_args.push(check_flag.to_owned());
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(message_format) = opts.message_format {
|
if let Some(message_format) = opts.message_format {
|
||||||
if let Err(msg) = convert_message_format_to_rustfmt_args(&message_format, &mut rustfmt_args)
|
if let Err(msg) = convert_message_format_to_rustfmt_args(&message_format, &mut rustfmt_args)
|
||||||
{
|
{
|
||||||
@ -346,7 +360,7 @@ fn get_targets_root_only(
|
|||||||
manifest_path: Option<&Path>,
|
manifest_path: Option<&Path>,
|
||||||
targets: &mut BTreeSet<Target>,
|
targets: &mut BTreeSet<Target>,
|
||||||
) -> Result<(), io::Error> {
|
) -> Result<(), io::Error> {
|
||||||
let metadata = get_cargo_metadata(manifest_path, false)?;
|
let metadata = get_cargo_metadata(manifest_path)?;
|
||||||
let workspace_root_path = PathBuf::from(&metadata.workspace_root).canonicalize()?;
|
let workspace_root_path = PathBuf::from(&metadata.workspace_root).canonicalize()?;
|
||||||
let (in_workspace_root, current_dir_manifest) = if let Some(target_manifest) = manifest_path {
|
let (in_workspace_root, current_dir_manifest) = if let Some(target_manifest) = manifest_path {
|
||||||
(
|
(
|
||||||
@ -390,34 +404,29 @@ fn get_targets_recursive(
|
|||||||
mut targets: &mut BTreeSet<Target>,
|
mut targets: &mut BTreeSet<Target>,
|
||||||
visited: &mut BTreeSet<String>,
|
visited: &mut BTreeSet<String>,
|
||||||
) -> Result<(), io::Error> {
|
) -> Result<(), io::Error> {
|
||||||
let metadata = get_cargo_metadata(manifest_path, false)?;
|
let metadata = get_cargo_metadata(manifest_path)?;
|
||||||
let metadata_with_deps = get_cargo_metadata(manifest_path, true)?;
|
for package in &metadata.packages {
|
||||||
|
|
||||||
for package in metadata.packages {
|
|
||||||
add_targets(&package.targets, &mut targets);
|
add_targets(&package.targets, &mut targets);
|
||||||
|
|
||||||
// Look for local dependencies.
|
// Look for local dependencies using information available since cargo v1.51
|
||||||
for dependency in package.dependencies {
|
// It's theoretically possible someone could use a newer version of rustfmt with
|
||||||
if dependency.source.is_some() || visited.contains(&dependency.name) {
|
// a much older version of `cargo`, but we don't try to explicitly support that scenario.
|
||||||
|
// If someone reports an issue with path-based deps not being formatted, be sure to
|
||||||
|
// confirm their version of `cargo` (not `cargo-fmt`) is >= v1.51
|
||||||
|
// https://github.com/rust-lang/cargo/pull/8994
|
||||||
|
for dependency in &package.dependencies {
|
||||||
|
if dependency.path.is_none() || visited.contains(&dependency.name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dependency_package = metadata_with_deps
|
let manifest_path = PathBuf::from(dependency.path.as_ref().unwrap()).join("Cargo.toml");
|
||||||
.packages
|
if manifest_path.exists()
|
||||||
.iter()
|
&& !metadata
|
||||||
.find(|p| p.name == dependency.name && p.source.is_none());
|
.packages
|
||||||
let manifest_path = if let Some(dep_pkg) = dependency_package {
|
.iter()
|
||||||
PathBuf::from(&dep_pkg.manifest_path)
|
.any(|p| p.manifest_path.eq(&manifest_path))
|
||||||
} else {
|
{
|
||||||
let mut package_manifest_path = PathBuf::from(&package.manifest_path);
|
visited.insert(dependency.name.to_owned());
|
||||||
package_manifest_path.pop();
|
|
||||||
package_manifest_path.push(&dependency.name);
|
|
||||||
package_manifest_path.push("Cargo.toml");
|
|
||||||
package_manifest_path
|
|
||||||
};
|
|
||||||
|
|
||||||
if manifest_path.exists() {
|
|
||||||
visited.insert(dependency.name);
|
|
||||||
get_targets_recursive(Some(&manifest_path), &mut targets, visited)?;
|
get_targets_recursive(Some(&manifest_path), &mut targets, visited)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,8 +440,7 @@ fn get_targets_with_hitlist(
|
|||||||
hitlist: &[String],
|
hitlist: &[String],
|
||||||
targets: &mut BTreeSet<Target>,
|
targets: &mut BTreeSet<Target>,
|
||||||
) -> Result<(), io::Error> {
|
) -> Result<(), io::Error> {
|
||||||
let metadata = get_cargo_metadata(manifest_path, false)?;
|
let metadata = get_cargo_metadata(manifest_path)?;
|
||||||
|
|
||||||
let mut workspace_hitlist: BTreeSet<&String> = BTreeSet::from_iter(hitlist);
|
let mut workspace_hitlist: BTreeSet<&String> = BTreeSet::from_iter(hitlist);
|
||||||
|
|
||||||
for package in metadata.packages {
|
for package in metadata.packages {
|
||||||
@ -517,18 +525,13 @@ fn run_rustfmt(
|
|||||||
.unwrap_or(SUCCESS))
|
.unwrap_or(SUCCESS))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cargo_metadata(
|
fn get_cargo_metadata(manifest_path: Option<&Path>) -> Result<cargo_metadata::Metadata, io::Error> {
|
||||||
manifest_path: Option<&Path>,
|
|
||||||
include_deps: bool,
|
|
||||||
) -> Result<cargo_metadata::Metadata, io::Error> {
|
|
||||||
let mut cmd = cargo_metadata::MetadataCommand::new();
|
let mut cmd = cargo_metadata::MetadataCommand::new();
|
||||||
if !include_deps {
|
cmd.no_deps();
|
||||||
cmd.no_deps();
|
|
||||||
}
|
|
||||||
if let Some(manifest_path) = manifest_path {
|
if let Some(manifest_path) = manifest_path {
|
||||||
cmd.manifest_path(manifest_path);
|
cmd.manifest_path(manifest_path);
|
||||||
}
|
}
|
||||||
cmd.other_options(&[String::from("--offline")]);
|
cmd.other_options(vec![String::from("--offline")]);
|
||||||
|
|
||||||
match cmd.exec() {
|
match cmd.exec() {
|
||||||
Ok(metadata) => Ok(metadata),
|
Ok(metadata) => Ok(metadata),
|
||||||
@ -541,221 +544,3 @@ fn get_cargo_metadata(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod cargo_fmt_tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn default_options() {
|
|
||||||
let empty: Vec<String> = vec![];
|
|
||||||
let o = Opts::from_iter(&empty);
|
|
||||||
assert_eq!(false, o.quiet);
|
|
||||||
assert_eq!(false, o.verbose);
|
|
||||||
assert_eq!(false, o.version);
|
|
||||||
assert_eq!(empty, o.packages);
|
|
||||||
assert_eq!(empty, o.rustfmt_options);
|
|
||||||
assert_eq!(false, o.format_all);
|
|
||||||
assert_eq!(None, o.manifest_path);
|
|
||||||
assert_eq!(None, o.message_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn good_options() {
|
|
||||||
let o = Opts::from_iter(&[
|
|
||||||
"test",
|
|
||||||
"-q",
|
|
||||||
"-p",
|
|
||||||
"p1",
|
|
||||||
"-p",
|
|
||||||
"p2",
|
|
||||||
"--message-format",
|
|
||||||
"short",
|
|
||||||
"--",
|
|
||||||
"--edition",
|
|
||||||
"2018",
|
|
||||||
]);
|
|
||||||
assert_eq!(true, o.quiet);
|
|
||||||
assert_eq!(false, o.verbose);
|
|
||||||
assert_eq!(false, o.version);
|
|
||||||
assert_eq!(vec!["p1", "p2"], o.packages);
|
|
||||||
assert_eq!(vec!["--edition", "2018"], o.rustfmt_options);
|
|
||||||
assert_eq!(false, o.format_all);
|
|
||||||
assert_eq!(Some(String::from("short")), o.message_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn unexpected_option() {
|
|
||||||
assert!(
|
|
||||||
Opts::clap()
|
|
||||||
.get_matches_from_safe(&["test", "unexpected"])
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn unexpected_flag() {
|
|
||||||
assert!(
|
|
||||||
Opts::clap()
|
|
||||||
.get_matches_from_safe(&["test", "--flag"])
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn mandatory_separator() {
|
|
||||||
assert!(
|
|
||||||
Opts::clap()
|
|
||||||
.get_matches_from_safe(&["test", "--check"])
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
!Opts::clap()
|
|
||||||
.get_matches_from_safe(&["test", "--", "--check"])
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn multiple_packages_one_by_one() {
|
|
||||||
let o = Opts::from_iter(&[
|
|
||||||
"test",
|
|
||||||
"-p",
|
|
||||||
"package1",
|
|
||||||
"--package",
|
|
||||||
"package2",
|
|
||||||
"-p",
|
|
||||||
"package3",
|
|
||||||
]);
|
|
||||||
assert_eq!(3, o.packages.len());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn multiple_packages_grouped() {
|
|
||||||
let o = Opts::from_iter(&[
|
|
||||||
"test",
|
|
||||||
"--package",
|
|
||||||
"package1",
|
|
||||||
"package2",
|
|
||||||
"-p",
|
|
||||||
"package3",
|
|
||||||
"package4",
|
|
||||||
]);
|
|
||||||
assert_eq!(4, o.packages.len());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn empty_packages_1() {
|
|
||||||
assert!(Opts::clap().get_matches_from_safe(&["test", "-p"]).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn empty_packages_2() {
|
|
||||||
assert!(
|
|
||||||
Opts::clap()
|
|
||||||
.get_matches_from_safe(&["test", "-p", "--", "--check"])
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn empty_packages_3() {
|
|
||||||
assert!(
|
|
||||||
Opts::clap()
|
|
||||||
.get_matches_from_safe(&["test", "-p", "--verbose"])
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn empty_packages_4() {
|
|
||||||
assert!(
|
|
||||||
Opts::clap()
|
|
||||||
.get_matches_from_safe(&["test", "-p", "--check"])
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
mod convert_message_format_to_rustfmt_args_tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn invalid_message_format() {
|
|
||||||
assert_eq!(
|
|
||||||
convert_message_format_to_rustfmt_args("awesome", &mut vec![]),
|
|
||||||
Err(String::from(
|
|
||||||
"invalid --message-format value: awesome. Allowed values are: short|json|human"
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn json_message_format_and_check_arg() {
|
|
||||||
let mut args = vec![String::from("--check")];
|
|
||||||
assert_eq!(
|
|
||||||
convert_message_format_to_rustfmt_args("json", &mut args),
|
|
||||||
Err(String::from(
|
|
||||||
"cannot include --check arg when --message-format is set to json"
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn json_message_format_and_emit_arg() {
|
|
||||||
let mut args = vec![String::from("--emit"), String::from("checkstyle")];
|
|
||||||
assert_eq!(
|
|
||||||
convert_message_format_to_rustfmt_args("json", &mut args),
|
|
||||||
Err(String::from(
|
|
||||||
"cannot include --emit arg when --message-format is set to json"
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn json_message_format() {
|
|
||||||
let mut args = vec![String::from("--edition"), String::from("2018")];
|
|
||||||
assert!(convert_message_format_to_rustfmt_args("json", &mut args).is_ok());
|
|
||||||
assert_eq!(
|
|
||||||
args,
|
|
||||||
vec![
|
|
||||||
String::from("--edition"),
|
|
||||||
String::from("2018"),
|
|
||||||
String::from("--emit"),
|
|
||||||
String::from("json")
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn human_message_format() {
|
|
||||||
let exp_args = vec![String::from("--emit"), String::from("json")];
|
|
||||||
let mut act_args = exp_args.clone();
|
|
||||||
assert!(convert_message_format_to_rustfmt_args("human", &mut act_args).is_ok());
|
|
||||||
assert_eq!(act_args, exp_args);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn short_message_format() {
|
|
||||||
let mut args = vec![String::from("--check")];
|
|
||||||
assert!(convert_message_format_to_rustfmt_args("short", &mut args).is_ok());
|
|
||||||
assert_eq!(args, vec![String::from("--check"), String::from("-l")]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn short_message_format_included_short_list_files_flag() {
|
|
||||||
let mut args = vec![String::from("--check"), String::from("-l")];
|
|
||||||
assert!(convert_message_format_to_rustfmt_args("short", &mut args).is_ok());
|
|
||||||
assert_eq!(args, vec![String::from("--check"), String::from("-l")]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn short_message_format_included_long_list_files_flag() {
|
|
||||||
let mut args = vec![String::from("--check"), String::from("--files-with-diff")];
|
|
||||||
assert!(convert_message_format_to_rustfmt_args("short", &mut args).is_ok());
|
|
||||||
assert_eq!(
|
|
||||||
args,
|
|
||||||
vec![String::from("--check"), String::from("--files-with-diff")]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
80
src/tools/rustfmt/src/cargo-fmt/test/message_format.rs
Normal file
80
src/tools/rustfmt/src/cargo-fmt/test/message_format.rs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn invalid_message_format() {
|
||||||
|
assert_eq!(
|
||||||
|
convert_message_format_to_rustfmt_args("awesome", &mut vec![]),
|
||||||
|
Err(String::from(
|
||||||
|
"invalid --message-format value: awesome. Allowed values are: short|json|human"
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn json_message_format_and_check_arg() {
|
||||||
|
let mut args = vec![String::from("--check")];
|
||||||
|
assert_eq!(
|
||||||
|
convert_message_format_to_rustfmt_args("json", &mut args),
|
||||||
|
Err(String::from(
|
||||||
|
"cannot include --check arg when --message-format is set to json"
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn json_message_format_and_emit_arg() {
|
||||||
|
let mut args = vec![String::from("--emit"), String::from("checkstyle")];
|
||||||
|
assert_eq!(
|
||||||
|
convert_message_format_to_rustfmt_args("json", &mut args),
|
||||||
|
Err(String::from(
|
||||||
|
"cannot include --emit arg when --message-format is set to json"
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn json_message_format() {
|
||||||
|
let mut args = vec![String::from("--edition"), String::from("2018")];
|
||||||
|
assert!(convert_message_format_to_rustfmt_args("json", &mut args).is_ok());
|
||||||
|
assert_eq!(
|
||||||
|
args,
|
||||||
|
vec![
|
||||||
|
String::from("--edition"),
|
||||||
|
String::from("2018"),
|
||||||
|
String::from("--emit"),
|
||||||
|
String::from("json")
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn human_message_format() {
|
||||||
|
let exp_args = vec![String::from("--emit"), String::from("json")];
|
||||||
|
let mut act_args = exp_args.clone();
|
||||||
|
assert!(convert_message_format_to_rustfmt_args("human", &mut act_args).is_ok());
|
||||||
|
assert_eq!(act_args, exp_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn short_message_format() {
|
||||||
|
let mut args = vec![String::from("--check")];
|
||||||
|
assert!(convert_message_format_to_rustfmt_args("short", &mut args).is_ok());
|
||||||
|
assert_eq!(args, vec![String::from("--check"), String::from("-l")]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn short_message_format_included_short_list_files_flag() {
|
||||||
|
let mut args = vec![String::from("--check"), String::from("-l")];
|
||||||
|
assert!(convert_message_format_to_rustfmt_args("short", &mut args).is_ok());
|
||||||
|
assert_eq!(args, vec![String::from("--check"), String::from("-l")]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn short_message_format_included_long_list_files_flag() {
|
||||||
|
let mut args = vec![String::from("--check"), String::from("--files-with-diff")];
|
||||||
|
assert!(convert_message_format_to_rustfmt_args("short", &mut args).is_ok());
|
||||||
|
assert_eq!(
|
||||||
|
args,
|
||||||
|
vec![String::from("--check"), String::from("--files-with-diff")]
|
||||||
|
);
|
||||||
|
}
|
137
src/tools/rustfmt/src/cargo-fmt/test/mod.rs
Normal file
137
src/tools/rustfmt/src/cargo-fmt/test/mod.rs
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
mod message_format;
|
||||||
|
mod targets;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn default_options() {
|
||||||
|
let empty: Vec<String> = vec![];
|
||||||
|
let o = Opts::from_iter(&empty);
|
||||||
|
assert_eq!(false, o.quiet);
|
||||||
|
assert_eq!(false, o.verbose);
|
||||||
|
assert_eq!(false, o.version);
|
||||||
|
assert_eq!(false, o.check);
|
||||||
|
assert_eq!(empty, o.packages);
|
||||||
|
assert_eq!(empty, o.rustfmt_options);
|
||||||
|
assert_eq!(false, o.format_all);
|
||||||
|
assert_eq!(None, o.manifest_path);
|
||||||
|
assert_eq!(None, o.message_format);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn good_options() {
|
||||||
|
let o = Opts::from_iter(&[
|
||||||
|
"test",
|
||||||
|
"-q",
|
||||||
|
"-p",
|
||||||
|
"p1",
|
||||||
|
"-p",
|
||||||
|
"p2",
|
||||||
|
"--message-format",
|
||||||
|
"short",
|
||||||
|
"--check",
|
||||||
|
"--",
|
||||||
|
"--edition",
|
||||||
|
"2018",
|
||||||
|
]);
|
||||||
|
assert_eq!(true, o.quiet);
|
||||||
|
assert_eq!(false, o.verbose);
|
||||||
|
assert_eq!(false, o.version);
|
||||||
|
assert_eq!(true, o.check);
|
||||||
|
assert_eq!(vec!["p1", "p2"], o.packages);
|
||||||
|
assert_eq!(vec!["--edition", "2018"], o.rustfmt_options);
|
||||||
|
assert_eq!(false, o.format_all);
|
||||||
|
assert_eq!(Some(String::from("short")), o.message_format);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unexpected_option() {
|
||||||
|
assert!(
|
||||||
|
Opts::clap()
|
||||||
|
.get_matches_from_safe(&["test", "unexpected"])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unexpected_flag() {
|
||||||
|
assert!(
|
||||||
|
Opts::clap()
|
||||||
|
.get_matches_from_safe(&["test", "--flag"])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mandatory_separator() {
|
||||||
|
assert!(
|
||||||
|
Opts::clap()
|
||||||
|
.get_matches_from_safe(&["test", "--emit"])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!Opts::clap()
|
||||||
|
.get_matches_from_safe(&["test", "--", "--emit"])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn multiple_packages_one_by_one() {
|
||||||
|
let o = Opts::from_iter(&[
|
||||||
|
"test",
|
||||||
|
"-p",
|
||||||
|
"package1",
|
||||||
|
"--package",
|
||||||
|
"package2",
|
||||||
|
"-p",
|
||||||
|
"package3",
|
||||||
|
]);
|
||||||
|
assert_eq!(3, o.packages.len());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn multiple_packages_grouped() {
|
||||||
|
let o = Opts::from_iter(&[
|
||||||
|
"test",
|
||||||
|
"--package",
|
||||||
|
"package1",
|
||||||
|
"package2",
|
||||||
|
"-p",
|
||||||
|
"package3",
|
||||||
|
"package4",
|
||||||
|
]);
|
||||||
|
assert_eq!(4, o.packages.len());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_packages_1() {
|
||||||
|
assert!(Opts::clap().get_matches_from_safe(&["test", "-p"]).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_packages_2() {
|
||||||
|
assert!(
|
||||||
|
Opts::clap()
|
||||||
|
.get_matches_from_safe(&["test", "-p", "--", "--check"])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_packages_3() {
|
||||||
|
assert!(
|
||||||
|
Opts::clap()
|
||||||
|
.get_matches_from_safe(&["test", "-p", "--verbose"])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_packages_4() {
|
||||||
|
assert!(
|
||||||
|
Opts::clap()
|
||||||
|
.get_matches_from_safe(&["test", "-p", "--check"])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
}
|
134
src/tools/rustfmt/src/cargo-fmt/test/targets.rs
Normal file
134
src/tools/rustfmt/src/cargo-fmt/test/targets.rs
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
struct ExpTarget {
|
||||||
|
path: &'static str,
|
||||||
|
edition: &'static str,
|
||||||
|
kind: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
mod all_targets {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn assert_correct_targets_loaded(
|
||||||
|
manifest_suffix: &str,
|
||||||
|
source_root: &str,
|
||||||
|
exp_targets: &[ExpTarget],
|
||||||
|
exp_num_targets: usize,
|
||||||
|
) {
|
||||||
|
let root_path = Path::new("tests/cargo-fmt/source").join(source_root);
|
||||||
|
let get_path = |exp: &str| PathBuf::from(&root_path).join(exp).canonicalize().unwrap();
|
||||||
|
let manifest_path = Path::new(&root_path).join(manifest_suffix);
|
||||||
|
let targets = get_targets(&CargoFmtStrategy::All, Some(manifest_path.as_path()))
|
||||||
|
.expect("Targets should have been loaded");
|
||||||
|
|
||||||
|
assert_eq!(targets.len(), exp_num_targets);
|
||||||
|
|
||||||
|
for target in exp_targets {
|
||||||
|
assert!(targets.contains(&Target {
|
||||||
|
path: get_path(target.path),
|
||||||
|
edition: target.edition.to_owned(),
|
||||||
|
kind: target.kind.to_owned(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod different_crate_and_dir_names {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn assert_correct_targets_loaded(manifest_suffix: &str) {
|
||||||
|
let exp_targets = vec![
|
||||||
|
ExpTarget {
|
||||||
|
path: "dependency-dir-name/subdep-dir-name/src/lib.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "lib",
|
||||||
|
},
|
||||||
|
ExpTarget {
|
||||||
|
path: "dependency-dir-name/src/lib.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "lib",
|
||||||
|
},
|
||||||
|
ExpTarget {
|
||||||
|
path: "src/main.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "main",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
super::assert_correct_targets_loaded(
|
||||||
|
manifest_suffix,
|
||||||
|
"divergent-crate-dir-names",
|
||||||
|
&exp_targets,
|
||||||
|
3,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn correct_targets_from_root() {
|
||||||
|
assert_correct_targets_loaded("Cargo.toml");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn correct_targets_from_sub_local_dep() {
|
||||||
|
assert_correct_targets_loaded("dependency-dir-name/Cargo.toml");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod workspaces {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn assert_correct_targets_loaded(manifest_suffix: &str) {
|
||||||
|
let exp_targets = vec![
|
||||||
|
ExpTarget {
|
||||||
|
path: "ws/a/src/main.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "bin",
|
||||||
|
},
|
||||||
|
ExpTarget {
|
||||||
|
path: "ws/b/src/main.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "bin",
|
||||||
|
},
|
||||||
|
ExpTarget {
|
||||||
|
path: "ws/c/src/lib.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "lib",
|
||||||
|
},
|
||||||
|
ExpTarget {
|
||||||
|
path: "ws/a/d/src/lib.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "lib",
|
||||||
|
},
|
||||||
|
ExpTarget {
|
||||||
|
path: "e/src/main.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "main",
|
||||||
|
},
|
||||||
|
ExpTarget {
|
||||||
|
path: "ws/a/d/f/src/lib.rs",
|
||||||
|
edition: "2018",
|
||||||
|
kind: "lib",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
super::assert_correct_targets_loaded(
|
||||||
|
manifest_suffix,
|
||||||
|
"workspaces/path-dep-above",
|
||||||
|
&exp_targets,
|
||||||
|
6,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn includes_outside_workspace_deps() {
|
||||||
|
assert_correct_targets_loaded("ws/Cargo.toml");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn includes_workspace_from_dep_above() {
|
||||||
|
assert_correct_targets_loaded("e/Cargo.toml");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn includes_all_packages_from_workspace_subdir() {
|
||||||
|
assert_correct_targets_loaded("ws/a/d/f/Cargo.toml");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,8 @@ use crate::rewrite::RewriteContext;
|
|||||||
use crate::shape::{Indent, Shape};
|
use crate::shape::{Indent, Shape};
|
||||||
use crate::string::{rewrite_string, StringFormat};
|
use crate::string::{rewrite_string, StringFormat};
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
count_newlines, first_line_width, last_line_width, trim_left_preserve_layout, unicode_str_width,
|
count_newlines, first_line_width, last_line_width, trim_left_preserve_layout,
|
||||||
|
trimmed_last_line_width, unicode_str_width,
|
||||||
};
|
};
|
||||||
use crate::{ErrorKind, FormattingError};
|
use crate::{ErrorKind, FormattingError};
|
||||||
|
|
||||||
@ -171,11 +172,12 @@ pub(crate) fn combine_strs_with_missing_comments(
|
|||||||
String::with_capacity(prev_str.len() + next_str.len() + shape.indent.width() + 128);
|
String::with_capacity(prev_str.len() + next_str.len() + shape.indent.width() + 128);
|
||||||
result.push_str(prev_str);
|
result.push_str(prev_str);
|
||||||
let mut allow_one_line = !prev_str.contains('\n') && !next_str.contains('\n');
|
let mut allow_one_line = !prev_str.contains('\n') && !next_str.contains('\n');
|
||||||
let first_sep = if prev_str.is_empty() || next_str.is_empty() {
|
let first_sep =
|
||||||
""
|
if prev_str.is_empty() || next_str.is_empty() || trimmed_last_line_width(prev_str) == 0 {
|
||||||
} else {
|
""
|
||||||
" "
|
} else {
|
||||||
};
|
" "
|
||||||
|
};
|
||||||
let mut one_line_width =
|
let mut one_line_width =
|
||||||
last_line_width(prev_str) + first_line_width(next_str) + first_sep.len();
|
last_line_width(prev_str) + first_line_width(next_str) + first_sep.len();
|
||||||
|
|
||||||
@ -184,7 +186,7 @@ pub(crate) fn combine_strs_with_missing_comments(
|
|||||||
let missing_comment = rewrite_missing_comment(span, shape, context)?;
|
let missing_comment = rewrite_missing_comment(span, shape, context)?;
|
||||||
|
|
||||||
if missing_comment.is_empty() {
|
if missing_comment.is_empty() {
|
||||||
if allow_extend && prev_str.len() + first_sep.len() + next_str.len() <= shape.width {
|
if allow_extend && one_line_width <= shape.width {
|
||||||
result.push_str(first_sep);
|
result.push_str(first_sep);
|
||||||
} else if !prev_str.is_empty() {
|
} else if !prev_str.is_empty() {
|
||||||
result.push_str(&indent.to_string_with_newline(config))
|
result.push_str(&indent.to_string_with_newline(config))
|
||||||
@ -392,28 +394,26 @@ fn identify_comment(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attributes for code blocks in rustdoc.
|
/// Enum indicating if the code block contains rust based on attributes
|
||||||
/// See <https://doc.rust-lang.org/rustdoc/print.html#attributes>.
|
|
||||||
enum CodeBlockAttribute {
|
enum CodeBlockAttribute {
|
||||||
Rust,
|
Rust,
|
||||||
Ignore,
|
NotRust,
|
||||||
Text,
|
|
||||||
ShouldPanic,
|
|
||||||
NoRun,
|
|
||||||
CompileFail,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CodeBlockAttribute {
|
impl CodeBlockAttribute {
|
||||||
fn new(attribute: &str) -> CodeBlockAttribute {
|
/// Parse comma separated attributes list. Return rust only if all
|
||||||
match attribute {
|
/// attributes are valid rust attributes
|
||||||
"rust" | "" => CodeBlockAttribute::Rust,
|
/// See <https://doc.rust-lang.org/rustdoc/print.html#attributes>
|
||||||
"ignore" => CodeBlockAttribute::Ignore,
|
fn new(attributes: &str) -> CodeBlockAttribute {
|
||||||
"text" => CodeBlockAttribute::Text,
|
for attribute in attributes.split(",") {
|
||||||
"should_panic" => CodeBlockAttribute::ShouldPanic,
|
match attribute.trim() {
|
||||||
"no_run" => CodeBlockAttribute::NoRun,
|
"" | "rust" | "should_panic" | "no_run" | "edition2015" | "edition2018"
|
||||||
"compile_fail" => CodeBlockAttribute::CompileFail,
|
| "edition2021" => (),
|
||||||
_ => CodeBlockAttribute::Text,
|
"ignore" | "compile_fail" | "text" => return CodeBlockAttribute::NotRust,
|
||||||
|
_ => return CodeBlockAttribute::NotRust,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
CodeBlockAttribute::Rust
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,25 +647,21 @@ impl<'a> CommentRewrite<'a> {
|
|||||||
} else if self.code_block_attr.is_some() {
|
} else if self.code_block_attr.is_some() {
|
||||||
if line.starts_with("```") {
|
if line.starts_with("```") {
|
||||||
let code_block = match self.code_block_attr.as_ref().unwrap() {
|
let code_block = match self.code_block_attr.as_ref().unwrap() {
|
||||||
CodeBlockAttribute::Ignore | CodeBlockAttribute::Text => {
|
CodeBlockAttribute::Rust
|
||||||
trim_custom_comment_prefix(&self.code_block_buffer)
|
if self.fmt.config.format_code_in_doc_comments()
|
||||||
}
|
&& !self.code_block_buffer.is_empty() =>
|
||||||
_ if self.code_block_buffer.is_empty() => String::new(),
|
{
|
||||||
_ => {
|
|
||||||
let mut config = self.fmt.config.clone();
|
let mut config = self.fmt.config.clone();
|
||||||
config.set().wrap_comments(false);
|
config.set().wrap_comments(false);
|
||||||
if config.format_code_in_doc_comments() {
|
if let Some(s) =
|
||||||
if let Some(s) =
|
crate::format_code_block(&self.code_block_buffer, &config, false)
|
||||||
crate::format_code_block(&self.code_block_buffer, &config, false)
|
{
|
||||||
{
|
trim_custom_comment_prefix(&s.snippet)
|
||||||
trim_custom_comment_prefix(&s.snippet)
|
|
||||||
} else {
|
|
||||||
trim_custom_comment_prefix(&self.code_block_buffer)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
trim_custom_comment_prefix(&self.code_block_buffer)
|
trim_custom_comment_prefix(&self.code_block_buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => trim_custom_comment_prefix(&self.code_block_buffer),
|
||||||
};
|
};
|
||||||
if !code_block.is_empty() {
|
if !code_block.is_empty() {
|
||||||
self.result.push_str(&self.comment_line_separator);
|
self.result.push_str(&self.comment_line_separator);
|
||||||
|
@ -69,6 +69,8 @@ create_config! {
|
|||||||
format_macro_matchers: bool, false, false,
|
format_macro_matchers: bool, false, false,
|
||||||
"Format the metavariable matching patterns in macros";
|
"Format the metavariable matching patterns in macros";
|
||||||
format_macro_bodies: bool, true, false, "Format the bodies of macros";
|
format_macro_bodies: bool, true, false, "Format the bodies of macros";
|
||||||
|
hex_literal_case: HexLiteralCase, HexLiteralCase::Preserve, false,
|
||||||
|
"Format hexadecimal integer literals";
|
||||||
|
|
||||||
// Single line expressions and items
|
// Single line expressions and items
|
||||||
empty_item_single_line: bool, true, false,
|
empty_item_single_line: bool, true, false,
|
||||||
@ -125,7 +127,7 @@ create_config! {
|
|||||||
"Add trailing semicolon after break, continue and return";
|
"Add trailing semicolon after break, continue and return";
|
||||||
trailing_comma: SeparatorTactic, SeparatorTactic::Vertical, false,
|
trailing_comma: SeparatorTactic, SeparatorTactic::Vertical, false,
|
||||||
"How to handle trailing commas for lists";
|
"How to handle trailing commas for lists";
|
||||||
match_block_trailing_comma: bool, false, false,
|
match_block_trailing_comma: bool, false, true,
|
||||||
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
|
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
|
||||||
blank_lines_upper_bound: usize, 1, false,
|
blank_lines_upper_bound: usize, 1, false,
|
||||||
"Maximum number of blank lines which can be put between items";
|
"Maximum number of blank lines which can be put between items";
|
||||||
@ -136,6 +138,7 @@ create_config! {
|
|||||||
inline_attribute_width: usize, 0, false,
|
inline_attribute_width: usize, 0, false,
|
||||||
"Write an item and its attribute on the same line \
|
"Write an item and its attribute on the same line \
|
||||||
if their combined width is below a threshold";
|
if their combined width is below a threshold";
|
||||||
|
format_generated_files: bool, false, false, "Format generated files";
|
||||||
|
|
||||||
// Options that can change the source code beyond whitespace/blocks (somewhat linty things)
|
// Options that can change the source code beyond whitespace/blocks (somewhat linty things)
|
||||||
merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one";
|
merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one";
|
||||||
@ -152,7 +155,7 @@ create_config! {
|
|||||||
"Require a specific version of rustfmt";
|
"Require a specific version of rustfmt";
|
||||||
unstable_features: bool, false, false,
|
unstable_features: bool, false, false,
|
||||||
"Enables unstable features. Only available on nightly channel";
|
"Enables unstable features. Only available on nightly channel";
|
||||||
disable_all_formatting: bool, false, false, "Don't reformat anything";
|
disable_all_formatting: bool, false, true, "Don't reformat anything";
|
||||||
skip_children: bool, false, false, "Don't reformat out of line modules";
|
skip_children: bool, false, false, "Don't reformat out of line modules";
|
||||||
hide_parse_errors: bool, false, false, "Hide errors from the parser";
|
hide_parse_errors: bool, false, false, "Hide errors from the parser";
|
||||||
error_on_line_overflow: bool, false, false, "Error if unable to get all lines within max_width";
|
error_on_line_overflow: bool, false, false, "Error if unable to get all lines within max_width";
|
||||||
@ -569,6 +572,7 @@ license_template_path = ""
|
|||||||
format_strings = false
|
format_strings = false
|
||||||
format_macro_matchers = false
|
format_macro_matchers = false
|
||||||
format_macro_bodies = true
|
format_macro_bodies = true
|
||||||
|
hex_literal_case = "Preserve"
|
||||||
empty_item_single_line = true
|
empty_item_single_line = true
|
||||||
struct_lit_single_line = true
|
struct_lit_single_line = true
|
||||||
fn_single_line = false
|
fn_single_line = false
|
||||||
@ -604,6 +608,7 @@ blank_lines_lower_bound = 0
|
|||||||
edition = "2015"
|
edition = "2015"
|
||||||
version = "One"
|
version = "One"
|
||||||
inline_attribute_width = 0
|
inline_attribute_width = 0
|
||||||
|
format_generated_files = false
|
||||||
merge_derives = true
|
merge_derives = true
|
||||||
use_try_shorthand = false
|
use_try_shorthand = false
|
||||||
use_field_init_shorthand = false
|
use_field_init_shorthand = false
|
||||||
|
@ -125,6 +125,19 @@ pub enum ImportGranularity {
|
|||||||
Module,
|
Module,
|
||||||
/// Use one `use` statement per imported item.
|
/// Use one `use` statement per imported item.
|
||||||
Item,
|
Item,
|
||||||
|
/// Use one `use` statement including all items.
|
||||||
|
One,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Controls how rustfmt should handle case in hexadecimal literals.
|
||||||
|
#[config_type]
|
||||||
|
pub enum HexLiteralCase {
|
||||||
|
/// Leave the literal as-is
|
||||||
|
Preserve,
|
||||||
|
/// Ensure all literals use uppercase lettering
|
||||||
|
Upper,
|
||||||
|
/// Ensure all literals use lowercase lettering
|
||||||
|
Lower,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[config_type]
|
#[config_type]
|
||||||
|
@ -13,7 +13,7 @@ use crate::comment::{
|
|||||||
rewrite_missing_comment, CharClasses, FindUncommented,
|
rewrite_missing_comment, CharClasses, FindUncommented,
|
||||||
};
|
};
|
||||||
use crate::config::lists::*;
|
use crate::config::lists::*;
|
||||||
use crate::config::{Config, ControlBraceStyle, IndentStyle, Version};
|
use crate::config::{Config, ControlBraceStyle, HexLiteralCase, IndentStyle, Version};
|
||||||
use crate::lists::{
|
use crate::lists::{
|
||||||
definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
|
definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
|
||||||
struct_lit_tactic, write_list, ListFormatting, Separator,
|
struct_lit_tactic, write_list, ListFormatting, Separator,
|
||||||
@ -822,7 +822,7 @@ impl<'a> ControlFlow<'a> {
|
|||||||
let pat_string = pat.rewrite(context, pat_shape)?;
|
let pat_string = pat.rewrite(context, pat_shape)?;
|
||||||
let comments_lo = context
|
let comments_lo = context
|
||||||
.snippet_provider
|
.snippet_provider
|
||||||
.span_after(self.span, self.connector.trim());
|
.span_after(self.span.with_lo(pat.span.hi()), self.connector.trim());
|
||||||
let comments_span = mk_sp(comments_lo, expr.span.lo());
|
let comments_span = mk_sp(comments_lo, expr.span.lo());
|
||||||
return rewrite_assign_rhs_with_comments(
|
return rewrite_assign_rhs_with_comments(
|
||||||
context,
|
context,
|
||||||
@ -1168,6 +1168,7 @@ pub(crate) fn rewrite_literal(
|
|||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
match l.kind {
|
match l.kind {
|
||||||
ast::LitKind::Str(_, ast::StrStyle::Cooked) => rewrite_string_lit(context, l.span, shape),
|
ast::LitKind::Str(_, ast::StrStyle::Cooked) => rewrite_string_lit(context, l.span, shape),
|
||||||
|
ast::LitKind::Int(..) => rewrite_int_lit(context, l, shape),
|
||||||
_ => wrap_str(
|
_ => wrap_str(
|
||||||
context.snippet(l.span).to_owned(),
|
context.snippet(l.span).to_owned(),
|
||||||
context.config.max_width(),
|
context.config.max_width(),
|
||||||
@ -1202,6 +1203,36 @@ fn rewrite_string_lit(context: &RewriteContext<'_>, span: Span, shape: Shape) ->
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn rewrite_int_lit(context: &RewriteContext<'_>, lit: &ast::Lit, shape: Shape) -> Option<String> {
|
||||||
|
let span = lit.span;
|
||||||
|
let symbol = lit.token.symbol.as_str();
|
||||||
|
|
||||||
|
if symbol.starts_with("0x") {
|
||||||
|
let hex_lit = match context.config.hex_literal_case() {
|
||||||
|
HexLiteralCase::Preserve => None,
|
||||||
|
HexLiteralCase::Upper => Some(symbol[2..].to_ascii_uppercase()),
|
||||||
|
HexLiteralCase::Lower => Some(symbol[2..].to_ascii_lowercase()),
|
||||||
|
};
|
||||||
|
if let Some(hex_lit) = hex_lit {
|
||||||
|
return wrap_str(
|
||||||
|
format!(
|
||||||
|
"0x{}{}",
|
||||||
|
hex_lit,
|
||||||
|
lit.token.suffix.map_or(String::new(), |s| s.to_string())
|
||||||
|
),
|
||||||
|
context.config.max_width(),
|
||||||
|
shape,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wrap_str(
|
||||||
|
context.snippet(span).to_owned(),
|
||||||
|
context.config.max_width(),
|
||||||
|
shape,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn choose_separator_tactic(context: &RewriteContext<'_>, span: Span) -> Option<SeparatorTactic> {
|
fn choose_separator_tactic(context: &RewriteContext<'_>, span: Span) -> Option<SeparatorTactic> {
|
||||||
if context.inside_macro() {
|
if context.inside_macro() {
|
||||||
if span_ends_with_comma(context, span) {
|
if span_ends_with_comma(context, span) {
|
||||||
@ -1497,12 +1528,12 @@ fn rewrite_struct_lit<'a>(
|
|||||||
let path_shape = shape.sub_width(2)?;
|
let path_shape = shape.sub_width(2)?;
|
||||||
let path_str = rewrite_path(context, PathContext::Expr, None, path, path_shape)?;
|
let path_str = rewrite_path(context, PathContext::Expr, None, path, path_shape)?;
|
||||||
|
|
||||||
let has_base = match struct_rest {
|
let has_base_or_rest = match struct_rest {
|
||||||
ast::StructRest::None if fields.is_empty() => return Some(format!("{} {{}}", path_str)),
|
ast::StructRest::None if fields.is_empty() => return Some(format!("{} {{}}", path_str)),
|
||||||
ast::StructRest::Rest(_) if fields.is_empty() => {
|
ast::StructRest::Rest(_) if fields.is_empty() => {
|
||||||
return Some(format!("{} {{ .. }}", path_str));
|
return Some(format!("{} {{ .. }}", path_str));
|
||||||
}
|
}
|
||||||
ast::StructRest::Base(_) => true,
|
ast::StructRest::Rest(_) | ast::StructRest::Base(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1511,7 +1542,7 @@ fn rewrite_struct_lit<'a>(
|
|||||||
|
|
||||||
let one_line_width = h_shape.map_or(0, |shape| shape.width);
|
let one_line_width = h_shape.map_or(0, |shape| shape.width);
|
||||||
let body_lo = context.snippet_provider.span_after(span, "{");
|
let body_lo = context.snippet_provider.span_after(span, "{");
|
||||||
let fields_str = if struct_lit_can_be_aligned(fields, has_base)
|
let fields_str = if struct_lit_can_be_aligned(fields, has_base_or_rest)
|
||||||
&& context.config.struct_field_align_threshold() > 0
|
&& context.config.struct_field_align_threshold() > 0
|
||||||
{
|
{
|
||||||
rewrite_with_alignment(
|
rewrite_with_alignment(
|
||||||
@ -1583,10 +1614,7 @@ fn rewrite_struct_lit<'a>(
|
|||||||
nested_shape,
|
nested_shape,
|
||||||
tactic,
|
tactic,
|
||||||
context,
|
context,
|
||||||
force_no_trailing_comma
|
force_no_trailing_comma || has_base_or_rest || !context.use_block_indent(),
|
||||||
|| has_base
|
|
||||||
|| !context.use_block_indent()
|
|
||||||
|| matches!(struct_rest, ast::StructRest::Rest(_)),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
write_list(&item_vec, &fmt)?
|
write_list(&item_vec, &fmt)?
|
||||||
|
@ -10,6 +10,7 @@ use rustc_span::Span;
|
|||||||
use self::newline_style::apply_newline_style;
|
use self::newline_style::apply_newline_style;
|
||||||
use crate::comment::{CharClasses, FullCodeCharKind};
|
use crate::comment::{CharClasses, FullCodeCharKind};
|
||||||
use crate::config::{Config, FileName, Verbosity};
|
use crate::config::{Config, FileName, Verbosity};
|
||||||
|
use crate::formatting::generated::is_generated_file;
|
||||||
use crate::issues::BadIssueSeeker;
|
use crate::issues::BadIssueSeeker;
|
||||||
use crate::modules::Module;
|
use crate::modules::Module;
|
||||||
use crate::syntux::parser::{DirectoryOwnership, Parser, ParserError};
|
use crate::syntux::parser::{DirectoryOwnership, Parser, ParserError};
|
||||||
@ -18,6 +19,7 @@ use crate::utils::count_newlines;
|
|||||||
use crate::visitor::FmtVisitor;
|
use crate::visitor::FmtVisitor;
|
||||||
use crate::{modules, source_file, ErrorKind, FormatReport, Input, Session};
|
use crate::{modules, source_file, ErrorKind, FormatReport, Input, Session};
|
||||||
|
|
||||||
|
mod generated;
|
||||||
mod newline_style;
|
mod newline_style;
|
||||||
|
|
||||||
// A map of the files of a crate, with their new content
|
// A map of the files of a crate, with their new content
|
||||||
@ -103,7 +105,12 @@ fn format_project<T: FormatHandler>(
|
|||||||
context.parse_session.set_silent_emitter();
|
context.parse_session.set_silent_emitter();
|
||||||
|
|
||||||
for (path, module) in files {
|
for (path, module) in files {
|
||||||
let should_ignore = !input_is_stdin && context.ignore_file(&path);
|
let source_file = context.parse_session.span_to_file_contents(module.span);
|
||||||
|
let src = source_file.src.as_ref().expect("SourceFile without src");
|
||||||
|
|
||||||
|
let should_ignore = (!input_is_stdin && context.ignore_file(&path))
|
||||||
|
|| (!config.format_generated_files() && is_generated_file(src));
|
||||||
|
|
||||||
if (config.skip_children() && path != main_file) || should_ignore {
|
if (config.skip_children() && path != main_file) || should_ignore {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
7
src/tools/rustfmt/src/formatting/generated.rs
Normal file
7
src/tools/rustfmt/src/formatting/generated.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/// Returns `true` if the given span is a part of generated files.
|
||||||
|
pub(super) fn is_generated_file(original_snippet: &str) -> bool {
|
||||||
|
original_snippet
|
||||||
|
.lines()
|
||||||
|
.take(5) // looking for marker only in the beginning of the file
|
||||||
|
.any(|line| line.contains("@generated"))
|
||||||
|
}
|
@ -138,6 +138,29 @@ impl UseSegment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if self == other with their aliases removed.
|
||||||
|
fn equal_except_alias(&self, other: &Self) -> bool {
|
||||||
|
match (self, other) {
|
||||||
|
(UseSegment::Ident(ref s1, _), UseSegment::Ident(ref s2, _)) => s1 == s2,
|
||||||
|
(UseSegment::Slf(_), UseSegment::Slf(_))
|
||||||
|
| (UseSegment::Super(_), UseSegment::Super(_))
|
||||||
|
| (UseSegment::Crate(_), UseSegment::Crate(_))
|
||||||
|
| (UseSegment::Glob, UseSegment::Glob) => true,
|
||||||
|
(UseSegment::List(ref list1), UseSegment::List(ref list2)) => list1 == list2,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_alias(&self) -> Option<&str> {
|
||||||
|
match self {
|
||||||
|
UseSegment::Ident(_, a)
|
||||||
|
| UseSegment::Slf(a)
|
||||||
|
| UseSegment::Super(a)
|
||||||
|
| UseSegment::Crate(a) => a.as_deref(),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn from_path_segment(
|
fn from_path_segment(
|
||||||
context: &RewriteContext<'_>,
|
context: &RewriteContext<'_>,
|
||||||
path_seg: &ast::PathSegment,
|
path_seg: &ast::PathSegment,
|
||||||
@ -558,6 +581,7 @@ impl UseTree {
|
|||||||
SharedPrefix::Module => {
|
SharedPrefix::Module => {
|
||||||
self.path[..self.path.len() - 1] == other.path[..other.path.len() - 1]
|
self.path[..self.path.len() - 1] == other.path[..other.path.len() - 1]
|
||||||
}
|
}
|
||||||
|
SharedPrefix::One => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -598,7 +622,7 @@ impl UseTree {
|
|||||||
fn merge(&mut self, other: &UseTree, merge_by: SharedPrefix) {
|
fn merge(&mut self, other: &UseTree, merge_by: SharedPrefix) {
|
||||||
let mut prefix = 0;
|
let mut prefix = 0;
|
||||||
for (a, b) in self.path.iter().zip(other.path.iter()) {
|
for (a, b) in self.path.iter().zip(other.path.iter()) {
|
||||||
if *a == *b {
|
if a.equal_except_alias(b) {
|
||||||
prefix += 1;
|
prefix += 1;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -633,14 +657,20 @@ fn merge_rest(
|
|||||||
return Some(new_path);
|
return Some(new_path);
|
||||||
}
|
}
|
||||||
} else if len == 1 {
|
} else if len == 1 {
|
||||||
let rest = if a.len() == len { &b[1..] } else { &a[1..] };
|
let (common, rest) = if a.len() == len {
|
||||||
return Some(vec![
|
(&a[0], &b[1..])
|
||||||
b[0].clone(),
|
} else {
|
||||||
UseSegment::List(vec![
|
(&b[0], &a[1..])
|
||||||
UseTree::from_path(vec![UseSegment::Slf(None)], DUMMY_SP),
|
};
|
||||||
UseTree::from_path(rest.to_vec(), DUMMY_SP),
|
let mut list = vec![UseTree::from_path(
|
||||||
]),
|
vec![UseSegment::Slf(common.get_alias().map(ToString::to_string))],
|
||||||
]);
|
DUMMY_SP,
|
||||||
|
)];
|
||||||
|
match rest {
|
||||||
|
[UseSegment::List(rest_list)] => list.extend(rest_list.clone()),
|
||||||
|
_ => list.push(UseTree::from_path(rest.to_vec(), DUMMY_SP)),
|
||||||
|
}
|
||||||
|
return Some(vec![b[0].clone(), UseSegment::List(list)]);
|
||||||
} else {
|
} else {
|
||||||
len -= 1;
|
len -= 1;
|
||||||
}
|
}
|
||||||
@ -655,18 +685,54 @@ fn merge_rest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn merge_use_trees_inner(trees: &mut Vec<UseTree>, use_tree: UseTree, merge_by: SharedPrefix) {
|
fn merge_use_trees_inner(trees: &mut Vec<UseTree>, use_tree: UseTree, merge_by: SharedPrefix) {
|
||||||
let similar_trees = trees
|
struct SimilarTree<'a> {
|
||||||
.iter_mut()
|
similarity: usize,
|
||||||
.filter(|tree| tree.share_prefix(&use_tree, merge_by));
|
path_len: usize,
|
||||||
|
tree: &'a mut UseTree,
|
||||||
|
}
|
||||||
|
|
||||||
|
let similar_trees = trees.iter_mut().filter_map(|tree| {
|
||||||
|
if tree.share_prefix(&use_tree, merge_by) {
|
||||||
|
// In the case of `SharedPrefix::One`, `similarity` is used for deciding with which
|
||||||
|
// tree `use_tree` should be merge.
|
||||||
|
// In other cases `similarity` won't be used, so set it to `0` as a dummy value.
|
||||||
|
let similarity = if merge_by == SharedPrefix::One {
|
||||||
|
tree.path
|
||||||
|
.iter()
|
||||||
|
.zip(&use_tree.path)
|
||||||
|
.take_while(|(a, b)| a.equal_except_alias(b))
|
||||||
|
.count()
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
let path_len = tree.path.len();
|
||||||
|
Some(SimilarTree {
|
||||||
|
similarity,
|
||||||
|
tree,
|
||||||
|
path_len,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if use_tree.path.len() == 1 && merge_by == SharedPrefix::Crate {
|
if use_tree.path.len() == 1 && merge_by == SharedPrefix::Crate {
|
||||||
if let Some(tree) = similar_trees.min_by_key(|tree| tree.path.len()) {
|
if let Some(tree) = similar_trees.min_by_key(|tree| tree.path_len) {
|
||||||
if tree.path.len() == 1 {
|
if tree.path_len == 1 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(tree) = similar_trees.max_by_key(|tree| tree.path.len()) {
|
} else if merge_by == SharedPrefix::One {
|
||||||
if tree.path.len() > 1 {
|
if let Some(sim_tree) = similar_trees.max_by_key(|tree| tree.similarity) {
|
||||||
tree.merge(&use_tree, merge_by);
|
if sim_tree.similarity > 0 {
|
||||||
|
sim_tree.tree.merge(&use_tree, merge_by);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if let Some(sim_tree) = similar_trees.max_by_key(|tree| tree.path_len) {
|
||||||
|
if sim_tree.path_len > 1 {
|
||||||
|
sim_tree.tree.merge(&use_tree, merge_by);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -880,6 +946,7 @@ impl Rewrite for UseTree {
|
|||||||
pub(crate) enum SharedPrefix {
|
pub(crate) enum SharedPrefix {
|
||||||
Crate,
|
Crate,
|
||||||
Module,
|
Module,
|
||||||
|
One,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -904,7 +971,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn eat(&mut self, c: char) {
|
fn eat(&mut self, c: char) {
|
||||||
assert!(self.input.next().unwrap() == c);
|
assert_eq!(self.input.next().unwrap(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_segment(
|
fn push_segment(
|
||||||
@ -1094,6 +1161,49 @@ mod test {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_use_tree_merge_one() {
|
||||||
|
test_merge!(One, ["a", "b"], ["{a, b}"]);
|
||||||
|
|
||||||
|
test_merge!(One, ["a::{aa, ab}", "b", "a"], ["{a::{self, aa, ab}, b}"]);
|
||||||
|
|
||||||
|
test_merge!(One, ["a as x", "b as y"], ["{a as x, b as y}"]);
|
||||||
|
|
||||||
|
test_merge!(
|
||||||
|
One,
|
||||||
|
["a::{aa as xa, ab}", "b", "a"],
|
||||||
|
["{a::{self, aa as xa, ab}, b}"]
|
||||||
|
);
|
||||||
|
|
||||||
|
test_merge!(
|
||||||
|
One,
|
||||||
|
["a", "a::{aa, ab::{aba, abb}}"],
|
||||||
|
["a::{self, aa, ab::{aba, abb}}"]
|
||||||
|
);
|
||||||
|
|
||||||
|
test_merge!(One, ["a", "b::{ba, *}"], ["{a, b::{ba, *}}"]);
|
||||||
|
|
||||||
|
test_merge!(One, ["a", "b", "a::aa"], ["{a::{self, aa}, b}"]);
|
||||||
|
|
||||||
|
test_merge!(
|
||||||
|
One,
|
||||||
|
["a::aa::aaa", "a::ac::aca", "a::aa::*"],
|
||||||
|
["a::{aa::{aaa, *}, ac::aca}"]
|
||||||
|
);
|
||||||
|
|
||||||
|
test_merge!(
|
||||||
|
One,
|
||||||
|
["a", "b::{ba, bb}", "a::{aa::*, ab::aba}"],
|
||||||
|
["{a::{self, aa::*, ab::aba}, b::{ba, bb}}"]
|
||||||
|
);
|
||||||
|
|
||||||
|
test_merge!(
|
||||||
|
One,
|
||||||
|
["b", "a::ac::{aca, acb}", "a::{aa::*, ab}"],
|
||||||
|
["{a::{aa::*, ab, ac::{aca, acb}}, b}"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_flatten_use_trees() {
|
fn test_flatten_use_trees() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -174,14 +174,14 @@ pub(crate) struct FnSig<'a> {
|
|||||||
constness: ast::Const,
|
constness: ast::Const,
|
||||||
defaultness: ast::Defaultness,
|
defaultness: ast::Defaultness,
|
||||||
unsafety: ast::Unsafe,
|
unsafety: ast::Unsafe,
|
||||||
visibility: ast::Visibility,
|
visibility: &'a ast::Visibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FnSig<'a> {
|
impl<'a> FnSig<'a> {
|
||||||
pub(crate) fn from_method_sig(
|
pub(crate) fn from_method_sig(
|
||||||
method_sig: &'a ast::FnSig,
|
method_sig: &'a ast::FnSig,
|
||||||
generics: &'a ast::Generics,
|
generics: &'a ast::Generics,
|
||||||
visibility: ast::Visibility,
|
visibility: &'a ast::Visibility,
|
||||||
) -> FnSig<'a> {
|
) -> FnSig<'a> {
|
||||||
FnSig {
|
FnSig {
|
||||||
unsafety: method_sig.header.unsafety,
|
unsafety: method_sig.header.unsafety,
|
||||||
@ -204,7 +204,7 @@ impl<'a> FnSig<'a> {
|
|||||||
match *fn_kind {
|
match *fn_kind {
|
||||||
visit::FnKind::Fn(fn_ctxt, _, fn_sig, vis, _) => match fn_ctxt {
|
visit::FnKind::Fn(fn_ctxt, _, fn_sig, vis, _) => match fn_ctxt {
|
||||||
visit::FnCtxt::Assoc(..) => {
|
visit::FnCtxt::Assoc(..) => {
|
||||||
let mut fn_sig = FnSig::from_method_sig(fn_sig, generics, vis.clone());
|
let mut fn_sig = FnSig::from_method_sig(fn_sig, generics, vis);
|
||||||
fn_sig.defaultness = defaultness;
|
fn_sig.defaultness = defaultness;
|
||||||
fn_sig
|
fn_sig
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ impl<'a> FnSig<'a> {
|
|||||||
is_async: Cow::Borrowed(&fn_sig.header.asyncness),
|
is_async: Cow::Borrowed(&fn_sig.header.asyncness),
|
||||||
defaultness,
|
defaultness,
|
||||||
unsafety: fn_sig.header.unsafety,
|
unsafety: fn_sig.header.unsafety,
|
||||||
visibility: vis.clone(),
|
visibility: vis,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
@ -323,6 +323,7 @@ impl<'a> FmtVisitor<'a> {
|
|||||||
indent: Indent,
|
indent: Indent,
|
||||||
ident: symbol::Ident,
|
ident: symbol::Ident,
|
||||||
sig: &ast::FnSig,
|
sig: &ast::FnSig,
|
||||||
|
vis: &ast::Visibility,
|
||||||
generics: &ast::Generics,
|
generics: &ast::Generics,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
@ -334,7 +335,7 @@ impl<'a> FmtVisitor<'a> {
|
|||||||
&context,
|
&context,
|
||||||
indent,
|
indent,
|
||||||
ident,
|
ident,
|
||||||
&FnSig::from_method_sig(sig, generics, DEFAULT_VISIBILITY),
|
&FnSig::from_method_sig(sig, generics, vis),
|
||||||
span,
|
span,
|
||||||
FnBraceStyle::None,
|
FnBraceStyle::None,
|
||||||
)?;
|
)?;
|
||||||
@ -1474,12 +1475,17 @@ fn format_tuple_struct(
|
|||||||
format_empty_struct_or_tuple(context, inner_span, offset, &mut result, "(", ")");
|
format_empty_struct_or_tuple(context, inner_span, offset, &mut result, "(", ")");
|
||||||
} else {
|
} else {
|
||||||
let shape = Shape::indented(offset, context.config).sub_width(1)?;
|
let shape = Shape::indented(offset, context.config).sub_width(1)?;
|
||||||
|
let lo = if let Some(generics) = struct_parts.generics {
|
||||||
|
generics.span.hi()
|
||||||
|
} else {
|
||||||
|
struct_parts.ident.span.hi()
|
||||||
|
};
|
||||||
result = overflow::rewrite_with_parens(
|
result = overflow::rewrite_with_parens(
|
||||||
context,
|
context,
|
||||||
&result,
|
&result,
|
||||||
fields.iter(),
|
fields.iter(),
|
||||||
shape,
|
shape,
|
||||||
span,
|
mk_sp(lo, span.hi()),
|
||||||
context.config.fn_call_width(),
|
context.config.fn_call_width(),
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
@ -1503,7 +1509,7 @@ fn format_tuple_struct(
|
|||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rewrite_type<R: Rewrite>(
|
pub(crate) fn rewrite_type<R: Rewrite>(
|
||||||
context: &RewriteContext<'_>,
|
context: &RewriteContext<'_>,
|
||||||
indent: Indent,
|
indent: Indent,
|
||||||
ident: symbol::Ident,
|
ident: symbol::Ident,
|
||||||
@ -1760,7 +1766,7 @@ impl<'a> StaticParts<'a> {
|
|||||||
};
|
};
|
||||||
StaticParts {
|
StaticParts {
|
||||||
prefix: "const",
|
prefix: "const",
|
||||||
vis: &DEFAULT_VISIBILITY,
|
vis: &ti.vis,
|
||||||
ident: ti.ident,
|
ident: ti.ident,
|
||||||
ty,
|
ty,
|
||||||
mutability: ast::Mutability::Not,
|
mutability: ast::Mutability::Not,
|
||||||
@ -1847,29 +1853,6 @@ fn rewrite_static(
|
|||||||
Some(format!("{}{};", prefix, ty_str))
|
Some(format!("{}{};", prefix, ty_str))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn rewrite_type_alias(
|
|
||||||
ident: symbol::Ident,
|
|
||||||
ty_opt: Option<&ptr::P<ast::Ty>>,
|
|
||||||
generics: &ast::Generics,
|
|
||||||
generic_bounds_opt: Option<&ast::GenericBounds>,
|
|
||||||
context: &RewriteContext<'_>,
|
|
||||||
indent: Indent,
|
|
||||||
vis: &ast::Visibility,
|
|
||||||
span: Span,
|
|
||||||
) -> Option<String> {
|
|
||||||
rewrite_type(
|
|
||||||
context,
|
|
||||||
indent,
|
|
||||||
ident,
|
|
||||||
vis,
|
|
||||||
generics,
|
|
||||||
generic_bounds_opt,
|
|
||||||
ty_opt,
|
|
||||||
span,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OpaqueType<'a> {
|
struct OpaqueType<'a> {
|
||||||
bounds: &'a ast::GenericBounds,
|
bounds: &'a ast::GenericBounds,
|
||||||
}
|
}
|
||||||
@ -1883,32 +1866,7 @@ impl<'a> Rewrite for OpaqueType<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn rewrite_opaque_impl_type(
|
pub(crate) fn rewrite_impl_type(
|
||||||
context: &RewriteContext<'_>,
|
|
||||||
ident: symbol::Ident,
|
|
||||||
generics: &ast::Generics,
|
|
||||||
generic_bounds: &ast::GenericBounds,
|
|
||||||
indent: Indent,
|
|
||||||
) -> Option<String> {
|
|
||||||
let ident_str = rewrite_ident(context, ident);
|
|
||||||
// 5 = "type "
|
|
||||||
let generics_shape = Shape::indented(indent, context.config).offset_left(5)?;
|
|
||||||
let generics_str = rewrite_generics(context, ident_str, generics, generics_shape)?;
|
|
||||||
let prefix = format!("type {} =", generics_str);
|
|
||||||
let rhs = OpaqueType {
|
|
||||||
bounds: generic_bounds,
|
|
||||||
};
|
|
||||||
|
|
||||||
rewrite_assign_rhs(
|
|
||||||
context,
|
|
||||||
&prefix,
|
|
||||||
&rhs,
|
|
||||||
Shape::indented(indent, context.config).sub_width(1)?,
|
|
||||||
)
|
|
||||||
.map(|s| s + ";")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn rewrite_associated_impl_type(
|
|
||||||
ident: symbol::Ident,
|
ident: symbol::Ident,
|
||||||
vis: &ast::Visibility,
|
vis: &ast::Visibility,
|
||||||
defaultness: ast::Defaultness,
|
defaultness: ast::Defaultness,
|
||||||
@ -1918,7 +1876,25 @@ pub(crate) fn rewrite_associated_impl_type(
|
|||||||
indent: Indent,
|
indent: Indent,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
let result = rewrite_type_alias(ident, ty_opt, generics, None, context, indent, vis, span)?;
|
// Opaque type
|
||||||
|
let result = if let Some(rustc_ast::ast::Ty {
|
||||||
|
kind: ast::TyKind::ImplTrait(_, ref bounds),
|
||||||
|
..
|
||||||
|
}) = ty_opt.map(|t| &**t)
|
||||||
|
{
|
||||||
|
rewrite_type(
|
||||||
|
context,
|
||||||
|
indent,
|
||||||
|
ident,
|
||||||
|
&DEFAULT_VISIBILITY,
|
||||||
|
generics,
|
||||||
|
None,
|
||||||
|
Some(&OpaqueType { bounds }),
|
||||||
|
span,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
rewrite_type(context, indent, ident, vis, generics, None, ty_opt, span)
|
||||||
|
}?;
|
||||||
|
|
||||||
match defaultness {
|
match defaultness {
|
||||||
ast::Defaultness::Default(..) => Some(format!("default {}", result)),
|
ast::Defaultness::Default(..) => Some(format!("default {}", result)),
|
||||||
@ -1995,14 +1971,17 @@ impl Rewrite for ast::Param {
|
|||||||
let param_attrs_result = self
|
let param_attrs_result = self
|
||||||
.attrs
|
.attrs
|
||||||
.rewrite(context, Shape::legacy(shape.width, shape.indent))?;
|
.rewrite(context, Shape::legacy(shape.width, shape.indent))?;
|
||||||
let (span, has_multiple_attr_lines) = if !self.attrs.is_empty() {
|
// N.B. Doc comments aren't typically valid syntax, but could appear
|
||||||
|
// in the presence of certain macros - https://github.com/rust-lang/rustfmt/issues/4936
|
||||||
|
let (span, has_multiple_attr_lines, has_doc_comments) = if !self.attrs.is_empty() {
|
||||||
let num_attrs = self.attrs.len();
|
let num_attrs = self.attrs.len();
|
||||||
(
|
(
|
||||||
mk_sp(self.attrs[num_attrs - 1].span.hi(), self.pat.span.lo()),
|
mk_sp(self.attrs[num_attrs - 1].span.hi(), self.pat.span.lo()),
|
||||||
param_attrs_result.contains('\n'),
|
param_attrs_result.contains('\n'),
|
||||||
|
self.attrs.iter().any(|a| a.is_doc_comment()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(mk_sp(self.span.lo(), self.span.lo()), false)
|
(mk_sp(self.span.lo(), self.span.lo()), false, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(ref explicit_self) = self.to_self() {
|
if let Some(ref explicit_self) = self.to_self() {
|
||||||
@ -2015,15 +1994,16 @@ impl Rewrite for ast::Param {
|
|||||||
has_multiple_attr_lines,
|
has_multiple_attr_lines,
|
||||||
)
|
)
|
||||||
} else if is_named_param(self) {
|
} else if is_named_param(self) {
|
||||||
|
let param_name = &self
|
||||||
|
.pat
|
||||||
|
.rewrite(context, Shape::legacy(shape.width, shape.indent))?;
|
||||||
let mut result = combine_strs_with_missing_comments(
|
let mut result = combine_strs_with_missing_comments(
|
||||||
context,
|
context,
|
||||||
¶m_attrs_result,
|
¶m_attrs_result,
|
||||||
&self
|
param_name,
|
||||||
.pat
|
|
||||||
.rewrite(context, Shape::legacy(shape.width, shape.indent))?,
|
|
||||||
span,
|
span,
|
||||||
shape,
|
shape,
|
||||||
!has_multiple_attr_lines,
|
!has_multiple_attr_lines && !has_doc_comments,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if !is_empty_infer(&*self.ty, self.pat.span) {
|
if !is_empty_infer(&*self.ty, self.pat.span) {
|
||||||
@ -2034,10 +2014,30 @@ impl Rewrite for ast::Param {
|
|||||||
result.push_str(&after_comment);
|
result.push_str(&after_comment);
|
||||||
let overhead = last_line_width(&result);
|
let overhead = last_line_width(&result);
|
||||||
let max_width = shape.width.checked_sub(overhead)?;
|
let max_width = shape.width.checked_sub(overhead)?;
|
||||||
let ty_str = self
|
if let Some(ty_str) = self
|
||||||
.ty
|
.ty
|
||||||
.rewrite(context, Shape::legacy(max_width, shape.indent))?;
|
.rewrite(context, Shape::legacy(max_width, shape.indent))
|
||||||
result.push_str(&ty_str);
|
{
|
||||||
|
result.push_str(&ty_str);
|
||||||
|
} else {
|
||||||
|
result = combine_strs_with_missing_comments(
|
||||||
|
context,
|
||||||
|
&(param_attrs_result + &shape.to_string_with_newline(context.config)),
|
||||||
|
param_name,
|
||||||
|
span,
|
||||||
|
shape,
|
||||||
|
!has_multiple_attr_lines,
|
||||||
|
)?;
|
||||||
|
result.push_str(&before_comment);
|
||||||
|
result.push_str(colon_spaces(context.config));
|
||||||
|
result.push_str(&after_comment);
|
||||||
|
let overhead = last_line_width(&result);
|
||||||
|
let max_width = shape.width.checked_sub(overhead)?;
|
||||||
|
let ty_str = self
|
||||||
|
.ty
|
||||||
|
.rewrite(context, Shape::legacy(max_width, shape.indent))?;
|
||||||
|
result.push_str(&ty_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(result)
|
Some(result)
|
||||||
@ -3146,7 +3146,7 @@ impl Rewrite for ast::ForeignItem {
|
|||||||
context,
|
context,
|
||||||
shape.indent,
|
shape.indent,
|
||||||
self.ident,
|
self.ident,
|
||||||
&FnSig::from_method_sig(&fn_sig, generics, self.vis.clone()),
|
&FnSig::from_method_sig(&fn_sig, generics, &self.vis),
|
||||||
span,
|
span,
|
||||||
FnBraceStyle::None,
|
FnBraceStyle::None,
|
||||||
)
|
)
|
||||||
@ -3170,14 +3170,14 @@ impl Rewrite for ast::ForeignItem {
|
|||||||
ast::ForeignItemKind::TyAlias(ref ty_alias_kind) => {
|
ast::ForeignItemKind::TyAlias(ref ty_alias_kind) => {
|
||||||
let ast::TyAliasKind(_, ref generics, ref generic_bounds, ref type_default) =
|
let ast::TyAliasKind(_, ref generics, ref generic_bounds, ref type_default) =
|
||||||
**ty_alias_kind;
|
**ty_alias_kind;
|
||||||
rewrite_type_alias(
|
rewrite_type(
|
||||||
self.ident,
|
|
||||||
type_default.as_ref(),
|
|
||||||
generics,
|
|
||||||
Some(generic_bounds),
|
|
||||||
&context,
|
&context,
|
||||||
shape.indent,
|
shape.indent,
|
||||||
|
self.ident,
|
||||||
&self.vis,
|
&self.vis,
|
||||||
|
generics,
|
||||||
|
Some(generic_bounds),
|
||||||
|
type_default.as_ref(),
|
||||||
self.span,
|
self.span,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -367,9 +367,9 @@ where
|
|||||||
result.push_str(&comment);
|
result.push_str(&comment);
|
||||||
|
|
||||||
if !inner_item.is_empty() {
|
if !inner_item.is_empty() {
|
||||||
if tactic == DefinitiveListTactic::Vertical || tactic == DefinitiveListTactic::Mixed
|
use DefinitiveListTactic::*;
|
||||||
{
|
if matches!(tactic, Vertical | Mixed | SpecialMacro(_)) {
|
||||||
// We cannot keep pre-comments on the same line if the comment if normalized.
|
// We cannot keep pre-comments on the same line if the comment is normalized.
|
||||||
let keep_comment = if formatting.config.normalize_comments()
|
let keep_comment = if formatting.config.normalize_comments()
|
||||||
|| item.pre_comment_style == ListItemCommentStyle::DifferentLine
|
|| item.pre_comment_style == ListItemCommentStyle::DifferentLine
|
||||||
{
|
{
|
||||||
@ -389,7 +389,7 @@ where
|
|||||||
line_len = item.item.as_ref().map_or(0, |s| unicode_str_width(&s));
|
line_len = item.item.as_ref().map_or(0, |s| unicode_str_width(&s));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.push(' ');
|
result.push(' ')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item_max_width = None;
|
item_max_width = None;
|
||||||
|
@ -409,6 +409,7 @@ fn rewrite_match_body(
|
|||||||
}
|
}
|
||||||
result.push_str(&nested_indent_str);
|
result.push_str(&nested_indent_str);
|
||||||
result.push_str(&body_str);
|
result.push_str(&body_str);
|
||||||
|
result.push_str(&comma);
|
||||||
return Some(result);
|
return Some(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,14 @@ impl<'a> FmtVisitor<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn format_missing_with_indent(&mut self, end: BytePos) {
|
pub(crate) fn format_missing_with_indent(&mut self, end: BytePos) {
|
||||||
|
self.format_missing_indent(end, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn format_missing_no_indent(&mut self, end: BytePos) {
|
||||||
|
self.format_missing_indent(end, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn format_missing_indent(&mut self, end: BytePos, should_indent: bool) {
|
||||||
let config = self.config;
|
let config = self.config;
|
||||||
self.format_missing_inner(end, |this, last_snippet, snippet| {
|
self.format_missing_inner(end, |this, last_snippet, snippet| {
|
||||||
this.push_str(last_snippet.trim_end());
|
this.push_str(last_snippet.trim_end());
|
||||||
@ -58,14 +66,10 @@ impl<'a> FmtVisitor<'a> {
|
|||||||
// No new lines in the snippet.
|
// No new lines in the snippet.
|
||||||
this.push_str("\n");
|
this.push_str("\n");
|
||||||
}
|
}
|
||||||
let indent = this.block_indent.to_string(config);
|
if should_indent {
|
||||||
this.push_str(&indent);
|
let indent = this.block_indent.to_string(config);
|
||||||
})
|
this.push_str(&indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn format_missing_no_indent(&mut self, end: BytePos) {
|
|
||||||
self.format_missing_inner(end, |this, last_snippet, _| {
|
|
||||||
this.push_str(last_snippet.trim_end());
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ pub(crate) enum OverflowableItem<'a> {
|
|||||||
FieldDef(&'a ast::FieldDef),
|
FieldDef(&'a ast::FieldDef),
|
||||||
TuplePatField(&'a TuplePatField<'a>),
|
TuplePatField(&'a TuplePatField<'a>),
|
||||||
Ty(&'a ast::Ty),
|
Ty(&'a ast::Ty),
|
||||||
|
Pat(&'a ast::Pat),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Rewrite for OverflowableItem<'a> {
|
impl<'a> Rewrite for OverflowableItem<'a> {
|
||||||
@ -116,6 +117,7 @@ impl<'a> OverflowableItem<'a> {
|
|||||||
OverflowableItem::FieldDef(sf) => f(*sf),
|
OverflowableItem::FieldDef(sf) => f(*sf),
|
||||||
OverflowableItem::TuplePatField(pat) => f(*pat),
|
OverflowableItem::TuplePatField(pat) => f(*pat),
|
||||||
OverflowableItem::Ty(ty) => f(*ty),
|
OverflowableItem::Ty(ty) => f(*ty),
|
||||||
|
OverflowableItem::Pat(pat) => f(*pat),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +234,7 @@ macro_rules! impl_into_overflowable_item_for_rustfmt_types {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_into_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, FieldDef, Ty);
|
impl_into_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, FieldDef, Ty, Pat);
|
||||||
impl_into_overflowable_item_for_rustfmt_types!([MacroArg], [SegmentParam, TuplePatField]);
|
impl_into_overflowable_item_for_rustfmt_types!([MacroArg], [SegmentParam, TuplePatField]);
|
||||||
|
|
||||||
pub(crate) fn into_overflowable_list<'a, T>(
|
pub(crate) fn into_overflowable_list<'a, T>(
|
||||||
|
@ -4,6 +4,7 @@ use rustc_span::{BytePos, Span};
|
|||||||
|
|
||||||
use crate::comment::{combine_strs_with_missing_comments, FindUncommented};
|
use crate::comment::{combine_strs_with_missing_comments, FindUncommented};
|
||||||
use crate::config::lists::*;
|
use crate::config::lists::*;
|
||||||
|
use crate::config::Version;
|
||||||
use crate::expr::{can_be_overflowed_expr, rewrite_unary_prefix, wrap_struct_field};
|
use crate::expr::{can_be_overflowed_expr, rewrite_unary_prefix, wrap_struct_field};
|
||||||
use crate::lists::{
|
use crate::lists::{
|
||||||
definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
|
definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
|
||||||
@ -226,12 +227,13 @@ impl Rewrite for Pat {
|
|||||||
PatKind::Path(ref q_self, ref path) => {
|
PatKind::Path(ref q_self, ref path) => {
|
||||||
rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)
|
rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)
|
||||||
}
|
}
|
||||||
PatKind::TupleStruct(_, ref path, ref pat_vec) => {
|
PatKind::TupleStruct(ref q_self, ref path, ref pat_vec) => {
|
||||||
let path_str = rewrite_path(context, PathContext::Expr, None, path, shape)?;
|
let path_str =
|
||||||
|
rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)?;
|
||||||
rewrite_tuple_pat(pat_vec, Some(path_str), self.span, context, shape)
|
rewrite_tuple_pat(pat_vec, Some(path_str), self.span, context, shape)
|
||||||
}
|
}
|
||||||
PatKind::Lit(ref expr) => expr.rewrite(context, shape),
|
PatKind::Lit(ref expr) => expr.rewrite(context, shape),
|
||||||
PatKind::Slice(ref slice_pat) => {
|
PatKind::Slice(ref slice_pat) if context.config.version() == Version::One => {
|
||||||
let rw: Vec<String> = slice_pat
|
let rw: Vec<String> = slice_pat
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| {
|
.map(|p| {
|
||||||
@ -244,8 +246,17 @@ impl Rewrite for Pat {
|
|||||||
.collect();
|
.collect();
|
||||||
Some(format!("[{}]", rw.join(", ")))
|
Some(format!("[{}]", rw.join(", ")))
|
||||||
}
|
}
|
||||||
PatKind::Struct(_, ref path, ref fields, ellipsis) => {
|
PatKind::Slice(ref slice_pat) => overflow::rewrite_with_square_brackets(
|
||||||
rewrite_struct_pat(path, fields, ellipsis, self.span, context, shape)
|
context,
|
||||||
|
"",
|
||||||
|
slice_pat.iter(),
|
||||||
|
shape,
|
||||||
|
self.span,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
PatKind::Struct(ref qself, ref path, ref fields, ellipsis) => {
|
||||||
|
rewrite_struct_pat(qself, path, fields, ellipsis, self.span, context, shape)
|
||||||
}
|
}
|
||||||
PatKind::MacCall(ref mac) => {
|
PatKind::MacCall(ref mac) => {
|
||||||
rewrite_macro(mac, None, context, shape, MacroPosition::Pat)
|
rewrite_macro(mac, None, context, shape, MacroPosition::Pat)
|
||||||
@ -258,6 +269,7 @@ impl Rewrite for Pat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rewrite_struct_pat(
|
fn rewrite_struct_pat(
|
||||||
|
qself: &Option<ast::QSelf>,
|
||||||
path: &ast::Path,
|
path: &ast::Path,
|
||||||
fields: &[ast::PatField],
|
fields: &[ast::PatField],
|
||||||
ellipsis: bool,
|
ellipsis: bool,
|
||||||
@ -267,7 +279,7 @@ fn rewrite_struct_pat(
|
|||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
// 2 = ` {`
|
// 2 = ` {`
|
||||||
let path_shape = shape.sub_width(2)?;
|
let path_shape = shape.sub_width(2)?;
|
||||||
let path_str = rewrite_path(context, PathContext::Expr, None, path, path_shape)?;
|
let path_str = rewrite_path(context, PathContext::Expr, qself.as_ref(), path, path_shape)?;
|
||||||
|
|
||||||
if fields.is_empty() && !ellipsis {
|
if fields.is_empty() && !ellipsis {
|
||||||
return Some(format!("{} {{}}", path_str));
|
return Some(format!("{} {{}}", path_str));
|
||||||
|
@ -113,6 +113,7 @@ fn rewrite_reorderable_or_regroupable_items(
|
|||||||
merge_use_trees(normalized_items, SharedPrefix::Module)
|
merge_use_trees(normalized_items, SharedPrefix::Module)
|
||||||
}
|
}
|
||||||
ImportGranularity::Item => flatten_use_trees(normalized_items),
|
ImportGranularity::Item => flatten_use_trees(normalized_items),
|
||||||
|
ImportGranularity::One => merge_use_trees(normalized_items, SharedPrefix::One),
|
||||||
ImportGranularity::Preserve => normalized_items,
|
ImportGranularity::Preserve => normalized_items,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ impl Spanned for ast::Arm {
|
|||||||
impl Spanned for ast::Param {
|
impl Spanned for ast::Param {
|
||||||
fn span(&self) -> Span {
|
fn span(&self) -> Span {
|
||||||
if crate::items::is_named_param(self) {
|
if crate::items::is_named_param(self) {
|
||||||
mk_sp(self.pat.span.lo(), self.ty.span.hi())
|
mk_sp(crate::items::span_lo_for_param(self), self.ty.span.hi())
|
||||||
} else {
|
} else {
|
||||||
self.ty.span
|
self.ty.span
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,12 @@ impl ParseSess {
|
|||||||
self.parse_sess.source_map().span_to_filename(span).into()
|
self.parse_sess.source_map().span_to_filename(span).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn span_to_file_contents(&self, span: Span) -> Lrc<rustc_span::SourceFile> {
|
||||||
|
self.parse_sess
|
||||||
|
.source_map()
|
||||||
|
.lookup_source_file(span.data().lo)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn span_to_first_line_string(&self, span: Span) -> String {
|
pub(crate) fn span_to_first_line_string(&self, span: Span) -> String {
|
||||||
let file_lines = self.parse_sess.source_map().span_to_lines(span).ok();
|
let file_lines = self.parse_sess.source_map().span_to_lines(span).ok();
|
||||||
|
|
||||||
|
@ -469,11 +469,6 @@ fn stdin_works_with_modified_lines() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn stdin_disable_all_formatting_test() {
|
fn stdin_disable_all_formatting_test() {
|
||||||
init_log();
|
init_log();
|
||||||
match option_env!("CFG_RELEASE_CHANNEL") {
|
|
||||||
None | Some("nightly") => {}
|
|
||||||
// These tests require nightly.
|
|
||||||
_ => return,
|
|
||||||
}
|
|
||||||
let input = String::from("fn main() { println!(\"This should not be formatted.\"); }");
|
let input = String::from("fn main() { println!(\"This should not be formatted.\"); }");
|
||||||
let mut child = Command::new(rustfmt().to_str().unwrap())
|
let mut child = Command::new(rustfmt().to_str().unwrap())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
@ -694,7 +689,7 @@ fn read_significant_comments(file_name: &Path) -> HashMap<String, String> {
|
|||||||
reader
|
reader
|
||||||
.lines()
|
.lines()
|
||||||
.map(|line| line.expect("failed getting line"))
|
.map(|line| line.expect("failed getting line"))
|
||||||
.take_while(|line| line_regex.is_match(line))
|
.filter(|line| line_regex.is_match(line))
|
||||||
.filter_map(|line| {
|
.filter_map(|line| {
|
||||||
regex.captures_iter(&line).next().map(|capture| {
|
regex.captures_iter(&line).next().map(|capture| {
|
||||||
(
|
(
|
||||||
|
@ -169,34 +169,41 @@ impl<'a> Rewrite for SegmentParam<'a> {
|
|||||||
SegmentParam::Const(const_) => const_.rewrite(context, shape),
|
SegmentParam::Const(const_) => const_.rewrite(context, shape),
|
||||||
SegmentParam::LifeTime(lt) => lt.rewrite(context, shape),
|
SegmentParam::LifeTime(lt) => lt.rewrite(context, shape),
|
||||||
SegmentParam::Type(ty) => ty.rewrite(context, shape),
|
SegmentParam::Type(ty) => ty.rewrite(context, shape),
|
||||||
SegmentParam::Binding(assoc_ty_constraint) => {
|
SegmentParam::Binding(atc) => atc.rewrite(context, shape),
|
||||||
let mut result = match assoc_ty_constraint.kind {
|
|
||||||
ast::AssocTyConstraintKind::Bound { .. } => {
|
|
||||||
format!("{}: ", rewrite_ident(context, assoc_ty_constraint.ident))
|
|
||||||
}
|
|
||||||
ast::AssocTyConstraintKind::Equality { .. } => {
|
|
||||||
match context.config.type_punctuation_density() {
|
|
||||||
TypeDensity::Wide => {
|
|
||||||
format!("{} = ", rewrite_ident(context, assoc_ty_constraint.ident))
|
|
||||||
}
|
|
||||||
TypeDensity::Compressed => {
|
|
||||||
format!("{}=", rewrite_ident(context, assoc_ty_constraint.ident))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let budget = shape.width.checked_sub(result.len())?;
|
|
||||||
let rewrite = assoc_ty_constraint
|
|
||||||
.kind
|
|
||||||
.rewrite(context, Shape::legacy(budget, shape.indent + result.len()))?;
|
|
||||||
result.push_str(&rewrite);
|
|
||||||
Some(result)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Rewrite for ast::AssocTyConstraint {
|
||||||
|
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
|
||||||
|
use ast::AssocTyConstraintKind::{Bound, Equality};
|
||||||
|
|
||||||
|
let mut result = String::with_capacity(128);
|
||||||
|
result.push_str(rewrite_ident(context, self.ident));
|
||||||
|
|
||||||
|
if let Some(ref gen_args) = self.gen_args {
|
||||||
|
let budget = shape.width.checked_sub(result.len())?;
|
||||||
|
let shape = Shape::legacy(budget, shape.indent + result.len());
|
||||||
|
let gen_str = rewrite_generic_args(gen_args, context, shape, gen_args.span())?;
|
||||||
|
result.push_str(&gen_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
let infix = match (&self.kind, context.config.type_punctuation_density()) {
|
||||||
|
(Bound { .. }, _) => ": ",
|
||||||
|
(Equality { .. }, TypeDensity::Wide) => " = ",
|
||||||
|
(Equality { .. }, TypeDensity::Compressed) => "=",
|
||||||
|
};
|
||||||
|
result.push_str(infix);
|
||||||
|
|
||||||
|
let budget = shape.width.checked_sub(result.len())?;
|
||||||
|
let shape = Shape::legacy(budget, shape.indent + result.len());
|
||||||
|
let rewrite = self.kind.rewrite(context, shape)?;
|
||||||
|
result.push_str(&rewrite);
|
||||||
|
|
||||||
|
Some(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Rewrite for ast::AssocTyConstraintKind {
|
impl Rewrite for ast::AssocTyConstraintKind {
|
||||||
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
|
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
|
||||||
match self {
|
match self {
|
||||||
@ -235,21 +242,9 @@ fn rewrite_segment(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(ref args) = segment.args {
|
if let Some(ref args) = segment.args {
|
||||||
|
let generics_str = rewrite_generic_args(args, context, shape, mk_sp(*span_lo, span_hi))?;
|
||||||
match **args {
|
match **args {
|
||||||
ast::GenericArgs::AngleBracketed(ref data) if !data.args.is_empty() => {
|
ast::GenericArgs::AngleBracketed(ref data) if !data.args.is_empty() => {
|
||||||
let param_list = data
|
|
||||||
.args
|
|
||||||
.iter()
|
|
||||||
.map(|x| match x {
|
|
||||||
ast::AngleBracketedArg::Arg(generic_arg) => {
|
|
||||||
SegmentParam::from_generic_arg(generic_arg)
|
|
||||||
}
|
|
||||||
ast::AngleBracketedArg::Constraint(constraint) => {
|
|
||||||
SegmentParam::Binding(constraint)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
// HACK: squeeze out the span between the identifier and the parameters.
|
// HACK: squeeze out the span between the identifier and the parameters.
|
||||||
// The hack is requried so that we don't remove the separator inside macro calls.
|
// The hack is requried so that we don't remove the separator inside macro calls.
|
||||||
// This does not work in the presence of comment, hoping that people are
|
// This does not work in the presence of comment, hoping that people are
|
||||||
@ -265,33 +260,14 @@ fn rewrite_segment(
|
|||||||
};
|
};
|
||||||
result.push_str(separator);
|
result.push_str(separator);
|
||||||
|
|
||||||
let generics_str = overflow::rewrite_with_angle_brackets(
|
|
||||||
context,
|
|
||||||
"",
|
|
||||||
param_list.iter(),
|
|
||||||
shape,
|
|
||||||
mk_sp(*span_lo, span_hi),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Update position of last bracket.
|
// Update position of last bracket.
|
||||||
*span_lo = context
|
*span_lo = context
|
||||||
.snippet_provider
|
.snippet_provider
|
||||||
.span_after(mk_sp(*span_lo, span_hi), "<");
|
.span_after(mk_sp(*span_lo, span_hi), "<");
|
||||||
|
|
||||||
result.push_str(&generics_str)
|
|
||||||
}
|
|
||||||
ast::GenericArgs::Parenthesized(ref data) => {
|
|
||||||
result.push_str(&format_function_type(
|
|
||||||
data.inputs.iter().map(|x| &**x),
|
|
||||||
&data.output,
|
|
||||||
false,
|
|
||||||
data.span,
|
|
||||||
context,
|
|
||||||
shape,
|
|
||||||
)?);
|
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
result.push_str(&generics_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(result)
|
Some(result)
|
||||||
@ -484,6 +460,41 @@ impl Rewrite for ast::GenericArg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn rewrite_generic_args(
|
||||||
|
gen_args: &ast::GenericArgs,
|
||||||
|
context: &RewriteContext<'_>,
|
||||||
|
shape: Shape,
|
||||||
|
span: Span,
|
||||||
|
) -> Option<String> {
|
||||||
|
match gen_args {
|
||||||
|
ast::GenericArgs::AngleBracketed(ref data) if !data.args.is_empty() => {
|
||||||
|
let args = data
|
||||||
|
.args
|
||||||
|
.iter()
|
||||||
|
.map(|x| match x {
|
||||||
|
ast::AngleBracketedArg::Arg(generic_arg) => {
|
||||||
|
SegmentParam::from_generic_arg(generic_arg)
|
||||||
|
}
|
||||||
|
ast::AngleBracketedArg::Constraint(constraint) => {
|
||||||
|
SegmentParam::Binding(constraint)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
overflow::rewrite_with_angle_brackets(context, "", args.iter(), shape, span)
|
||||||
|
}
|
||||||
|
ast::GenericArgs::Parenthesized(ref data) => format_function_type(
|
||||||
|
data.inputs.iter().map(|x| &**x),
|
||||||
|
&data.output,
|
||||||
|
false,
|
||||||
|
data.span,
|
||||||
|
context,
|
||||||
|
shape,
|
||||||
|
),
|
||||||
|
_ => Some("".to_owned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn rewrite_bounded_lifetime(
|
fn rewrite_bounded_lifetime(
|
||||||
lt: &ast::Lifetime,
|
lt: &ast::Lifetime,
|
||||||
bounds: &[ast::GenericBound],
|
bounds: &[ast::GenericBound],
|
||||||
@ -566,13 +577,23 @@ impl Rewrite for ast::GenericParam {
|
|||||||
if let ast::GenericParamKind::Const {
|
if let ast::GenericParamKind::Const {
|
||||||
ref ty,
|
ref ty,
|
||||||
kw_span: _,
|
kw_span: _,
|
||||||
default: _,
|
default,
|
||||||
} = &self.kind
|
} = &self.kind
|
||||||
{
|
{
|
||||||
result.push_str("const ");
|
result.push_str("const ");
|
||||||
result.push_str(rewrite_ident(context, self.ident));
|
result.push_str(rewrite_ident(context, self.ident));
|
||||||
result.push_str(": ");
|
result.push_str(": ");
|
||||||
result.push_str(&ty.rewrite(context, shape)?);
|
result.push_str(&ty.rewrite(context, shape)?);
|
||||||
|
if let Some(default) = default {
|
||||||
|
let eq_str = match context.config.type_punctuation_density() {
|
||||||
|
TypeDensity::Compressed => "=",
|
||||||
|
TypeDensity::Wide => " = ",
|
||||||
|
};
|
||||||
|
result.push_str(eq_str);
|
||||||
|
let budget = shape.width.checked_sub(result.len())?;
|
||||||
|
let rewrite = default.rewrite(context, Shape::legacy(budget, shape.indent))?;
|
||||||
|
result.push_str(&rewrite);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result.push_str(rewrite_ident(context, self.ident));
|
result.push_str(rewrite_ident(context, self.ident));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
use rustc_ast::{ast, token::DelimToken, visit, AstLike};
|
use rustc_ast::{ast, token::DelimToken, visit, AstLike};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_span::{symbol, BytePos, Pos, Span, DUMMY_SP};
|
use rustc_span::{symbol, BytePos, Pos, Span};
|
||||||
|
|
||||||
use crate::attr::*;
|
use crate::attr::*;
|
||||||
use crate::comment::{contains_comment, rewrite_comment, CodeCharKind, CommentCodeSlices};
|
use crate::comment::{contains_comment, rewrite_comment, CodeCharKind, CommentCodeSlices};
|
||||||
@ -11,9 +11,9 @@ use crate::config::Version;
|
|||||||
use crate::config::{BraceStyle, Config};
|
use crate::config::{BraceStyle, Config};
|
||||||
use crate::coverage::transform_missing_snippet;
|
use crate::coverage::transform_missing_snippet;
|
||||||
use crate::items::{
|
use crate::items::{
|
||||||
format_impl, format_trait, format_trait_alias, is_mod_decl, is_use_item,
|
format_impl, format_trait, format_trait_alias, is_mod_decl, is_use_item, rewrite_extern_crate,
|
||||||
rewrite_associated_impl_type, rewrite_extern_crate, rewrite_opaque_impl_type,
|
rewrite_impl_type, rewrite_opaque_type, rewrite_type, FnBraceStyle, FnSig, StaticParts,
|
||||||
rewrite_opaque_type, rewrite_type_alias, FnBraceStyle, FnSig, StaticParts, StructParts,
|
StructParts,
|
||||||
};
|
};
|
||||||
use crate::macros::{macro_style, rewrite_macro, rewrite_macro_def, MacroPosition};
|
use crate::macros::{macro_style, rewrite_macro, rewrite_macro_def, MacroPosition};
|
||||||
use crate::modules::Module;
|
use crate::modules::Module;
|
||||||
@ -568,6 +568,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
|||||||
indent,
|
indent,
|
||||||
item.ident,
|
item.ident,
|
||||||
&fn_signature,
|
&fn_signature,
|
||||||
|
&item.vis,
|
||||||
generics,
|
generics,
|
||||||
item.span,
|
item.span,
|
||||||
);
|
);
|
||||||
@ -579,14 +580,14 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
|||||||
**alias_kind;
|
**alias_kind;
|
||||||
match ty {
|
match ty {
|
||||||
Some(ty) => {
|
Some(ty) => {
|
||||||
let rewrite = rewrite_type_alias(
|
let rewrite = rewrite_type(
|
||||||
item.ident,
|
|
||||||
Some(&*ty),
|
|
||||||
generics,
|
|
||||||
Some(generic_bounds),
|
|
||||||
&self.get_context(),
|
&self.get_context(),
|
||||||
self.block_indent,
|
self.block_indent,
|
||||||
|
item.ident,
|
||||||
&item.vis,
|
&item.vis,
|
||||||
|
generics,
|
||||||
|
Some(generic_bounds),
|
||||||
|
Some(&*ty),
|
||||||
item.span,
|
item.span,
|
||||||
);
|
);
|
||||||
self.push_rewrite(item.span, rewrite);
|
self.push_rewrite(item.span, rewrite);
|
||||||
@ -641,14 +642,9 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
|||||||
let ast::FnKind(defaultness, ref sig, ref generics, ref block) = **fn_kind;
|
let ast::FnKind(defaultness, ref sig, ref generics, ref block) = **fn_kind;
|
||||||
if let Some(ref body) = block {
|
if let Some(ref body) = block {
|
||||||
let inner_attrs = inner_attributes(&ti.attrs);
|
let inner_attrs = inner_attributes(&ti.attrs);
|
||||||
let vis = ast::Visibility {
|
|
||||||
kind: ast::VisibilityKind::Inherited,
|
|
||||||
span: DUMMY_SP,
|
|
||||||
tokens: None,
|
|
||||||
};
|
|
||||||
let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Trait);
|
let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Trait);
|
||||||
self.visit_fn(
|
self.visit_fn(
|
||||||
visit::FnKind::Fn(fn_ctxt, ti.ident, sig, &vis, Some(body)),
|
visit::FnKind::Fn(fn_ctxt, ti.ident, sig, &ti.vis, Some(body)),
|
||||||
generics,
|
generics,
|
||||||
&sig.decl,
|
&sig.decl,
|
||||||
ti.span,
|
ti.span,
|
||||||
@ -658,21 +654,21 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
|||||||
} else {
|
} else {
|
||||||
let indent = self.block_indent;
|
let indent = self.block_indent;
|
||||||
let rewrite =
|
let rewrite =
|
||||||
self.rewrite_required_fn(indent, ti.ident, sig, generics, ti.span);
|
self.rewrite_required_fn(indent, ti.ident, sig, &ti.vis, generics, ti.span);
|
||||||
self.push_rewrite(ti.span, rewrite);
|
self.push_rewrite(ti.span, rewrite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::AssocItemKind::TyAlias(ref ty_alias_kind) => {
|
ast::AssocItemKind::TyAlias(ref ty_alias_kind) => {
|
||||||
let ast::TyAliasKind(_, ref generics, ref generic_bounds, ref type_default) =
|
let ast::TyAliasKind(_, ref generics, ref generic_bounds, ref type_default) =
|
||||||
**ty_alias_kind;
|
**ty_alias_kind;
|
||||||
let rewrite = rewrite_type_alias(
|
let rewrite = rewrite_type(
|
||||||
ti.ident,
|
|
||||||
type_default.as_ref(),
|
|
||||||
generics,
|
|
||||||
Some(generic_bounds),
|
|
||||||
&self.get_context(),
|
&self.get_context(),
|
||||||
self.block_indent,
|
self.block_indent,
|
||||||
|
ti.ident,
|
||||||
&ti.vis,
|
&ti.vis,
|
||||||
|
generics,
|
||||||
|
Some(generic_bounds),
|
||||||
|
type_default.as_ref(),
|
||||||
ti.span,
|
ti.span,
|
||||||
);
|
);
|
||||||
self.push_rewrite(ti.span, rewrite);
|
self.push_rewrite(ti.span, rewrite);
|
||||||
@ -708,15 +704,16 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
|||||||
} else {
|
} else {
|
||||||
let indent = self.block_indent;
|
let indent = self.block_indent;
|
||||||
let rewrite =
|
let rewrite =
|
||||||
self.rewrite_required_fn(indent, ii.ident, sig, generics, ii.span);
|
self.rewrite_required_fn(indent, ii.ident, sig, &ii.vis, generics, ii.span);
|
||||||
self.push_rewrite(ii.span, rewrite);
|
self.push_rewrite(ii.span, rewrite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::AssocItemKind::Const(..) => self.visit_static(&StaticParts::from_impl_item(ii)),
|
ast::AssocItemKind::Const(..) => self.visit_static(&StaticParts::from_impl_item(ii)),
|
||||||
ast::AssocItemKind::TyAlias(ref ty_alias_kind) => {
|
ast::AssocItemKind::TyAlias(ref ty_alias_kind) => {
|
||||||
let ast::TyAliasKind(defaultness, ref generics, _, ref ty) = **ty_alias_kind;
|
let ast::TyAliasKind(defaultness, ref generics, _, ref ty) = **ty_alias_kind;
|
||||||
let rewrite_associated = || {
|
self.push_rewrite(
|
||||||
rewrite_associated_impl_type(
|
ii.span,
|
||||||
|
rewrite_impl_type(
|
||||||
ii.ident,
|
ii.ident,
|
||||||
&ii.vis,
|
&ii.vis,
|
||||||
defaultness,
|
defaultness,
|
||||||
@ -725,22 +722,8 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
|||||||
&self.get_context(),
|
&self.get_context(),
|
||||||
self.block_indent,
|
self.block_indent,
|
||||||
ii.span,
|
ii.span,
|
||||||
)
|
),
|
||||||
};
|
);
|
||||||
let rewrite = match ty {
|
|
||||||
None => rewrite_associated(),
|
|
||||||
Some(ty) => match ty.kind {
|
|
||||||
ast::TyKind::ImplTrait(_, ref bounds) => rewrite_opaque_impl_type(
|
|
||||||
&self.get_context(),
|
|
||||||
ii.ident,
|
|
||||||
generics,
|
|
||||||
bounds,
|
|
||||||
self.block_indent,
|
|
||||||
),
|
|
||||||
_ => rewrite_associated(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
self.push_rewrite(ii.span, rewrite);
|
|
||||||
}
|
}
|
||||||
ast::AssocItemKind::MacCall(ref mac) => {
|
ast::AssocItemKind::MacCall(ref mac) => {
|
||||||
self.visit_mac(mac, Some(ii.ident), MacroPosition::Item);
|
self.visit_mac(mac, Some(ii.ident), MacroPosition::Item);
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
[package]
|
||||||
|
name = "cargo-fmt-test"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["calebcartwright"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
indexmap = "1.0.2"
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"dependency-dir-name",
|
||||||
|
]
|
@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "dependency-crate-name"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["calebcartwright"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
subdep-crate-name = { path = "subdep-dir-name" }
|
||||||
|
indexmap = "1.0.2"
|
||||||
|
rusty-hook = "0.8.4"
|
@ -0,0 +1,7 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
assert_eq!(2 + 2, 4);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "subdep-crate-name"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["calebcartwright"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
@ -0,0 +1,7 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn sub_test_that_works() {
|
||||||
|
assert_eq!(3 + 3, 6);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "e"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
[dependencies]
|
||||||
|
c = { path = "../ws/c" }
|
||||||
|
|
||||||
|
[workspace]
|
@ -0,0 +1 @@
|
|||||||
|
struct E{ }
|
@ -0,0 +1,5 @@
|
|||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"a",
|
||||||
|
"b"
|
||||||
|
]
|
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "a"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
[dependencies]
|
||||||
|
d = { path = "./d" }
|
@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "d"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
[dependencies]
|
||||||
|
e = { path = "../../../e" }
|
||||||
|
f = { path = "f" }
|
@ -0,0 +1,4 @@
|
|||||||
|
[package]
|
||||||
|
name = "f"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
@ -0,0 +1 @@
|
|||||||
|
struct F{ }
|
@ -0,0 +1 @@
|
|||||||
|
struct D{ }
|
@ -0,0 +1 @@
|
|||||||
|
struct D{ }
|
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "b"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
[dependencies]
|
||||||
|
c = { path = "../c" }
|
@ -0,0 +1 @@
|
|||||||
|
struct B{ }
|
@ -0,0 +1,4 @@
|
|||||||
|
[package]
|
||||||
|
name = "c"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
@ -0,0 +1 @@
|
|||||||
|
struct C{ }
|
@ -0,0 +1,14 @@
|
|||||||
|
// rustfmt-binop_separator: Back
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let value = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ^ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;
|
||||||
|
|
||||||
|
let value = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ & abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;
|
||||||
|
|
||||||
|
let value = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ | abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;
|
||||||
|
|
||||||
|
let value = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ << abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;
|
||||||
|
|
||||||
|
let value = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ >> abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;
|
||||||
|
|
||||||
|
}
|
23
src/tools/rustfmt/tests/source/binop-separator-back/comp.rs
Normal file
23
src/tools/rustfmt/tests/source/binop-separator-back/comp.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// rustfmt-binop_separator: Back
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ < abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
if abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ <= abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
if abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ > abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
if abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ >= abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
if abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ == abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user