Skip to content

Commit 09304f1

Browse files
committed
Fix fallout in tools
1 parent 1522674 commit 09304f1

Some content is hidden

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

47 files changed

+185
-220
lines changed

src/librustdoc/clean/cfg/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ fn test_parse_err() {
325325
assert!(Cfg::parse(&mi).is_err());
326326

327327
let five = Symbol::intern("5");
328-
let mi = dummy_lit(five, LitKind::Int(5.into(), LitIntType::Unsuffixed));
328+
let mi = dummy_lit(five, LitKind::Int(5.into(), LitIntType::Unsuffixed(false)));
329329
assert!(Cfg::parse(&mi).is_err());
330330
})
331331
}

src/tools/clippy/clippy_lints/src/approx_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl ApproxConstant {
7676
}
7777

7878
impl<'tcx> LateLintPass<'tcx> for ApproxConstant {
79-
fn check_lit(&mut self, cx: &LateContext<'_>, _hir_id: HirId, lit: &Lit, _negated: bool) {
79+
fn check_lit(&mut self, cx: &LateContext<'_>, _hir_id: HirId, lit: &Lit) {
8080
match lit.node {
8181
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
8282
FloatTy::F16 => self.check_known_consts(cx, lit.span, s, "f16"),

src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::{get_parent_expr, is_hir_ty_cfg_dependant, is_ty_alias, path_t
66
use rustc_ast::{LitFloatType, LitIntType, LitKind};
77
use rustc_errors::Applicability;
88
use rustc_hir::def::{DefKind, Res};
9-
use rustc_hir::{Expr, ExprKind, Lit, Node, Path, QPath, TyKind, UnOp};
9+
use rustc_hir::{Expr, ExprKind, Node, Path, QPath, TyKind};
1010
use rustc_lint::{LateContext, LintContext};
1111
use rustc_middle::ty::{self, FloatTy, InferTy, Ty};
1212
use std::ops::ControlFlow;
@@ -99,7 +99,7 @@ pub(super) fn check<'tcx>(
9999
return false;
100100
}
101101

102-
if let Some(lit) = get_numeric_literal(cast_expr) {
102+
if let ExprKind::Lit(lit) = cast_expr.kind {
103103
let literal_str = &cast_str;
104104

105105
if let LitKind::Int(n, _) = lit.node
@@ -118,15 +118,15 @@ pub(super) fn check<'tcx>(
118118
}
119119

120120
match lit.node {
121-
LitKind::Int(_, LitIntType::Unsuffixed) if cast_to.is_integral() => {
121+
LitKind::Int(_, LitIntType::Unsuffixed(_)) if cast_to.is_integral() => {
122122
lint_unnecessary_cast(cx, expr, literal_str, cast_from, cast_to);
123123
return false;
124124
},
125125
LitKind::Float(_, LitFloatType::Unsuffixed) if cast_to.is_floating_point() => {
126126
lint_unnecessary_cast(cx, expr, literal_str, cast_from, cast_to);
127127
return false;
128128
},
129-
LitKind::Int(_, LitIntType::Signed(_) | LitIntType::Unsigned(_))
129+
LitKind::Int(_, LitIntType::Signed(..) | LitIntType::Unsigned(_))
130130
| LitKind::Float(_, LitFloatType::Suffixed(_))
131131
if cast_from.kind() == cast_to.kind() =>
132132
{
@@ -214,20 +214,6 @@ fn lint_unnecessary_cast(
214214
);
215215
}
216216

217-
fn get_numeric_literal<'e>(expr: &'e Expr<'e>) -> Option<&'e Lit> {
218-
match expr.kind {
219-
ExprKind::Lit(lit) => Some(lit),
220-
ExprKind::Unary(UnOp::Neg, e) => {
221-
if let ExprKind::Lit(lit) = e.kind {
222-
Some(lit)
223-
} else {
224-
None
225-
}
226-
},
227-
_ => None,
228-
}
229-
}
230-
231217
/// Returns the mantissa bits wide of a fp type.
232218
/// Will return 0 if the type is not a fp
233219
fn fp_ty_mantissa_nbits(typ: Ty<'_>) -> u32 {

src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'a, 'tcx> NumericFallbackVisitor<'a, 'tcx> {
8888
&& matches!(self.ty_bounds.last(), Some(ExplicitTyBound(false)))
8989
&& matches!(
9090
lit.node,
91-
LitKind::Int(_, LitIntType::Unsuffixed) | LitKind::Float(_, LitFloatType::Unsuffixed)
91+
LitKind::Int(_, LitIntType::Unsuffixed(false)) | LitKind::Float(_, LitFloatType::Unsuffixed)
9292
)
9393
{
9494
let (suffix, is_float) = match lit_ty.kind() {

src/tools/clippy/clippy_lints/src/implicit_saturating_add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingAdd {
7070
&& clippy_utils::SpanlessEq::new(cx).eq_expr(l, target)
7171
&& BinOpKind::Add == op1.node
7272
&& let ExprKind::Lit(lit) = value.kind
73-
&& let LitKind::Int(Pu128(1), LitIntType::Unsuffixed) = lit.node
73+
&& let LitKind::Int(Pu128(1), LitIntType::Unsuffixed(false)) = lit.node
7474
&& block.expr.is_none()
7575
{
7676
let mut app = Applicability::MachineApplicable;

src/tools/clippy/clippy_lints/src/loops/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'tcx> Visitor<'tcx> for InitializeVisitor<'_, 'tcx> {
192192
InitializeVisitorState::Declared(name, mut ty) => {
193193
if ty.is_none() {
194194
if let ExprKind::Lit(Spanned {
195-
node: LitKind::Int(_, LitIntType::Unsuffixed),
195+
node: LitKind::Int(_, LitIntType::Unsuffixed(false)),
196196
..
197197
}) = rhs.kind
198198
{

src/tools/clippy/clippy_lints/src/manual_div_ceil.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,9 @@ fn differ_by_one(small_expr: &Expr<'_>, large_expr: &Expr<'_>) -> bool {
133133
&& let ExprKind::Lit(large) = large_expr.kind
134134
&& let LitKind::Int(s, _) = small.node
135135
&& let LitKind::Int(l, _) = large.node
136+
&& small.node.is_negative() == large.node.is_negative()
136137
{
137138
Some(l.get()) == s.get().checked_add(1)
138-
} else if let ExprKind::Unary(UnOp::Neg, small_inner_expr) = small_expr.kind
139-
&& let ExprKind::Unary(UnOp::Neg, large_inner_expr) = large_expr.kind
140-
{
141-
differ_by_one(large_inner_expr, small_inner_expr)
142139
} else {
143140
false
144141
}
@@ -179,18 +176,9 @@ fn build_suggestion(
179176
&& matches!(
180177
lhs.kind,
181178
ExprKind::Lit(Spanned {
182-
node: LitKind::Int(_, LitIntType::Unsuffixed),
179+
node: LitKind::Int(_, LitIntType::Unsuffixed(_)),
183180
..
184-
}) | ExprKind::Unary(
185-
UnOp::Neg,
186-
Expr {
187-
kind: ExprKind::Lit(Spanned {
188-
node: LitKind::Int(_, LitIntType::Unsuffixed),
189-
..
190-
}),
191-
..
192-
}
193-
)
181+
})
194182
) {
195183
format!("_{}", cx.typeck_results().expr_ty(rhs))
196184
} else {

src/tools/clippy/clippy_lints/src/manual_is_ascii_check.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,8 @@ fn check_expr_range(start: &Expr<'_>, end: &Expr<'_>) -> CharRange {
202202
}
203203

204204
fn check_range(start: &PatExpr<'_>, end: &PatExpr<'_>) -> CharRange {
205-
if let PatExprKind::Lit {
206-
lit: start_lit,
207-
negated: false,
208-
} = &start.kind
209-
&& let PatExprKind::Lit {
210-
lit: end_lit,
211-
negated: false,
212-
} = &end.kind
205+
if let PatExprKind::Lit { lit: start_lit } = &start.kind
206+
&& let PatExprKind::Lit { lit: end_lit } = &end.kind
213207
{
214208
check_lit_range(start_lit, end_lit)
215209
} else {

src/tools/clippy/clippy_lints/src/manual_range_patterns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ declare_clippy_lint! {
3838
declare_lint_pass!(ManualRangePatterns => [MANUAL_RANGE_PATTERNS]);
3939

4040
fn expr_as_i128(expr: &PatExpr<'_>) -> Option<i128> {
41-
if let PatExprKind::Lit { lit, negated } = expr.kind
41+
if let PatExprKind::Lit { lit } = expr.kind
4242
&& let LitKind::Int(num, _) = lit.node
4343
{
4444
// Intentionally not handling numbers greater than i128::MAX (for u128 literals) for now.
4545
let n = i128::try_from(num.get()).ok()?;
46-
Some(if negated { -n } else { n })
46+
Some(if lit.node.is_negative() { -n } else { n })
4747
} else {
4848
None
4949
}

src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl<'a> NormalizedPat<'a> {
317317
},
318318
PatKind::Expr(e) => match &e.kind {
319319
// TODO: Handle negative integers. They're currently treated as a wild match.
320-
PatExprKind::Lit { lit, negated: false } => match lit.node {
320+
PatExprKind::Lit { lit } if !lit.node.is_negative() => match lit.node {
321321
LitKind::Str(sym, _) => Self::LitStr(sym),
322322
LitKind::ByteStr(ref bytes, _) | LitKind::CStr(ref bytes, _) => Self::LitBytes(bytes),
323323
LitKind::Byte(val) => Self::LitInt(val.into()),
@@ -334,7 +334,7 @@ impl<'a> NormalizedPat<'a> {
334334
let start = match start {
335335
None => 0,
336336
Some(e) => match &e.kind {
337-
PatExprKind::Lit { lit, negated: false } => match lit.node {
337+
PatExprKind::Lit { lit } if !lit.node.is_negative() => match lit.node {
338338
LitKind::Int(val, _) => val.get(),
339339
LitKind::Char(val) => val.into(),
340340
LitKind::Byte(val) => val.into(),
@@ -346,7 +346,7 @@ impl<'a> NormalizedPat<'a> {
346346
let (end, bounds) = match end {
347347
None => (u128::MAX, RangeEnd::Included),
348348
Some(e) => match &e.kind {
349-
PatExprKind::Lit { lit, negated: false } => match lit.node {
349+
PatExprKind::Lit { lit } if !lit.node.is_negative() => match lit.node {
350350
LitKind::Int(val, _) => (val.get(), bounds),
351351
LitKind::Char(val) => (val.into(), bounds),
352352
LitKind::Byte(val) => (val.into(), bounds),

0 commit comments

Comments
 (0)