From e4bafa2b8cd02aad4077ed34be29dd8fddbbefed Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Sun, 10 Mar 2024 20:24:00 +0100 Subject: [PATCH] fix metadata for dyn-star in new solver --- .../src/solve/normalizes_to/mod.rs | 5 +++-- tests/ui/dyn-star/thin.next.stderr | 11 +++++++++++ tests/ui/dyn-star/thin.old.stderr | 11 +++++++++++ tests/ui/dyn-star/thin.rs | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/ui/dyn-star/thin.next.stderr create mode 100644 tests/ui/dyn-star/thin.old.stderr create mode 100644 tests/ui/dyn-star/thin.rs diff --git a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs index ed839d14dc7..a45c1c34410 100644 --- a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs @@ -542,13 +542,14 @@ fn consider_builtin_pointee_candidate( | ty::Coroutine(..) | ty::CoroutineWitness(..) | ty::Never - | ty::Foreign(..) => tcx.types.unit, + | ty::Foreign(..) + | ty::Dynamic(_, _, ty::DynStar) => tcx.types.unit, ty::Error(e) => Ty::new_error(tcx, *e), ty::Str | ty::Slice(_) => tcx.types.usize, - ty::Dynamic(_, _, _) => { + ty::Dynamic(_, _, ty::Dyn) => { let dyn_metadata = tcx.require_lang_item(LangItem::DynMetadata, None); tcx.type_of(dyn_metadata) .instantiate(tcx, &[ty::GenericArg::from(goal.predicate.self_ty())]) diff --git a/tests/ui/dyn-star/thin.next.stderr b/tests/ui/dyn-star/thin.next.stderr new file mode 100644 index 00000000000..ef251062afc --- /dev/null +++ b/tests/ui/dyn-star/thin.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/thin.rs:6:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #102425 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/dyn-star/thin.old.stderr b/tests/ui/dyn-star/thin.old.stderr new file mode 100644 index 00000000000..ef251062afc --- /dev/null +++ b/tests/ui/dyn-star/thin.old.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/thin.rs:6:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #102425 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/dyn-star/thin.rs b/tests/ui/dyn-star/thin.rs new file mode 100644 index 00000000000..6df70f560de --- /dev/null +++ b/tests/ui/dyn-star/thin.rs @@ -0,0 +1,16 @@ +//@check-pass +//@revisions: old next +//@[next] compile-flags: -Znext-solver + +#![feature(ptr_metadata)] +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +use std::fmt::Debug; +use std::ptr::Thin; + +fn check_thin() {} + +fn main() { + check_thin::(); +}