Use tcx.require_lang_item
instead of unwrapping
This commit is contained in:
parent
0f7d81754d
commit
b80356a5ab
9 changed files with 14 additions and 12 deletions
|
@ -2293,7 +2293,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// Given a `ty`, return whether it's an `impl Future<...>`.
|
||||
pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool {
|
||||
let ty::Opaque(def_id, _) = ty.kind() else { return false };
|
||||
let future_trait = self.lang_items().future_trait().unwrap();
|
||||
let future_trait = self.require_lang_item(LangItem::Future, None);
|
||||
|
||||
self.explicit_item_bounds(def_id).iter().any(|(predicate, _)| {
|
||||
let ty::PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder() else {
|
||||
|
|
|
@ -11,6 +11,7 @@ use rustc_hir as hir;
|
|||
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
||||
use rustc_hir::def_id::{DefId, DefIdSet, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData};
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_session::config::TrimmedDefPaths;
|
||||
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
|
||||
use rustc_session::Limit;
|
||||
|
@ -889,7 +890,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
// Group the return ty with its def id, if we had one.
|
||||
entry
|
||||
.return_ty
|
||||
.map(|ty| (tcx.lang_items().fn_once_output().unwrap(), ty)),
|
||||
.map(|ty| (tcx.require_lang_item(LangItem::FnOnce, None), ty)),
|
||||
);
|
||||
}
|
||||
if let Some(trait_ref) = entry.fn_mut_trait_ref {
|
||||
|
|
|
@ -17,6 +17,7 @@ use rustc_data_structures::captures::Captures;
|
|||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
@ -2108,7 +2109,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
|
||||
ty::Str | ty::Slice(_) => (tcx.types.usize, false),
|
||||
ty::Dynamic(..) => {
|
||||
let dyn_metadata = tcx.lang_items().dyn_metadata().unwrap();
|
||||
let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, None);
|
||||
(tcx.bound_type_of(dyn_metadata).subst(tcx, &[tail.into()]), false)
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue