Skip to content

Commit 57130ef

Browse files
Fast path for sized pred
1 parent 9e31dcb commit 57130ef

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,9 +1883,9 @@ impl<'tcx> Ty<'tcx> {
18831883
// Needs normalization or revealing to determine, so no is the safe answer.
18841884
ty::Alias(..) => false,
18851885

1886-
ty::Param(..) | ty::Infer(..) | ty::Error(..) => false,
1886+
ty::Param(..) | ty::Placeholder(..) | ty::Infer(..) | ty::Error(..) => false,
18871887

1888-
ty::Bound(..) | ty::Placeholder(..) => {
1888+
ty::Bound(..) => {
18891889
bug!("`is_trivially_pure_clone_copy` applied to unexpected type: {:?}", self);
18901890
}
18911891
}

compiler/rustc_trait_selection/src/solve/delegate.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ops::Deref;
22

33
use rustc_data_structures::fx::FxHashSet;
4+
use rustc_hir::LangItem;
45
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
56
use rustc_infer::infer::canonical::query_response::make_query_region_constraints;
67
use rustc_infer::infer::canonical::{
@@ -82,6 +83,21 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
8283

8384
Some(())
8485
}
86+
ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => {
87+
match self.0.tcx.as_lang_item(trait_pred.def_id()) {
88+
Some(LangItem::Sized)
89+
if trait_pred.self_ty().is_trivially_sized(self.0.tcx) =>
90+
{
91+
Some(())
92+
}
93+
Some(LangItem::Copy | LangItem::Clone)
94+
if trait_pred.self_ty().is_trivially_pure_clone_copy() =>
95+
{
96+
Some(())
97+
}
98+
_ => None,
99+
}
100+
}
85101
_ => None,
86102
}
87103
}

0 commit comments

Comments
 (0)