Skip to content

Commit 45ff5d1

Browse files
committed
fixed style issues and incorrect implementation
1 parent 67492b9 commit 45ff5d1

File tree

452 files changed

+1758
-1505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

452 files changed

+1758
-1505
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,14 @@ impl TtParser {
678678
// edition-specific matching behavior for non-terminals.
679679
let nt = match parser.to_mut().parse_nonterminal(kind) {
680680
Err(err) => {
681-
let guarantee = err.with_span_label(
682-
span,
683-
format!(
681+
let guarantee = err
682+
.with_span_label(
683+
span,
684+
format!(
684685
"while parsing argument for this `{kind}` macro fragment"
685686
),
686-
)
687-
.emit();
687+
)
688+
.emit();
688689
return ErrorReported(guarantee);
689690
}
690691
Ok(nt) => nt,

compiler/rustc_index_macros/src/newtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl Parse for Newtype {
122122
#gate_rustc_only
123123
impl ::std::iter::Step for #name {
124124
#[inline]
125-
fn steps_between(start: &Self, end: &Self) -> (usize,Option<usize>) {
125+
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
126126
<usize as ::std::iter::Step>::steps_between(
127127
&Self::index(*start),
128128
&Self::index(*end),

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
166166
) -> ty::GenericArg<'tcx> {
167167
let arg = self.param_env.and(arg);
168168

169-
self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| bug!(
169+
self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| {
170+
bug!(
170171
"Failed to normalize {:?}, maybe try to call `try_normalize_erasing_regions` instead",
171172
arg.value
172-
))
173+
)
174+
})
173175
}
174176
}
175177

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
117117
let suggestion = suggestion
118118
.and_then(|suggestion| {
119119
sm.indentation_before(span).map(|indent| {
120-
format!("{}// TODO: Audit that {}.\n", indent, suggestion) // ignore-tidy-todo
120+
format!("{}// TODO: Audit that {}.\n", indent, suggestion)
121+
// ignore-tidy-todo
121122
})
122123
})
123124
.unwrap_or_default();

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ impl<'psess, 'src> StringReader<'psess, 'src> {
519519
.with_code(E0766)
520520
.emit()
521521
}
522-
self.cook_unicode(token::ByteStr, Mode::ByteStr, start, end, 2, 1) // b" "
522+
self.cook_unicode(token::ByteStr, Mode::ByteStr, start, end, 2, 1)
523+
// b" "
523524
}
524525
rustc_lexer::LiteralKind::CStr { terminated } => {
525526
if !terminated {
@@ -537,7 +538,8 @@ impl<'psess, 'src> StringReader<'psess, 'src> {
537538
if let Some(n_hashes) = n_hashes {
538539
let n = u32::from(n_hashes);
539540
let kind = token::StrRaw(n_hashes);
540-
self.cook_unicode(kind, Mode::RawStr, start, end, 2 + n, 1 + n) // r##" "##
541+
self.cook_unicode(kind, Mode::RawStr, start, end, 2 + n, 1 + n)
542+
// r##" "##
541543
} else {
542544
self.report_raw_str_error(start, 1);
543545
}
@@ -546,7 +548,8 @@ impl<'psess, 'src> StringReader<'psess, 'src> {
546548
if let Some(n_hashes) = n_hashes {
547549
let n = u32::from(n_hashes);
548550
let kind = token::ByteStrRaw(n_hashes);
549-
self.cook_unicode(kind, Mode::RawByteStr, start, end, 3 + n, 1 + n) // br##" "##
551+
self.cook_unicode(kind, Mode::RawByteStr, start, end, 3 + n, 1 + n)
552+
// br##" "##
550553
} else {
551554
self.report_raw_str_error(start, 2);
552555
}
@@ -555,7 +558,8 @@ impl<'psess, 'src> StringReader<'psess, 'src> {
555558
if let Some(n_hashes) = n_hashes {
556559
let n = u32::from(n_hashes);
557560
let kind = token::CStrRaw(n_hashes);
558-
self.cook_unicode(kind, Mode::RawCStr, start, end, 3 + n, 1 + n) // cr##" "##
561+
self.cook_unicode(kind, Mode::RawCStr, start, end, 3 + n, 1 + n)
562+
// cr##" "##
559563
} else {
560564
self.report_raw_str_error(start, 2);
561565
}

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17421742
)) = binding.kind
17431743
{
17441744
let def_id = self.tcx.parent(ctor_def_id);
1745-
return self.field_idents(def_id)?.iter().map(|&f| f.span).reduce(Span::to); // None for `struct Foo()`
1745+
return self.field_idents(def_id)?.iter().map(|&f| f.span).reduce(Span::to);
1746+
// None for `struct Foo()`
17461747
}
17471748
None
17481749
}

library/core/src/iter/range.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,13 @@ macro_rules! step_integer_impls {
259259
step_unsigned_methods!();
260260

261261
#[inline]
262-
fn steps_between(start: &Self, end: &Self) -> (usize,Option<usize>) {
262+
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
263263
if *start <= *end {
264264
// This relies on $u_narrower <= usize
265-
((*end-*start) as usize, Some((*end - *start) as usize))
265+
let steps = (*end - *start) as usize
266+
(steps, Some(steps))
266267
} else {
267-
(0,None)
268+
(0, None)
268269
}
269270
}
270271

@@ -299,7 +300,8 @@ macro_rules! step_integer_impls {
299300
// Casting to isize extends the width but preserves the sign.
300301
// Use wrapping_sub in isize space and cast to usize to compute
301302
// the difference that might not fit inside the range of isize.
302-
((*end as isize).wrapping_sub(*start as isize) as usize,Some((*end as isize).wrapping_sub(*start as isize) as usize))
303+
let steps = (*end as isize).wrapping_sub(*start as isize) as usize;
304+
(steps, Some(steps))
303305
} else {
304306
(0,None)
305307
}
@@ -707,7 +709,7 @@ impl<A: Step> RangeIteratorImpl for ops::Range<A> {
707709
#[inline]
708710
default fn spec_advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
709711
let steps = Step::steps_between(&self.start, &self.end);
710-
let available = if let Some(steps) = steps.1 { steps } else { steps.0 };
712+
let available = steps.1.unwrap_or(steps.0);
711713

712714
let taken = available.min(n);
713715

@@ -745,7 +747,7 @@ impl<A: Step> RangeIteratorImpl for ops::Range<A> {
745747
#[inline]
746748
default fn spec_advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
747749
let steps = Step::steps_between(&self.start, &self.end);
748-
let available = if let Some(steps) = steps.1 { steps } else { steps.0 };
750+
let available = steps.1.unwrap_or(steps.0);
749751

750752
let taken = available.min(n);
751753

@@ -786,7 +788,7 @@ impl<T: TrustedStep> RangeIteratorImpl for ops::Range<T> {
786788
#[inline]
787789
fn spec_advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
788790
let steps = Step::steps_between(&self.start, &self.end);
789-
let available = if let Some(steps) = steps.1 { steps } else { steps.0 };
791+
let available = steps.1.unwrap_or(step.0);
790792

791793
let taken = available.min(n);
792794

@@ -827,7 +829,7 @@ impl<T: TrustedStep> RangeIteratorImpl for ops::Range<T> {
827829
#[inline]
828830
fn spec_advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
829831
let steps = Step::steps_between(&self.start, &self.end);
830-
let available = if let Some(steps) = steps.1 { steps } else { steps.0 };
832+
let available = steps.1.unwrap_or(steps.0);
831833

832834
let taken = available.min(n);
833835

@@ -849,11 +851,7 @@ impl<A: Step> Iterator for ops::Range<A> {
849851

850852
#[inline]
851853
fn size_hint(&self) -> (usize, Option<usize>) {
852-
if self.start < self.end {
853-
(0, Some(0))
854-
} else {
855-
Step::steps_between(&self.start, &self.end)
856-
}
854+
Step::steps_between(&self.start, &self.end)
857855
}
858856

859857
#[inline]

src/tools/clippy/clippy_config/src/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::ClippyConfiguration;
21
use crate::msrvs::Msrv;
32
use crate::types::{DisallowedPath, MacroMatcher, MatchLintBehaviour, PubUnderscoreFieldsBehaviour, Rename};
3+
use crate::ClippyConfiguration;
44
use rustc_errors::Applicability;
55
use rustc_session::Session;
66
use rustc_span::edit_distance::edit_distance;

src/tools/clippy/clippy_config/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ mod metadata;
2626
pub mod msrvs;
2727
pub mod types;
2828

29-
pub use conf::{Conf, get_configuration_metadata, lookup_conf_file, sanitize_explanation};
29+
pub use conf::{get_configuration_metadata, lookup_conf_file, sanitize_explanation, Conf};
3030
pub use metadata::ClippyConfiguration;

src/tools/clippy/clippy_config/src/msrvs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast::Attribute;
22
use rustc_attr::parse_version;
33
use rustc_session::{RustcVersion, Session};
4-
use rustc_span::{Symbol, sym};
4+
use rustc_span::{sym, Symbol};
55
use serde::Deserialize;
66
use std::fmt;
77

0 commit comments

Comments
 (0)