Skip to content

Rustup #12921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Jun 13, 2024
Merged

Rustup #12921

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7f66e56
Don't require `visit_body` to take a lifetime that must outlive the f…
oli-obk May 29, 2024
f44a6a7
Make `body_owned_by` return the body directly.
oli-obk May 29, 2024
d38920f
ast: Revert a breaking attribute visiting order change
petrochenkov May 29, 2024
8299d49
Auto merge of #125711 - oli-obk:const_block_ice2, r=Nadrieril
bors May 30, 2024
e2e5731
Rollup merge of #125711 - oli-obk:const_block_ice2, r=Nadrieril
matthiaskrgr May 30, 2024
f67f726
Merge commit 'c9139bd546d9cd69df817faeab62c5f9b1a51337' into clippy-s…
flip1995 May 30, 2024
b7a6c2d
Auto merge of #125761 - matthiaskrgr:rollup-7u082og, r=matthiaskrgr
bors May 30, 2024
51347ba
Auto merge of #125764 - flip1995:clippy-subtree-update, r=Manishearth
bors May 30, 2024
040edea
Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup
fmease May 27, 2024
febfa51
Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constrain…
matthiaskrgr May 31, 2024
2334264
Deduplicate supertrait_def_ids code
Mark-Simulacrum Apr 27, 2024
5a44877
Uplift TypeRelation and Relate
compiler-errors May 31, 2024
ab45660
Auto merge of #125775 - compiler-errors:uplift-closure-args, r=lcnr
bors Jun 1, 2024
e94779a
Opt-in diagnostics reporting to avoid doing extra work in the new solver
compiler-errors Jun 1, 2024
9f4a2dd
Align Term methods with GenericArg methods
compiler-errors May 30, 2024
537ce5c
Handle safety keyword for extern block inner items
spastorino May 23, 2024
bd0f908
Add safe/unsafe to static inside extern blocks
spastorino May 7, 2024
e8d02fe
Make top-level `rustc_parse` functions fallible.
nnethercote May 31, 2024
38de6e1
Misc fixes to cranelift/clippy/miri
BoxyUwU Jun 4, 2024
ea13653
Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk
bors Jun 6, 2024
c245cde
Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"
lqd Jun 6, 2024
16fcbd2
Auto merge of #126068 - lqd:revert-124976, r=petrochenkov
bors Jun 6, 2024
5ea5f63
Revert "Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs…
lqd Jun 6, 2024
246d4fe
bless `std_instead_of_core`
slanterns Jun 7, 2024
3e43cfc
Rollup merge of #126101 - lqd:revert-124099, r=wesleywiser
workingjubilee Jun 7, 2024
abd0116
Revert "Create const block DefIds in typeck instead of ast lowering"
oli-obk Jun 3, 2024
127f3e1
Auto merge of #125918 - oli-obk:const_block_ice, r=compiler-errors
bors Jun 7, 2024
fe6f332
Rollup merge of #125951 - slanterns:error_in_core_stabilization, r=Am…
fmease Jun 8, 2024
5acc25e
Update `icu4x` dependencies
clubby789 Jun 8, 2024
8c1f953
ScalarInt: size mismatches are a bug, do not delay the panic
RalfJung Jun 8, 2024
35f54fd
Rollup merge of #126159 - RalfJung:scalarint-size-mismatch, r=oli-obk
matthiaskrgr Jun 10, 2024
cc63143
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jun 13, 2024
614966b
Bump Clippy version -> 0.1.81
flip1995 Jun 13, 2024
89658ef
Bump nightly version -> 2024-06-13
flip1995 Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.1.80"
version = "0.1.81"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion clippy_config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy_config"
version = "0.1.80"
version = "0.1.81"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy_lints"
version = "0.1.80"
version = "0.1.81"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/default_numeric_fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare_clippy_lint! {
declare_lint_pass!(DefaultNumericFallback => [DEFAULT_NUMERIC_FALLBACK]);

impl<'tcx> LateLintPass<'tcx> for DefaultNumericFallback {
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
let hir = cx.tcx.hir();
let is_parent_const = matches!(
hir.body_const_context(hir.body_owner_def_id(body.id())),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
}
}

fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
fn check_body_post(&mut self, cx: &LateContext<'tcx>, body: &Body<'_>) {
if Some(body.id()) == self.current_body {
for pat in self.ref_locals.drain(..).filter_map(|(_, x)| x) {
let replacements = pat.replacements;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/doc/needless_doctest_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::HumanEmitter;
use rustc_errors::{Diag, DiagCtxt};
use rustc_lint::LateContext;
use rustc_parse::maybe_new_parser_from_source_str;
use rustc_parse::new_parser_from_source_str;
use rustc_parse::parser::ForceCollect;
use rustc_session::parse::ParseSess;
use rustc_span::edition::Edition;
Expand Down Expand Up @@ -50,7 +50,7 @@ pub fn check(
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let psess = ParseSess::with_dcx(dcx, sm);

let mut parser = match maybe_new_parser_from_source_str(&psess, filename, code) {
let mut parser = match new_parser_from_source_str(&psess, filename, code) {
Ok(p) => p,
Err(errs) => {
errs.into_iter().for_each(Diag::cancel);
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, Saf
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{
self, Binder, ClosureArgs, ClosureKind, FnSig, GenericArg, GenericArgKind, List, Region, RegionKind, Ty,
self, Binder, ClosureArgs, ClosureKind, FnSig, GenericArg, GenericArgKind, List, Region, RegionKind, Ty, TyCtxt,
TypeVisitableExt, TypeckResults,
};
use rustc_session::declare_lint_pass;
Expand Down Expand Up @@ -251,7 +251,7 @@ fn check_inputs(
})
}

fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure: ClosureArgs<'tcx>, call_sig: FnSig<'_>) -> bool {
fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure: ClosureArgs<TyCtxt<'tcx>>, call_sig: FnSig<'_>) -> bool {
call_sig.safety == Safety::Safe
&& !has_late_bound_to_non_late_bound_regions(
cx.tcx.signature_unclosure(closure.sig(), Safety::Safe).skip_binder(),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
let send_trait = cx.tcx.get_diagnostic_item(sym::Send).unwrap();
let span = decl.output.span();
let infcx = cx.tcx.infer_ctxt().build();
let ocx = ObligationCtxt::new(&infcx);
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
let cause = traits::ObligationCause::misc(span, fn_def_id);
ocx.register_bound(cause, cx.param_env, ret_ty, send_trait);
let send_errors = ocx.select_all_or_error();
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/implicit_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl<'a, 'b, 'tcx> ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
type NestedFilter = nested_filter::OnlyBodies;

fn visit_body(&mut self, body: &'tcx Body<'_>) {
fn visit_body(&mut self, body: &Body<'tcx>) {
let old_maybe_typeck_results = self.maybe_typeck_results.replace(self.cx.tcx.typeck_body(body.id()));
walk_body(self, body);
self.maybe_typeck_results = old_maybe_typeck_results;
Expand Down
58 changes: 29 additions & 29 deletions clippy_lints/src/implied_bounds_in_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use clippy_utils::source::snippet;
use rustc_errors::{Applicability, SuggestionStyle};
use rustc_hir::def_id::DefId;
use rustc_hir::{
GenericArg, GenericBound, GenericBounds, ItemKind, PredicateOrigin, TraitBoundModifier, TyKind, TypeBinding,
WherePredicate,
AssocItemConstraint, GenericArg, GenericBound, GenericBounds, ItemKind, PredicateOrigin, TraitBoundModifier,
TyKind, WherePredicate,
};
use rustc_hir_analysis::lower_ty;
use rustc_lint::{LateContext, LateLintPass};
Expand Down Expand Up @@ -54,9 +54,9 @@ fn emit_lint(
poly_trait: &rustc_hir::PolyTraitRef<'_>,
bounds: GenericBounds<'_>,
index: usize,
// The bindings that were implied, used for suggestion purposes since removing a bound with associated types
// means we might need to then move it to a different bound
implied_bindings: &[TypeBinding<'_>],
// The constraints that were implied, used for suggestion purposes since removing a bound with
// associated types means we might need to then move it to a different bound.
implied_constraints: &[AssocItemConstraint<'_>],
bound: &ImplTraitBound<'_>,
) {
let implied_by = snippet(cx, bound.span, "..");
Expand All @@ -83,46 +83,46 @@ fn emit_lint(

let mut sugg = vec![(implied_span_extended, String::new())];

// We also might need to include associated type binding that were specified in the implied bound,
// but omitted in the implied-by bound:
// We also might need to include associated item constraints that were specified in the implied
// bound, but omitted in the implied-by bound:
// `fn f() -> impl Deref<Target = u8> + DerefMut`
// If we're going to suggest removing `Deref<..>`, we'll need to put `<Target = u8>` on `DerefMut`
let omitted_assoc_tys: Vec<_> = implied_bindings
let omitted_constraints: Vec<_> = implied_constraints
.iter()
.filter(|binding| !bound.bindings.iter().any(|b| b.ident == binding.ident))
.filter(|constraint| !bound.constraints.iter().any(|c| c.ident == constraint.ident))
.collect();

if !omitted_assoc_tys.is_empty() {
// `<>` needs to be added if there aren't yet any generic arguments or bindings
let needs_angle_brackets = bound.args.is_empty() && bound.bindings.is_empty();
let insert_span = match (bound.args, bound.bindings) {
([.., arg], [.., binding]) => arg.span().max(binding.span).shrink_to_hi(),
if !omitted_constraints.is_empty() {
// `<>` needs to be added if there aren't yet any generic arguments or constraints
let needs_angle_brackets = bound.args.is_empty() && bound.constraints.is_empty();
let insert_span = match (bound.args, bound.constraints) {
([.., arg], [.., constraint]) => arg.span().max(constraint.span).shrink_to_hi(),
([.., arg], []) => arg.span().shrink_to_hi(),
([], [.., binding]) => binding.span.shrink_to_hi(),
([], [.., constraint]) => constraint.span.shrink_to_hi(),
([], []) => bound.span.shrink_to_hi(),
};

let mut associated_tys_sugg = if needs_angle_brackets {
let mut constraints_sugg = if needs_angle_brackets {
"<".to_owned()
} else {
// If angle brackets aren't needed (i.e., there are already generic arguments or bindings),
// If angle brackets aren't needed (i.e., there are already generic arguments or constraints),
// we need to add a comma:
// `impl A<B, C >`
// ^ if we insert `Assoc=i32` without a comma here, that'd be invalid syntax:
// `impl A<B, C Assoc=i32>`
", ".to_owned()
};

for (index, binding) in omitted_assoc_tys.into_iter().enumerate() {
for (index, constraint) in omitted_constraints.into_iter().enumerate() {
if index > 0 {
associated_tys_sugg += ", ";
constraints_sugg += ", ";
}
associated_tys_sugg += &snippet(cx, binding.span, "..");
constraints_sugg += &snippet(cx, constraint.span, "..");
}
if needs_angle_brackets {
associated_tys_sugg += ">";
constraints_sugg += ">";
}
sugg.push((insert_span, associated_tys_sugg));
sugg.push((insert_span, constraints_sugg));
}

diag.multipart_suggestion_with_style(
Expand Down Expand Up @@ -229,8 +229,8 @@ struct ImplTraitBound<'tcx> {
trait_def_id: DefId,
/// The generic arguments on the `impl Trait` bound
args: &'tcx [GenericArg<'tcx>],
/// The associated types on this bound
bindings: &'tcx [TypeBinding<'tcx>],
/// The associated item constraints of this bound
constraints: &'tcx [AssocItemConstraint<'tcx>],
}

/// Given an `impl Trait` type, gets all the supertraits from each bound ("implied bounds").
Expand All @@ -253,7 +253,7 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds
Some(ImplTraitBound {
predicates,
args: path.args.map_or([].as_slice(), |p| p.args),
bindings: path.args.map_or([].as_slice(), |p| p.bindings),
constraints: path.args.map_or([].as_slice(), |p| p.constraints),
trait_def_id,
span: bound.span(),
})
Expand Down Expand Up @@ -310,20 +310,20 @@ fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) {
if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound
&& let [.., path] = poly_trait.trait_ref.path.segments
&& let implied_args = path.args.map_or([].as_slice(), |a| a.args)
&& let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings)
&& let implied_constraints = path.args.map_or([].as_slice(), |a| a.constraints)
&& let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id()
&& let Some(bound) = find_bound_in_supertraits(cx, def_id, implied_args, &supertraits)
// If the implied bound has a type binding that also exists in the implied-by trait,
// then we shouldn't lint. See #11880 for an example.
&& let assocs = cx.tcx.associated_items(bound.trait_def_id)
&& !implied_bindings.iter().any(|binding| {
&& !implied_constraints.iter().any(|constraint| {
assocs
.filter_by_name_unhygienic(binding.ident.name)
.filter_by_name_unhygienic(constraint.ident.name)
.next()
.is_some_and(|assoc| assoc.kind == ty::AssocKind::Type)
})
{
emit_lint(cx, poly_trait, bounds, index, implied_bindings, bound);
emit_lint(cx, poly_trait, bounds, index, implied_constraints, bound);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/large_const_arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
&& generics.params.is_empty() && !generics.has_where_clause_predicates
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
&& let ty::Array(element_type, cst) = ty.kind()
&& let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind()
&& let Ok(element_count) = element_count.try_to_target_usize(cx.tcx)
&& let ConstKind::Value(_, ty::ValTree::Leaf(element_count)) = cst.kind()
&& let element_count = element_count.to_target_usize(cx.tcx)
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
&& self.maximum_allowed_size < u128::from(element_count) * u128::from(element_size)
{
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/large_stack_arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
if let ExprKind::Repeat(_, _) | ExprKind::Array(_) = expr.kind
&& !self.is_from_vec_macro(cx, expr.span)
&& let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind()
&& let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind()
&& let Ok(element_count) = element_count.try_to_target_usize(cx.tcx)
&& let ConstKind::Value(_, ty::ValTree::Leaf(element_count)) = cst.kind()
&& let element_count = element_count.to_target_usize(cx.tcx)
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
&& !cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| {
matches!(
Expand Down
19 changes: 7 additions & 12 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir::def_id::{DefId, DefIdSet};
use rustc_hir::{
AssocItemKind, BinOpKind, Expr, ExprKind, FnRetTy, GenericArg, GenericBound, ImplItem, ImplItemKind,
ImplicitSelfKind, Item, ItemKind, Mutability, Node, OpaqueTyOrigin, PatKind, PathSegment, PrimTy, QPath,
TraitItemRef, TyKind, TypeBindingKind,
TraitItemRef, TyKind,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, AssocKind, FnSig, Ty};
Expand Down Expand Up @@ -253,7 +253,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
// fill the set with current and super traits
fn fill_trait_set(traitt: DefId, set: &mut DefIdSet, cx: &LateContext<'_>) {
if set.insert(traitt) {
for supertrait in rustc_trait_selection::traits::supertrait_def_ids(cx.tcx, traitt) {
for supertrait in cx.tcx.supertrait_def_ids(traitt) {
fill_trait_set(supertrait, set, cx);
}
}
Expand Down Expand Up @@ -307,17 +307,12 @@ fn extract_future_output<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<&
&& let [GenericBound::Trait(trait_ref, _)] = &opaque.bounds
&& let Some(segment) = trait_ref.trait_ref.path.segments.last()
&& let Some(generic_args) = segment.args
&& generic_args.bindings.len() == 1
&& let TypeBindingKind::Equality {
term:
rustc_hir::Term::Ty(rustc_hir::Ty {
kind: TyKind::Path(QPath::Resolved(_, path)),
..
}),
} = &generic_args.bindings[0].kind
&& path.segments.len() == 1
&& let [constraint] = generic_args.constraints
&& let Some(ty) = constraint.ty()
&& let TyKind::Path(QPath::Resolved(_, path)) = ty.kind
&& let [segment] = path.segments
{
return Some(&path.segments[0]);
return Some(segment);
}

None
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/macro_metavars_in_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BodyVisitor<'a, 'tcx> {
}

impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx rustc_hir::Body<'tcx>) {
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &rustc_hir::Body<'tcx>) {
if is_lint_allowed(cx, MACRO_METAVARS_IN_UNSAFE, body.value.hir_id) {
return;
}
Expand Down
10 changes: 4 additions & 6 deletions clippy_lints/src/manual_async_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{
Block, Body, Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, FnDecl,
FnRetTy, GenericArg, GenericBound, ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind,
TypeBindingKind,
FnRetTy, GenericArg, GenericBound, ImplItem, Item, ItemKind, LifetimeName, Node, TraitRef, Ty, TyKind,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;
Expand Down Expand Up @@ -138,10 +137,9 @@ fn future_trait_ref<'tcx>(
fn future_output_ty<'tcx>(trait_ref: &'tcx TraitRef<'tcx>) -> Option<&'tcx Ty<'tcx>> {
if let Some(segment) = trait_ref.path.segments.last()
&& let Some(args) = segment.args
&& args.bindings.len() == 1
&& let binding = &args.bindings[0]
&& binding.ident.name == sym::Output
&& let TypeBindingKind::Equality { term: Term::Ty(output) } = binding.kind
&& let [constraint] = args.constraints
&& constraint.ident.name == sym::Output
&& let Some(output) = constraint.ty()
{
return Some(output);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/matches/overlapping_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>)
Some(lhs) => constant(cx, cx.typeck_results(), lhs)?,
None => {
let min_val_const = ty.numeric_min_val(cx.tcx)?;
mir_to_const(cx, mir::Const::from_ty_const(min_val_const, cx.tcx))?
mir_to_const(cx, mir::Const::from_ty_const(min_val_const, ty, cx.tcx))?
},
};
let rhs_const = match rhs {
Some(rhs) => constant(cx, cx.typeck_results(), rhs)?,
None => {
let max_val_const = ty.numeric_max_val(cx.tcx)?;
mir_to_const(cx, mir::Const::from_ty_const(max_val_const, cx.tcx))?
mir_to_const(cx, mir::Const::from_ty_const(max_val_const, ty, cx.tcx))?
},
};
let lhs_val = lhs_const.int_value(cx, ty)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn is_arg_ty_unified_in_fn<'tcx>(
cx.tcx.predicates_of(fn_id).predicates.iter().any(|(clause, _)| {
clause
.as_projection_clause()
.and_then(|p| p.map_bound(|p| p.term.ty()).transpose())
.and_then(|p| p.map_bound(|p| p.term.as_type()).transpose())
.is_some_and(|ty| ty.skip_binder() == arg_ty_in_args)
}) || fn_sig
.inputs()
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/option_map_unwrap_or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(super) fn check<'tcx>(
};

let map = cx.tcx.hir();
let body = map.body(map.body_owned_by(map.enclosing_body_owner(expr.hir_id)));
let body = map.body_owned_by(map.enclosing_body_owner(expr.hir_id));
reference_visitor.visit_body(body);

if reference_visitor.found_reference {
Expand Down
Loading