Skip to content

Commit

Permalink
Account for API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Aug 6, 2024
1 parent 210ebe4 commit abb62ab
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/experimental/derive_opportunity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn super_traits_of(tcx: ty::TyCtxt<'_>, trait_def_id: DefId) -> impl Iterator<It

iter::from_fn(move || -> Option<DefId> {
let trait_did = stack.pop()?;
let generic_predicates = tcx.super_predicates_of(trait_did);
let generic_predicates = tcx.explicit_super_predicates_of(trait_did);

for (predicate, _) in generic_predicates.predicates {
if let ty::ClauseKind::Trait(data) = predicate.kind().skip_binder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ fn is_from_residual_or_try_implementor_method_call<'tcx>(
) -> Option<Place<'tcx>> {
if let TerminatorKind::Call { func, args, .. } = &terminator.kind
&& let Some((def_id, _)) = func.const_fn_def()
&& let [arg, ..] = args.as_slice()
&& let [arg, ..] = args.as_ref()
&& let Some(arg_place) = arg.node.place()
&& {
if cx.tcx.lang_items().from_residual_fn() == Some(def_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use rustc_middle::ty::{
use rustc_session::declare_lint_pass;
use rustc_span::symbol::sym;
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt as _;

use clippy_utils::{
get_parent_expr,
Expand Down
4 changes: 2 additions & 2 deletions examples/supplementary/commented_code/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
extern crate rustc_hir;
extern crate rustc_span;

use clippy_utils::{diagnostics::span_lint_and_help, source::get_source_text};
use clippy_utils::{diagnostics::span_lint_and_help, source::SpanRangeExt};
use once_cell::sync::Lazy;
use regex::{Captures, Regex};
use rustc_hir::Block;
Expand Down Expand Up @@ -89,7 +89,7 @@ static LINE_COMMENT: Lazy<Regex> = Lazy::new(|| Regex::new("(^|[^/])(//([^/].*))
static BLOCK_COMMENT: Lazy<Regex> = Lazy::new(|| Regex::new(r"/\*(([^*]|\*[^/])*)\*/").unwrap());

fn check_span(cx: &LateContext<'_>, span: Span) {
let Some(source_file_range) = get_source_text(cx, span) else {
let Some(source_file_range) = span.get_source_text(cx) else {
return;
};
let Some(text) = source_file_range.as_str() else {
Expand Down
2 changes: 1 addition & 1 deletion examples/supplementary/unnecessary_borrow_mut/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<'tcx> Visitor<'tcx> for V<'tcx> {
}
if let Some((def_id, _)) = func.const_fn_def()
&& self.tcx.is_diagnostic_item(sym::deref_method, def_id)
&& let [arg] = args.as_slice()
&& let [arg] = args.as_ref()
&& let Some(arg_place) = arg.node.place()
&& arg_place.as_local() == Some(self.local)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ use rustc_span::{symbol::sym, Symbol};

#[allow(clippy::too_many_lines)]
pub fn check_inherents(cx: &LateContext<'_>) {
let into_iterator_def_id =
get_trait_def_id(cx, &["core", "iter", "traits", "collect", "IntoIterator"]).unwrap();
let into_iterator_def_id = get_trait_def_id(
cx.tcx,
&["core", "iter", "traits", "collect", "IntoIterator"],
)
.unwrap();
let iterator_def_id =
get_trait_def_id(cx, &["core", "iter", "traits", "iterator", "Iterator"]).unwrap();
get_trait_def_id(cx.tcx, &["core", "iter", "traits", "iterator", "Iterator"]).unwrap();

let type_paths = type_paths();

Expand Down Expand Up @@ -62,7 +65,7 @@ pub fn check_inherents(cx: &LateContext<'_>) {

let type_path_impl_def_ids = type_paths
.iter()
.flat_map(|type_path| def_path_res(cx, type_path))
.flat_map(|type_path| def_path_res(cx.tcx, type_path))
.filter_map(|res| res.opt_def_id())
.flat_map(|def_id| cx.tcx.inherent_impls(def_id).unwrap());

Expand Down Expand Up @@ -93,7 +96,7 @@ pub fn check_inherents(cx: &LateContext<'_>) {
continue;
}

let def_id = def_path_res(cx, path)
let def_id = def_path_res(cx.tcx, path)
.into_iter()
.find_map(|res| res.opt_def_id())
.ok_or_else(|| format!("`def_path_res` failed for {path:?}"))
Expand Down Expand Up @@ -199,7 +202,7 @@ fn replace_ty_params_with_global_ty<'tcx>(
cx: &LateContext<'tcx>,
ty: ty::Ty<'tcx>,
) -> ty::Ty<'tcx> {
let global_def_id = def_path_res(cx, &["alloc", "alloc", "Global"])
let global_def_id = def_path_res(cx.tcx, &["alloc", "alloc", "Global"])
.into_iter()
.find_map(|res| res.opt_def_id())
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ fn inner_arg_implements_traits<'tcx>(
}

predicates.iter().all(|predicate| {
let predicate = EarlyBinder::bind(predicate).instantiate(cx.tcx, &substs_with_new_ty);
let predicate =
EarlyBinder::bind(predicate).instantiate(cx.tcx, substs_with_new_ty.as_slice());
let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate);
cx.tcx
.infer_ctxt()
Expand Down

0 comments on commit abb62ab

Please sign in to comment.