Use is_lang_item more
This commit is contained in:
parent
e08b80c0fb
commit
bac19686a5
12 changed files with 26 additions and 24 deletions
|
@ -230,8 +230,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
post_message,
|
||||
);
|
||||
|
||||
let (err_msg, safe_transmute_explanation) = if Some(main_trait_ref.def_id())
|
||||
== self.tcx.lang_items().transmute_trait()
|
||||
let (err_msg, safe_transmute_explanation) = if self.tcx.is_lang_item(main_trait_ref.def_id(), LangItem::TransmuteTrait)
|
||||
{
|
||||
// Recompute the safe transmute reason and use that for the error reporting
|
||||
match self.get_safe_transmute_error_and_reason(
|
||||
|
|
|
@ -2829,7 +2829,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
// Do not suggest relaxing if there is an explicit `Sized` obligation.
|
||||
&& !bounds.iter()
|
||||
.filter_map(|bound| bound.trait_ref())
|
||||
.any(|tr| tr.trait_def_id() == tcx.lang_items().sized_trait())
|
||||
.any(|tr| tr.trait_def_id().is_some_and(|def_id| tcx.is_lang_item(def_id, LangItem::Sized)))
|
||||
{
|
||||
let (span, separator) = if let [.., last] = bounds {
|
||||
(last.span().shrink_to_hi(), " +")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use rustc_hir::LangItem;
|
||||
use rustc_infer::traits::Obligation;
|
||||
pub use rustc_middle::traits::query::type_op::ProvePredicate;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
|
@ -20,8 +21,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
|
|||
// such cases.
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_ref)) =
|
||||
key.value.predicate.kind().skip_binder()
|
||||
&& let Some(sized_def_id) = tcx.lang_items().sized_trait()
|
||||
&& trait_ref.def_id() == sized_def_id
|
||||
&& tcx.is_lang_item(trait_ref.def_id(), LangItem::Sized)
|
||||
&& trait_ref.self_ty().is_trivially_sized(tcx)
|
||||
{
|
||||
return Some(());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue