Skip to content

Commit bd58700

Browse files
committed
Some require_lang_item -> is_lang_item replacements
1 parent 32d2385 commit bd58700

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,9 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
214214
let span = tcx.def_span(impl_did);
215215
let trait_name = "DispatchFromDyn";
216216

217-
let dispatch_from_dyn_trait = tcx.require_lang_item(LangItem::DispatchFromDyn, Some(span));
218-
219217
let source = trait_ref.self_ty();
220218
let target = {
221-
assert_eq!(trait_ref.def_id, dispatch_from_dyn_trait);
219+
assert!(tcx.is_lang_item(trait_ref.def_id, LangItem::DispatchFromDyn));
222220

223221
trait_ref.args.type_at(1)
224222
};
@@ -339,7 +337,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
339337
tcx,
340338
cause.clone(),
341339
param_env,
342-
ty::TraitRef::new(tcx, dispatch_from_dyn_trait, [ty_a, ty_b]),
340+
ty::TraitRef::new(tcx, trait_ref.def_id, [ty_a, ty_b]),
343341
));
344342
let errors = ocx.select_all_or_error();
345343
if !errors.is_empty() {

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,15 +1080,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10801080

10811081
// Check that this is a projection from the `Future` trait.
10821082
let trait_def_id = predicate.projection_term.trait_def_id(self.tcx);
1083-
let future_trait = self.tcx.require_lang_item(LangItem::Future, Some(cause_span));
1084-
if trait_def_id != future_trait {
1083+
if !self.tcx.is_lang_item(trait_def_id, LangItem::Future) {
10851084
debug!("deduce_future_output_from_projection: not a future");
10861085
return None;
10871086
}
10881087

10891088
// The `Future` trait has only one associated item, `Output`,
10901089
// so check that this is what we see.
1091-
let output_assoc_item = self.tcx.associated_item_def_ids(future_trait)[0];
1090+
let output_assoc_item = self.tcx.associated_item_def_ids(trait_def_id)[0];
10921091
if output_assoc_item != predicate.projection_term.def_id {
10931092
span_bug!(
10941093
cause_span,

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,8 +1260,7 @@ impl<'tcx> Ty<'tcx> {
12601260
return true;
12611261
};
12621262
alloc.expect_ty().ty_adt_def().is_some_and(|alloc_adt| {
1263-
let global_alloc = tcx.require_lang_item(LangItem::GlobalAlloc, None);
1264-
alloc_adt.did() == global_alloc
1263+
tcx.is_lang_item(alloc_adt.did(), LangItem::GlobalAlloc)
12651264
})
12661265
}
12671266
_ => false,

0 commit comments

Comments
 (0)