Skip to content

Commit f16bfa4

Browse files
committed
Auto merge of rust-lang#10703 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents a3ed905 + 36bf3ef commit f16bfa4

Some content is hidden

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

55 files changed

+129
-87
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.70"
3+
version = "0.1.71"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.70"
3+
version = "0.1.71"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/bool_assert_comparison.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn extract_bool_lit(e: &Expr<'_>) -> Option<bool> {
4141
}) = e.kind
4242
&& !e.span.from_expansion()
4343
{
44-
Some(b)
44+
Some(*b)
4545
} else {
4646
None
4747
}

clippy_lints/src/casts/unnecessary_cast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ fn lint_unnecessary_cast(
141141

142142
fn get_numeric_literal<'e>(expr: &'e Expr<'e>) -> Option<&'e Lit> {
143143
match expr.kind {
144-
ExprKind::Lit(ref lit) => Some(lit),
144+
ExprKind::Lit(lit) => Some(lit),
145145
ExprKind::Unary(UnOp::Neg, e) => {
146-
if let ExprKind::Lit(ref lit) = e.kind {
146+
if let ExprKind::Lit(lit) = e.kind {
147147
Some(lit)
148148
} else {
149149
None

clippy_lints/src/float_literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
6666
let ty = cx.typeck_results().expr_ty(expr);
6767
if_chain! {
6868
if let ty::Float(fty) = *ty.kind();
69-
if let hir::ExprKind::Lit(ref lit) = expr.kind;
69+
if let hir::ExprKind::Lit(lit) = expr.kind;
7070
if let LitKind::Float(sym, lit_float_ty) = lit.node;
7171
then {
7272
let sym_str = sym.as_str();

clippy_lints/src/floating_point_arithmetic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
677677
{
678678
let mut proposal = format!("{}.to_degrees()", Sugg::hir(cx, mul_lhs, "..").maybe_par());
679679
if_chain! {
680-
if let ExprKind::Lit(ref literal) = mul_lhs.kind;
680+
if let ExprKind::Lit(literal) = mul_lhs.kind;
681681
if let ast::LitKind::Float(ref value, float_type) = literal.node;
682682
if float_type == ast::LitFloatType::Unsuffixed;
683683
then {
@@ -703,7 +703,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
703703
{
704704
let mut proposal = format!("{}.to_radians()", Sugg::hir(cx, mul_lhs, "..").maybe_par());
705705
if_chain! {
706-
if let ExprKind::Lit(ref literal) = mul_lhs.kind;
706+
if let ExprKind::Lit(literal) = mul_lhs.kind;
707707
if let ast::LitKind::Float(ref value, float_type) = literal.node;
708708
if float_type == ast::LitFloatType::Unsuffixed;
709709
then {

clippy_lints/src/implicit_saturating_add.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingAdd {
6060
if expr1.span.ctxt() == ctxt;
6161
if clippy_utils::SpanlessEq::new(cx).eq_expr(l, target);
6262
if BinOpKind::Add == op1.node;
63-
if let ExprKind::Lit(ref lit) = value.kind;
63+
if let ExprKind::Lit(lit) = value.kind;
6464
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit.node;
6565
if block.expr.is_none();
6666
then {

clippy_lints/src/implicit_saturating_sub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
8787
// Get the variable name
8888
let var_name = ares_path.segments[0].ident.name.as_str();
8989
match cond_num_val.kind {
90-
ExprKind::Lit(ref cond_lit) => {
90+
ExprKind::Lit(cond_lit) => {
9191
// Check if the constant is zero
9292
if let LitKind::Int(0, _) = cond_lit.node {
9393
if cx.typeck_results().expr_ty(cond_left).is_signed() {

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ fn check_empty_expr(cx: &LateContext<'_>, span: Span, lit1: &Expr<'_>, lit2: &Ex
532532
}
533533

534534
fn is_empty_string(expr: &Expr<'_>) -> bool {
535-
if let ExprKind::Lit(ref lit) = expr.kind {
535+
if let ExprKind::Lit(lit) = expr.kind {
536536
if let LitKind::Str(lit, _) = lit.node {
537537
let lit = lit.as_str();
538538
return lit.is_empty();

clippy_lints/src/loops/needless_range_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ fn is_end_eq_array_len<'tcx>(
208208
indexed_ty: Ty<'tcx>,
209209
) -> bool {
210210
if_chain! {
211-
if let ExprKind::Lit(ref lit) = end.kind;
211+
if let ExprKind::Lit(lit) = end.kind;
212212
if let ast::LitKind::Int(end_int, _) = lit.node;
213213
if let ty::Array(_, arr_len_const) = indexed_ty.kind();
214214
if let Some(arr_len) = arr_len_const.try_eval_target_usize(cx.tcx, cx.param_env);

clippy_lints/src/loops/never_loop.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: H
226226
| InlineAsmOperand::SymStatic { .. } => NeverLoopResult::Otherwise,
227227
})
228228
.fold(NeverLoopResult::Otherwise, combine_seq),
229-
ExprKind::Yield(_, _)
229+
ExprKind::OffsetOf(_, _)
230+
| ExprKind::Yield(_, _)
230231
| ExprKind::Closure { .. }
231232
| ExprKind::Path(_)
232233
| ExprKind::ConstBlock(_)

clippy_lints/src/manual_strip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn eq_pattern_length<'tcx>(cx: &LateContext<'tcx>, pattern: &Expr<'_>, expr: &'t
159159
..
160160
}) = expr.kind
161161
{
162-
constant_length(cx, pattern).map_or(false, |length| length == n)
162+
constant_length(cx, pattern).map_or(false, |length| length == *n)
163163
} else {
164164
len_arg(cx, expr).map_or(false, |arg| eq_expr_value(cx, pattern, arg))
165165
}

clippy_lints/src/matches/match_bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) fn check(cx: &LateContext<'_>, scrutinee: &Expr<'_>, arms: &[Arm<'_>]
2222
if arms.len() == 2 {
2323
// no guards
2424
let exprs = if let PatKind::Lit(arm_bool) = arms[0].pat.kind {
25-
if let ExprKind::Lit(ref lit) = arm_bool.kind {
25+
if let ExprKind::Lit(lit) = arm_bool.kind {
2626
match lit.node {
2727
LitKind::Bool(true) => Some((arms[0].body, arms[1].body)),
2828
LitKind::Bool(false) => Some((arms[1].body, arms[0].body)),

clippy_lints/src/matches/match_like_matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn find_bool_lit(ex: &ExprKind<'_>) -> Option<bool> {
162162
node: LitKind::Bool(b), ..
163163
}) = exp.kind
164164
{
165-
Some(b)
165+
Some(*b)
166166
} else {
167167
None
168168
}

clippy_lints/src/matches/redundant_pattern_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ fn find_good_method_for_match<'a>(
334334
};
335335

336336
match body_node_pair {
337-
(ExprKind::Lit(ref lit_left), ExprKind::Lit(ref lit_right)) => match (&lit_left.node, &lit_right.node) {
337+
(ExprKind::Lit(lit_left), ExprKind::Lit(lit_right)) => match (&lit_left.node, &lit_right.node) {
338338
(LitKind::Bool(true), LitKind::Bool(false)) => Some(should_be_left),
339339
(LitKind::Bool(false), LitKind::Bool(true)) => Some(should_be_right),
340340
_ => None,

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

+1
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
342342
ExprKind::DropTemps(_) |
343343
ExprKind::Err(_) |
344344
ExprKind::InlineAsm(_) |
345+
ExprKind::OffsetOf(_, _) |
345346
ExprKind::Let(_) |
346347
ExprKind::Lit(_) |
347348
ExprKind::Loop(_, _, _, _) |

clippy_lints/src/methods/chars_cmp_with_unwrap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(super) fn check(
1818
) -> bool {
1919
if_chain! {
2020
if let Some(args) = method_chain_args(info.chain, chain_methods);
21-
if let hir::ExprKind::Lit(ref lit) = info.other.kind;
21+
if let hir::ExprKind::Lit(lit) = info.other.kind;
2222
if let ast::LitKind::Char(c) = lit.node;
2323
then {
2424
let mut applicability = Applicability::MachineApplicable;

clippy_lints/src/methods/iter_next_slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, cal
3030
if let hir::ExprKind::Index(caller_var, index_expr) = &caller_expr.kind;
3131
if let Some(higher::Range { start: Some(start_expr), end: None, limits: ast::RangeLimits::HalfOpen })
3232
= higher::Range::hir(index_expr);
33-
if let hir::ExprKind::Lit(ref start_lit) = &start_expr.kind;
33+
if let hir::ExprKind::Lit(start_lit) = &start_expr.kind;
3434
if let ast::LitKind::Int(start_idx, _) = start_lit.node;
3535
then {
3636
let mut applicability = Applicability::MachineApplicable;

clippy_lints/src/methods/open_options.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ fn get_open_options(cx: &LateContext<'_>, argument: &Expr<'_>, options: &mut Vec
4242
// Only proceed if this is a call on some object of type std::fs::OpenOptions
4343
if match_type(cx, obj_ty, &paths::OPEN_OPTIONS) && !arguments.is_empty() {
4444
let argument_option = match arguments[0].kind {
45-
ExprKind::Lit(ref span) => {
45+
ExprKind::Lit(span) => {
4646
if let Spanned {
4747
node: LitKind::Bool(lit),
4848
..
49-
} = *span
49+
} = span
5050
{
51-
if lit { Argument::True } else { Argument::False }
51+
if *lit { Argument::True } else { Argument::False }
5252
} else {
5353
// The function is called with a literal which is not a boolean literal.
5454
// This is theoretically possible, but not very likely.

clippy_lints/src/methods/path_buf_push_overwrite.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arg: &'t
1515
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
1616
if let Some(impl_id) = cx.tcx.impl_of_method(method_id);
1717
if is_type_diagnostic_item(cx, cx.tcx.type_of(impl_id).subst_identity(), sym::PathBuf);
18-
if let ExprKind::Lit(ref lit) = arg.kind;
18+
if let ExprKind::Lit(lit) = arg.kind;
1919
if let LitKind::Str(ref path_lit, _) = lit.node;
2020
if let pushed_path = Path::new(path_lit.as_str());
2121
if let Some(pushed_path_lit) = pushed_path.to_str();

clippy_lints/src/methods/seek_from_current.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn arg_is_seek_from_current<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
3838
match_def_path(cx, def_id, &paths::STD_IO_SEEK_FROM_CURRENT) {
3939
// check if argument of `SeekFrom::Current` is `0`
4040
if args.len() == 1 &&
41-
let ExprKind::Lit(ref lit) = args[0].kind &&
41+
let ExprKind::Lit(lit) = args[0].kind &&
4242
let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node {
4343
return true
4444
}

clippy_lints/src/methods/seek_to_start_instead_of_rewind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(super) fn check<'tcx>(
3030
let Some(def_id) = cx.qpath_res(path, func.hir_id).opt_def_id() &&
3131
match_def_path(cx, def_id, &paths::STD_IO_SEEKFROM_START) &&
3232
args1.len() == 1 &&
33-
let ExprKind::Lit(ref lit) = args1[0].kind &&
33+
let ExprKind::Lit(lit) = args1[0].kind &&
3434
let LitKind::Int(0, LitIntType::Unsuffixed) = lit.node
3535
{
3636
let method_call_span = expr.span.with_lo(name_span.lo());

clippy_lints/src/methods/unnecessary_fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(super) fn check(
7878
}
7979

8080
// Check if the first argument to .fold is a suitable literal
81-
if let hir::ExprKind::Lit(ref lit) = init.kind {
81+
if let hir::ExprKind::Lit(lit) = init.kind {
8282
match lit.node {
8383
ast::LitKind::Bool(false) => check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Or, "any", true),
8484
ast::LitKind::Bool(true) => check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::And, "all", true),

clippy_lints/src/needless_bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ fn fetch_bool_block(expr: &Expr<'_>) -> Option<Expression> {
369369
}
370370

371371
fn fetch_bool_expr(expr: &Expr<'_>) -> Option<bool> {
372-
if let ExprKind::Lit(ref lit_ptr) = peel_blocks(expr).kind {
372+
if let ExprKind::Lit(lit_ptr) = peel_blocks(expr).kind {
373373
if let LitKind::Bool(value) = lit_ptr.node {
374374
return Some(value);
375375
}

clippy_lints/src/needless_parens_on_range_literals.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ fn snippet_enclosed_in_parenthesis(snippet: &str) -> bool {
4949

5050
fn check_for_parens(cx: &LateContext<'_>, e: &Expr<'_>, is_start: bool) {
5151
if is_start &&
52-
let ExprKind::Lit(ref literal) = e.kind &&
52+
let ExprKind::Lit(literal) = e.kind &&
5353
let ast::LitKind::Float(_sym, ast::LitFloatType::Unsuffixed) = literal.node
5454
{
5555
// don't check floating point literals on the start expression of a range
5656
return;
5757
}
5858
if_chain! {
59-
if let ExprKind::Lit(ref literal) = e.kind;
59+
if let ExprKind::Lit(literal) = e.kind;
6060
// the indicator that parenthesis surround the literal is that the span of the expression and the literal differ
6161
if (literal.span.data().hi - literal.span.data().lo) != (e.span.data().hi - e.span.data().lo);
6262
// inspect the source code of the expression for parenthesis

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
122122

123123
let sized_trait = need!(cx.tcx.lang_items().sized_trait());
124124

125-
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds().iter())
125+
let preds = traits::elaborate(cx.tcx, cx.param_env.caller_bounds().iter())
126126
.filter(|p| !p.is_global())
127127
.filter_map(|pred| {
128128
// Note that we do not want to deal with qualified predicates here.

clippy_lints/src/neg_multiply.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for NegMultiply {
5454

5555
fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) {
5656
if_chain! {
57-
if let ExprKind::Lit(ref l) = lit.kind;
57+
if let ExprKind::Lit(l) = lit.kind;
5858
if consts::lit_to_mir_constant(&l.node, cx.typeck_results().expr_ty_opt(lit)) == Constant::Int(1);
5959
if cx.typeck_results().expr_ty(exp).is_integral();
6060

clippy_lints/src/non_copy_const.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,9 @@ fn is_value_unfrozen_poly<'tcx>(cx: &LateContext<'tcx>, body_id: BodyId, ty: Ty<
196196
fn is_value_unfrozen_expr<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId, def_id: DefId, ty: Ty<'tcx>) -> bool {
197197
let substs = cx.typeck_results().node_substs(hir_id);
198198

199-
let result = cx.tcx.const_eval_resolve(
200-
cx.param_env,
201-
mir::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs),
202-
None,
203-
);
199+
let result = cx
200+
.tcx
201+
.const_eval_resolve(cx.param_env, mir::UnevaluatedConst::new(def_id, substs), None);
204202
is_value_unfrozen_raw(cx, result, ty)
205203
}
206204

clippy_lints/src/operators/arithmetic_side_effects.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl ArithmeticSideEffects {
110110
/// like `i32::MAX` or constant references like `N` from `const N: i32 = 1;`,
111111
fn literal_integer(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<u128> {
112112
let actual = peel_hir_expr_unary(expr).0;
113-
if let hir::ExprKind::Lit(ref lit) = actual.kind && let ast::LitKind::Int(n, _) = lit.node {
113+
if let hir::ExprKind::Lit(lit) = actual.kind && let ast::LitKind::Int(n, _) = lit.node {
114114
return Some(n)
115115
}
116116
if let Some((Constant::Int(n), _)) = constant(cx, cx.typeck_results(), expr) {

clippy_lints/src/regex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn check_regex<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) {
180180
.allow_invalid_utf8(!utf8)
181181
.build();
182182

183-
if let ExprKind::Lit(ref lit) = expr.kind {
183+
if let ExprKind::Lit(lit) = expr.kind {
184184
if let LitKind::Str(ref r, style) = lit.node {
185185
let r = r.as_str();
186186
let offset = if let StrStyle::Raw(n) = style { 2 + n } else { 1 };

clippy_lints/src/unicode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ declare_lint_pass!(Unicode => [INVISIBLE_CHARACTERS, NON_ASCII_LITERAL, UNICODE_
7676

7777
impl LateLintPass<'_> for Unicode {
7878
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
79-
if let ExprKind::Lit(ref lit) = expr.kind {
79+
if let ExprKind::Lit(lit) = expr.kind {
8080
if let LitKind::Str(_, _) | LitKind::Char(_) = lit.node {
8181
check_str(cx, lit.span, expr.hir_id);
8282
}

clippy_lints/src/utils/author.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
430430
kind!("Unary(UnOp::{op:?}, {inner})");
431431
self.expr(inner);
432432
},
433-
ExprKind::Lit(ref lit) => {
433+
ExprKind::Lit(lit) => {
434434
bind!(self, lit);
435435
kind!("Lit(ref {lit})");
436436
self.lit(lit);
@@ -558,6 +558,10 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
558558
kind!("InlineAsm(_)");
559559
out!("// unimplemented: `ExprKind::InlineAsm` is not further destructured at the moment");
560560
},
561+
ExprKind::OffsetOf(container, ref fields) => {
562+
bind!(self, container, fields);
563+
kind!("OffsetOf({container}, {fields})");
564+
},
561565
ExprKind::Struct(qpath, fields, base) => {
562566
bind!(self, qpath, fields);
563567
opt_bind!(self, base);

clippy_utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_utils"
3-
version = "0.1.70"
3+
version = "0.1.71"
44
edition = "2021"
55
publish = false
66

clippy_utils/src/check_proc_macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
117117
ExprKind::Unary(UnOp::Deref, e) => (Pat::Str("*"), expr_search_pat(tcx, e).1),
118118
ExprKind::Unary(UnOp::Not, e) => (Pat::Str("!"), expr_search_pat(tcx, e).1),
119119
ExprKind::Unary(UnOp::Neg, e) => (Pat::Str("-"), expr_search_pat(tcx, e).1),
120-
ExprKind::Lit(ref lit) => lit_search_pat(&lit.node),
120+
ExprKind::Lit(lit) => lit_search_pat(&lit.node),
121121
ExprKind::Array(_) | ExprKind::Repeat(..) => (Pat::Str("["), Pat::Str("]")),
122122
ExprKind::Call(e, []) | ExprKind::MethodCall(_, e, [], _) => (expr_search_pat(tcx, e).0, Pat::Str("(")),
123123
ExprKind::Call(first, [.., last])

clippy_utils/src/consts.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
324324
match e.kind {
325325
ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id, self.typeck_results.expr_ty(e)),
326326
ExprKind::Block(block, _) => self.block(block),
327-
ExprKind::Lit(ref lit) => {
327+
ExprKind::Lit(lit) => {
328328
if is_direct_expn_of(e.span, "cfg").is_some() {
329329
None
330330
} else {
@@ -450,11 +450,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
450450
let result = self
451451
.lcx
452452
.tcx
453-
.const_eval_resolve(
454-
self.param_env,
455-
mir::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs),
456-
None,
457-
)
453+
.const_eval_resolve(self.param_env, mir::UnevaluatedConst::new(def_id, substs), None)
458454
.ok()
459455
.map(|val| rustc_middle::mir::ConstantKind::from_value(val, ty))?;
460456
let result = miri_to_const(self.lcx.tcx, result);

clippy_utils/src/eager_or_lazy.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
218218
| ExprKind::AddrOf(..)
219219
| ExprKind::Struct(..)
220220
| ExprKind::Repeat(..)
221-
| ExprKind::Block(Block { stmts: [], .. }, _) => (),
221+
| ExprKind::Block(Block { stmts: [], .. }, _)
222+
| ExprKind::OffsetOf(..) => (),
222223

223224
// Assignment might be to a local defined earlier, so don't eagerly evaluate.
224225
// Blocks with multiple statements might be expensive, so don't eagerly evaluate.

0 commit comments

Comments
 (0)