Skip to content

Commit

Permalink
Check pointee metadata correctly in ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 30, 2023
1 parent f5c78c4 commit 321a5db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_trait_selection/src/solve/project_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
LangItem::Sized,
[ty::GenericArg::from(goal.predicate.self_ty())],
));

ecx.add_goal(goal.with(tcx, sized_predicate));
ecx.eq(goal.param_env, goal.predicate.term, tcx.types.unit.into())?;
return ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
tcx.types.unit
}

ty::Adt(def, substs) if def.is_struct() => {
Expand Down
18 changes: 8 additions & 10 deletions tests/ui/traits/new-solver/pointee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ use std::ptr::{DynMetadata, Pointee};
trait Trait<U> {}
struct MyDst<T: ?Sized>(T);

fn works<T>() {
let _: <T as Pointee>::Metadata = ();
let _: <[T] as Pointee>::Metadata = 1_usize;
let _: <str as Pointee>::Metadata = 1_usize;
let _: <dyn Trait<T> as Pointee>::Metadata = give::<DynMetadata<dyn Trait<T>>>();
let _: <MyDst<T> as Pointee>::Metadata = ();
let _: <((((([u8],),),),),) as Pointee>::Metadata = 1_usize;
}
fn meta_is<T: Pointee<Metadata = U> + ?Sized, U>() {}

fn give<U>() -> U {
loop {}
fn works<T>() {
meta_is::<T, ()>();
meta_is::<[T], usize>();
meta_is::<str, usize>();
meta_is::<dyn Trait<T>, DynMetadata<dyn Trait<T>>>();
meta_is::<MyDst<T>, ()>();
meta_is::<((((([u8],),),),),), usize>();
}

fn main() {}

0 comments on commit 321a5db

Please sign in to comment.