Auto merge of #113429 - compiler-errors:rollup-wkv4w9a, r=compiler-errors
Rollup of 8 pull requests Successful merges: - #111917 (Simplify duplicate checks for mir validator) - #112008 (Fix incorrect documented default bufsize in bufreader/writer) - #112825 (Don't call `type_of` on TAIT in defining scope in new solver) - #113164 (Add a regression test for #109054) - #113318 (Revert "alloc: Allow comparing Boxs over different allocators", add regression test) - #113397 (Prefer object candidates in new selection) - #113419 (Avoid calling item_name for RPITIT) - #113421 (Do not assert >1 RPITITs on collect_return_position_impl_trait_in_trait_tys) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
7cc3da05f9
23 changed files with 307 additions and 151 deletions
|
@ -67,8 +67,8 @@ impl<'tcx> MirPass<'tcx> for Validator {
|
||||||
unwind_edge_count: 0,
|
unwind_edge_count: 0,
|
||||||
reachable_blocks: traversal::reachable_as_bitset(body),
|
reachable_blocks: traversal::reachable_as_bitset(body),
|
||||||
storage_liveness,
|
storage_liveness,
|
||||||
place_cache: Vec::new(),
|
place_cache: FxHashSet::default(),
|
||||||
value_cache: Vec::new(),
|
value_cache: FxHashSet::default(),
|
||||||
};
|
};
|
||||||
checker.visit_body(body);
|
checker.visit_body(body);
|
||||||
checker.check_cleanup_control_flow();
|
checker.check_cleanup_control_flow();
|
||||||
|
@ -95,8 +95,8 @@ struct TypeChecker<'a, 'tcx> {
|
||||||
unwind_edge_count: usize,
|
unwind_edge_count: usize,
|
||||||
reachable_blocks: BitSet<BasicBlock>,
|
reachable_blocks: BitSet<BasicBlock>,
|
||||||
storage_liveness: ResultsCursor<'a, 'tcx, MaybeStorageLive<'static>>,
|
storage_liveness: ResultsCursor<'a, 'tcx, MaybeStorageLive<'static>>,
|
||||||
place_cache: Vec<PlaceRef<'tcx>>,
|
place_cache: FxHashSet<PlaceRef<'tcx>>,
|
||||||
value_cache: Vec<u128>,
|
value_cache: FxHashSet<u128>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
|
@ -951,10 +951,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
||||||
|
|
||||||
self.value_cache.clear();
|
self.value_cache.clear();
|
||||||
self.value_cache.extend(targets.iter().map(|(value, _)| value));
|
self.value_cache.extend(targets.iter().map(|(value, _)| value));
|
||||||
let all_len = self.value_cache.len();
|
let has_duplicates = targets.iter().len() != self.value_cache.len();
|
||||||
self.value_cache.sort_unstable();
|
|
||||||
self.value_cache.dedup();
|
|
||||||
let has_duplicates = all_len != self.value_cache.len();
|
|
||||||
if has_duplicates {
|
if has_duplicates {
|
||||||
self.fail(
|
self.fail(
|
||||||
location,
|
location,
|
||||||
|
@ -987,16 +984,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
||||||
// passed by a reference to the callee. Consequently they must be non-overlapping.
|
// passed by a reference to the callee. Consequently they must be non-overlapping.
|
||||||
// Currently this simply checks for duplicate places.
|
// Currently this simply checks for duplicate places.
|
||||||
self.place_cache.clear();
|
self.place_cache.clear();
|
||||||
self.place_cache.push(destination.as_ref());
|
self.place_cache.insert(destination.as_ref());
|
||||||
|
let mut has_duplicates = false;
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if let Operand::Move(place) = arg {
|
if let Operand::Move(place) = arg {
|
||||||
self.place_cache.push(place.as_ref());
|
has_duplicates |= !self.place_cache.insert(place.as_ref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let all_len = self.place_cache.len();
|
|
||||||
let mut dedup = FxHashSet::default();
|
|
||||||
self.place_cache.retain(|p| dedup.insert(*p));
|
|
||||||
let has_duplicates = all_len != self.place_cache.len();
|
|
||||||
if has_duplicates {
|
if has_duplicates {
|
||||||
self.fail(
|
self.fail(
|
||||||
location,
|
location,
|
||||||
|
|
|
@ -669,11 +669,13 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||||
)
|
)
|
||||||
.fold_with(&mut collector);
|
.fold_with(&mut collector);
|
||||||
|
|
||||||
debug_assert_ne!(
|
if !unnormalized_trait_sig.output().references_error() {
|
||||||
collector.types.len(),
|
debug_assert_ne!(
|
||||||
0,
|
collector.types.len(),
|
||||||
"expect >1 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`"
|
0,
|
||||||
);
|
"expect >1 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let trait_sig = ocx.normalize(&norm_cause, param_env, unnormalized_trait_sig);
|
let trait_sig = ocx.normalize(&norm_cause, param_env, unnormalized_trait_sig);
|
||||||
trait_sig.error_reported()?;
|
trait_sig.error_reported()?;
|
||||||
|
|
|
@ -25,9 +25,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
"impl has stricter requirements than trait"
|
"impl has stricter requirements than trait"
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(span) = self.tcx.hir().span_if_local(trait_item_def_id) {
|
if !self.tcx.is_impl_trait_in_trait(trait_item_def_id) {
|
||||||
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
|
if let Some(span) = self.tcx.hir().span_if_local(trait_item_def_id) {
|
||||||
err.span_label(span, format!("definition of `{}` from trait", item_name));
|
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
|
||||||
|
err.span_label(span, format!("definition of `{}` from trait", item_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err.span_label(error_span, format!("impl has extra requirement {}", requirement));
|
err.span_label(error_span, format!("impl has extra requirement {}", requirement));
|
||||||
|
|
|
@ -837,7 +837,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn can_define_opaque_ty(&mut self, def_id: LocalDefId) -> bool {
|
pub(super) fn can_define_opaque_ty(&self, def_id: LocalDefId) -> bool {
|
||||||
self.infcx.opaque_type_origin(def_id).is_some()
|
self.infcx.opaque_type_origin(def_id).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,10 +173,18 @@ fn candidate_should_be_dropped_in_favor_of<'tcx>(
|
||||||
victim_idx >= other_idx
|
victim_idx >= other_idx
|
||||||
}
|
}
|
||||||
(_, CandidateSource::ParamEnv(_)) => true,
|
(_, CandidateSource::ParamEnv(_)) => true,
|
||||||
|
|
||||||
|
(
|
||||||
|
CandidateSource::BuiltinImpl(BuiltinImplSource::Object),
|
||||||
|
CandidateSource::BuiltinImpl(BuiltinImplSource::Object),
|
||||||
|
) => false,
|
||||||
|
(_, CandidateSource::BuiltinImpl(BuiltinImplSource::Object)) => true,
|
||||||
|
|
||||||
(CandidateSource::Impl(victim_def_id), CandidateSource::Impl(other_def_id)) => {
|
(CandidateSource::Impl(victim_def_id), CandidateSource::Impl(other_def_id)) => {
|
||||||
tcx.specializes((other_def_id, victim_def_id))
|
tcx.specializes((other_def_id, victim_def_id))
|
||||||
&& other.result.value.certainty == Certainty::Yes
|
&& other.result.value.certainty == Certainty::Yes
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use rustc_hir::{LangItem, Movability};
|
||||||
use rustc_infer::traits::query::NoSolution;
|
use rustc_infer::traits::query::NoSolution;
|
||||||
use rustc_infer::traits::util::supertraits;
|
use rustc_infer::traits::util::supertraits;
|
||||||
use rustc_middle::traits::solve::{CanonicalResponse, Certainty, Goal, QueryResult};
|
use rustc_middle::traits::solve::{CanonicalResponse, Certainty, Goal, QueryResult};
|
||||||
|
use rustc_middle::traits::Reveal;
|
||||||
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams, TreatProjections};
|
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams, TreatProjections};
|
||||||
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt};
|
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt};
|
||||||
use rustc_middle::ty::{TraitPredicate, TypeVisitableExt};
|
use rustc_middle::ty::{TraitPredicate, TypeVisitableExt};
|
||||||
|
@ -118,6 +119,32 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't call `type_of` on a local TAIT that's in the defining scope,
|
||||||
|
// since that may require calling `typeck` on the same item we're
|
||||||
|
// currently type checking, which will result in a fatal cycle that
|
||||||
|
// ideally we want to avoid, since we can make progress on this goal
|
||||||
|
// via an alias bound or a locally-inferred hidden type instead.
|
||||||
|
//
|
||||||
|
// Also, don't call `type_of` on a TAIT in `Reveal::All` mode, since
|
||||||
|
// we already normalize the self type in
|
||||||
|
// `assemble_candidates_after_normalizing_self_ty`, and we'd
|
||||||
|
// just be registering an identical candidate here.
|
||||||
|
//
|
||||||
|
// Returning `Err(NoSolution)` here is ok in `SolverMode::Coherence`
|
||||||
|
// since we'll always be registering an ambiguous candidate in
|
||||||
|
// `assemble_candidates_after_normalizing_self_ty` due to normalizing
|
||||||
|
// the TAIT.
|
||||||
|
if let ty::Alias(ty::Opaque, opaque_ty) = goal.predicate.self_ty().kind() {
|
||||||
|
if matches!(goal.param_env.reveal(), Reveal::All)
|
||||||
|
|| opaque_ty
|
||||||
|
.def_id
|
||||||
|
.as_local()
|
||||||
|
.is_some_and(|def_id| ecx.can_define_opaque_ty(def_id))
|
||||||
|
{
|
||||||
|
return Err(NoSolution);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ecx.probe_and_evaluate_goal_for_constituent_tys(
|
ecx.probe_and_evaluate_goal_for_constituent_tys(
|
||||||
goal,
|
goal,
|
||||||
structural_traits::instantiate_constituent_tys_for_auto_trait,
|
structural_traits::instantiate_constituent_tys_for_auto_trait,
|
||||||
|
|
|
@ -1319,56 +1319,39 @@ impl Clone for Box<str> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T, A1, A2> PartialEq<Box<T, A2>> for Box<T, A1>
|
impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for Box<T, A> {
|
||||||
where
|
|
||||||
T: ?Sized + PartialEq,
|
|
||||||
A1: Allocator,
|
|
||||||
A2: Allocator,
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Box<T, A2>) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
PartialEq::eq(&**self, &**other)
|
PartialEq::eq(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ne(&self, other: &Box<T, A2>) -> bool {
|
fn ne(&self, other: &Self) -> bool {
|
||||||
PartialEq::ne(&**self, &**other)
|
PartialEq::ne(&**self, &**other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T, A1, A2> PartialOrd<Box<T, A2>> for Box<T, A1>
|
impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Box<T, A> {
|
||||||
where
|
|
||||||
T: ?Sized + PartialOrd,
|
|
||||||
A1: Allocator,
|
|
||||||
A2: Allocator,
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &Box<T, A2>) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
PartialOrd::partial_cmp(&**self, &**other)
|
PartialOrd::partial_cmp(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn lt(&self, other: &Box<T, A2>) -> bool {
|
fn lt(&self, other: &Self) -> bool {
|
||||||
PartialOrd::lt(&**self, &**other)
|
PartialOrd::lt(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn le(&self, other: &Box<T, A2>) -> bool {
|
fn le(&self, other: &Self) -> bool {
|
||||||
PartialOrd::le(&**self, &**other)
|
PartialOrd::le(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ge(&self, other: &Box<T, A2>) -> bool {
|
fn ge(&self, other: &Self) -> bool {
|
||||||
PartialOrd::ge(&**self, &**other)
|
PartialOrd::ge(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn gt(&self, other: &Box<T, A2>) -> bool {
|
fn gt(&self, other: &Self) -> bool {
|
||||||
PartialOrd::gt(&**self, &**other)
|
PartialOrd::gt(&**self, &**other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> {
|
impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub struct BufReader<R: ?Sized> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Read> BufReader<R> {
|
impl<R: Read> BufReader<R> {
|
||||||
/// Creates a new `BufReader<R>` with a default buffer capacity. The default is currently 8 KB,
|
/// Creates a new `BufReader<R>` with a default buffer capacity. The default is currently 8 KiB,
|
||||||
/// but may change in the future.
|
/// but may change in the future.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|
|
@ -81,7 +81,7 @@ pub struct BufWriter<W: ?Sized + Write> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Write> BufWriter<W> {
|
impl<W: Write> BufWriter<W> {
|
||||||
/// Creates a new `BufWriter<W>` with a default buffer capacity. The default is currently 8 KB,
|
/// Creates a new `BufWriter<W>` with a default buffer capacity. The default is currently 8 KiB,
|
||||||
/// but may change in the future.
|
/// but may change in the future.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
error[E0726]: implicit elided lifetime not allowed here
|
||||||
|
--> $DIR/return-not-existing-pair.rs:12:20
|
||||||
|
|
|
||||||
|
LL | impl<'a, 'b, T, U> MyTrait<T> for U {
|
||||||
|
| ^^^^^^^^^^ expected lifetime parameters
|
||||||
|
|
|
||||||
|
help: indicate the anonymous lifetimes
|
||||||
|
|
|
||||||
|
LL | impl<'a, 'b, T, U> MyTrait<'_, '_, T> for U {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0412]: cannot find type `ConnImpl` in this scope
|
||||||
|
--> $DIR/return-not-existing-pair.rs:8:48
|
||||||
|
|
|
||||||
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
|
||||||
|
| ^^^^^^^^ not found in this scope
|
||||||
|
|
||||||
|
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
|
||||||
|
--> $DIR/return-not-existing-pair.rs:14:5
|
||||||
|
|
|
||||||
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
|
||||||
|
| ------------------------------------------------------------ `&self` used in trait
|
||||||
|
...
|
||||||
|
LL | async fn foo(_: T) -> (&'a U, &'b T) {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/return-not-existing-pair.rs:14:42
|
||||||
|
|
|
||||||
|
LL | async fn foo(_: T) -> (&'a U, &'b T) {}
|
||||||
|
| ^^ expected `(&U, &T)`, found `()`
|
||||||
|
|
|
||||||
|
= note: expected tuple `(&'a U, &'b T)`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0186, E0308, E0412, E0726.
|
||||||
|
For more information about an error, try `rustc --explain E0186`.
|
|
@ -0,0 +1,39 @@
|
||||||
|
error[E0726]: implicit elided lifetime not allowed here
|
||||||
|
--> $DIR/return-not-existing-pair.rs:12:20
|
||||||
|
|
|
||||||
|
LL | impl<'a, 'b, T, U> MyTrait<T> for U {
|
||||||
|
| ^^^^^^^^^^ expected lifetime parameters
|
||||||
|
|
|
||||||
|
help: indicate the anonymous lifetimes
|
||||||
|
|
|
||||||
|
LL | impl<'a, 'b, T, U> MyTrait<'_, '_, T> for U {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0412]: cannot find type `ConnImpl` in this scope
|
||||||
|
--> $DIR/return-not-existing-pair.rs:8:48
|
||||||
|
|
|
||||||
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
|
||||||
|
| ^^^^^^^^ not found in this scope
|
||||||
|
|
||||||
|
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
|
||||||
|
--> $DIR/return-not-existing-pair.rs:14:5
|
||||||
|
|
|
||||||
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
|
||||||
|
| ------------------------------------------------------------ `&self` used in trait
|
||||||
|
...
|
||||||
|
LL | async fn foo(_: T) -> (&'a U, &'b T) {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/return-not-existing-pair.rs:14:42
|
||||||
|
|
|
||||||
|
LL | async fn foo(_: T) -> (&'a U, &'b T) {}
|
||||||
|
| ^^ expected `(&U, &T)`, found `()`
|
||||||
|
|
|
||||||
|
= note: expected tuple `(&'a U, &'b T)`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0186, E0308, E0412, E0726.
|
||||||
|
For more information about an error, try `rustc --explain E0186`.
|
19
tests/ui/async-await/in-trait/return-not-existing-pair.rs
Normal file
19
tests/ui/async-await/in-trait/return-not-existing-pair.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// edition:2021
|
||||||
|
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||||
|
// revisions: current next
|
||||||
|
|
||||||
|
#![feature(async_fn_in_trait)]
|
||||||
|
|
||||||
|
trait MyTrait<'a, 'b, T> {
|
||||||
|
async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
|
||||||
|
//~^ ERROR: cannot find type `ConnImpl` in this scope [E0412]
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'b, T, U> MyTrait<T> for U {
|
||||||
|
//~^ ERROR: implicit elided lifetime not allowed here [E0726]
|
||||||
|
async fn foo(_: T) -> (&'a U, &'b T) {}
|
||||||
|
//~^ ERROR: method `foo` has a `&self` declaration in the trait, but not in the impl [E0186]
|
||||||
|
//~| ERROR: mismatched types [E0308]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0412]: cannot find type `Missing` in this scope
|
||||||
|
--> $DIR/return-not-existing-type-wrapping-rpitit.rs:10:25
|
||||||
|
|
|
||||||
|
LL | fn bar() -> Wrapper<Missing<impl Sized>>;
|
||||||
|
| ^^^^^^^ not found in this scope
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0412`.
|
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0412]: cannot find type `Missing` in this scope
|
||||||
|
--> $DIR/return-not-existing-type-wrapping-rpitit.rs:10:25
|
||||||
|
|
|
||||||
|
LL | fn bar() -> Wrapper<Missing<impl Sized>>;
|
||||||
|
| ^^^^^^^ not found in this scope
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0412`.
|
|
@ -0,0 +1,20 @@
|
||||||
|
// edition:2021
|
||||||
|
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||||
|
// revisions: current next
|
||||||
|
|
||||||
|
#![feature(return_position_impl_trait_in_trait)]
|
||||||
|
|
||||||
|
struct Wrapper<T>(T);
|
||||||
|
|
||||||
|
trait Foo {
|
||||||
|
fn bar() -> Wrapper<Missing<impl Sized>>;
|
||||||
|
//~^ ERROR: cannot find type `Missing` in this scope [E0412]
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Foo for () {
|
||||||
|
fn bar() -> Wrapper<i32> {
|
||||||
|
Wrapper(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,5 +1,5 @@
|
||||||
// compile-flags: -Ztrait-solver=next
|
// compile-flags: -Ztrait-solver=next
|
||||||
// known-bug: #112825
|
// check-pass
|
||||||
|
|
||||||
// Makes sure we don't prepopulate the MIR typeck of `define`
|
// Makes sure we don't prepopulate the MIR typeck of `define`
|
||||||
// with `Foo<T, U> = T`, but instead, `Foo<B, A> = B`, so that
|
// with `Foo<T, U> = T`, but instead, `Foo<B, A> = B`, so that
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:10:24
|
|
||||||
|
|
|
||||||
LL | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: ...which requires borrow-checking `define`...
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:15:1
|
|
||||||
|
|
|
||||||
LL | fn define<A, B: Send>(a: A, b: B) {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
= note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
|
|
||||||
note: cycle used when checking item types in top-level module
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:8:1
|
|
||||||
|
|
|
||||||
LL | / #![feature(type_alias_impl_trait)]
|
|
||||||
LL | |
|
|
||||||
LL | | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | fn main() {}
|
|
||||||
| |____________^
|
|
||||||
|
|
||||||
error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:10:24
|
|
||||||
|
|
|
||||||
LL | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: ...which requires borrow-checking `define`...
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:15:1
|
|
||||||
|
|
|
||||||
LL | fn define<A, B: Send>(a: A, b: B) {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
= note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
|
|
||||||
note: cycle used when checking item types in top-level module
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:8:1
|
|
||||||
|
|
|
||||||
LL | / #![feature(type_alias_impl_trait)]
|
|
||||||
LL | |
|
|
||||||
LL | | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | fn main() {}
|
|
||||||
| |____________^
|
|
||||||
|
|
||||||
error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:10:24
|
|
||||||
|
|
|
||||||
LL | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: ...which requires borrow-checking `define`...
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:15:1
|
|
||||||
|
|
|
||||||
LL | fn define<A, B: Send>(a: A, b: B) {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
= note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
|
|
||||||
note: cycle used when checking item types in top-level module
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:8:1
|
|
||||||
|
|
|
||||||
LL | / #![feature(type_alias_impl_trait)]
|
|
||||||
LL | |
|
|
||||||
LL | | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | fn main() {}
|
|
||||||
| |____________^
|
|
||||||
|
|
||||||
error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:10:24
|
|
||||||
|
|
|
||||||
LL | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: ...which requires borrow-checking `define`...
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:15:1
|
|
||||||
|
|
|
||||||
LL | fn define<A, B: Send>(a: A, b: B) {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
= note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
|
|
||||||
note: cycle used when checking item types in top-level module
|
|
||||||
--> $DIR/dont-remap-tait-substs.rs:8:1
|
|
||||||
|
|
|
||||||
LL | / #![feature(type_alias_impl_trait)]
|
|
||||||
LL | |
|
|
||||||
LL | | type Foo<T: Send, U> = impl NeedsSend<T>;
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | fn main() {}
|
|
||||||
| |____________^
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0391`.
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
error[E0283]: type annotations needed: cannot satisfy `Foo: Send`
|
||||||
|
--> $DIR/dont-type_of-tait-in-defining-scope.rs:16:5
|
||||||
|
|
|
||||||
|
LL | needs_send::<Foo>();
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: cannot satisfy `Foo: Send`
|
||||||
|
note: required by a bound in `needs_send`
|
||||||
|
--> $DIR/dont-type_of-tait-in-defining-scope.rs:13:18
|
||||||
|
|
|
||||||
|
LL | fn needs_send<T: Send>() {}
|
||||||
|
| ^^^^ required by this bound in `needs_send`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0283`.
|
|
@ -0,0 +1,22 @@
|
||||||
|
// revisions: is_send not_send
|
||||||
|
// compile-flags: -Ztrait-solver=next
|
||||||
|
//[is_send] check-pass
|
||||||
|
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
|
#[cfg(is_send)]
|
||||||
|
type Foo = impl Send;
|
||||||
|
|
||||||
|
#[cfg(not_send)]
|
||||||
|
type Foo = impl Sized;
|
||||||
|
|
||||||
|
fn needs_send<T: Send>() {}
|
||||||
|
|
||||||
|
fn test() {
|
||||||
|
needs_send::<Foo>();
|
||||||
|
//[not_send]~^ ERROR type annotations needed: cannot satisfy `Foo: Send`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _: Foo = ();
|
||||||
|
}
|
13
tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs
Normal file
13
tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// compile-flags: -Ztrait-solver=next
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
use std::any::Any;
|
||||||
|
|
||||||
|
fn needs_usize(_: &usize) {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: &dyn Any = &1usize;
|
||||||
|
if let Some(x) = x.downcast_ref::<usize>() {
|
||||||
|
needs_usize(x);
|
||||||
|
}
|
||||||
|
}
|
22
tests/ui/type-alias-impl-trait/issue-109054.rs
Normal file
22
tests/ui/type-alias-impl-trait/issue-109054.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// edition:2021
|
||||||
|
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
|
struct CallMe;
|
||||||
|
|
||||||
|
type ReturnType<'a> = impl std::future::Future<Output = u32> + 'a;
|
||||||
|
type FnType = impl Fn(&u32) -> ReturnType;
|
||||||
|
|
||||||
|
impl std::ops::Deref for CallMe {
|
||||||
|
type Target = FnType;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
fn inner(val: &u32) -> ReturnType {
|
||||||
|
async move { *val * 2 }
|
||||||
|
}
|
||||||
|
|
||||||
|
&inner //~ ERROR: expected generic lifetime parameter, found `'_`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
12
tests/ui/type-alias-impl-trait/issue-109054.stderr
Normal file
12
tests/ui/type-alias-impl-trait/issue-109054.stderr
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
error[E0792]: expected generic lifetime parameter, found `'_`
|
||||||
|
--> $DIR/issue-109054.rs:18:9
|
||||||
|
|
|
||||||
|
LL | type ReturnType<'a> = impl std::future::Future<Output = u32> + 'a;
|
||||||
|
| -- this generic parameter must be used with a generic lifetime parameter
|
||||||
|
...
|
||||||
|
LL | &inner
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0792`.
|
18
tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs
Normal file
18
tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// run-pass
|
||||||
|
// Verify that PartialEq implementations do not break type inference when
|
||||||
|
// accepting types with different allocators
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let boxed: Vec<Box<i32>> = vec![];
|
||||||
|
assert_eq!(boxed, vec![]);
|
||||||
|
|
||||||
|
let rc: Vec<Rc<i32>> = vec![];
|
||||||
|
assert_eq!(rc, vec![]);
|
||||||
|
|
||||||
|
let arc: Vec<Arc<i32>> = vec![];
|
||||||
|
assert_eq!(arc, vec![]);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue