Rollup merge of #132090 - compiler-errors:baily, r=lcnr

Stop being so bail-y in candidate assembly

A conceptual follow-up to #132084. We gotta stop bailing so much when there are errors; it's both unnecessary, leads to weird knock-on errors, and it's messing up the vibes lol
This commit is contained in:
Michael Goulet 2024-11-22 21:07:38 -05:00 committed by GitHub
commit 5a0086f351
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 328 additions and 240 deletions

View file

@ -91,14 +91,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} else if tcx.is_lang_item(def_id, LangItem::Sized) {
// Sized is never implementable by end-users, it is
// always automatically computed.
// FIXME: Consider moving this check to the top level as it
// may also be useful for predicates other than `Sized`
// Error type cannot possibly implement `Sized` (fixes #123154)
if let Err(e) = obligation.predicate.skip_binder().self_ty().error_reported() {
return Err(SelectionError::Overflow(e.into()));
}
let sized_conditions = self.sized_conditions(obligation);
self.assemble_builtin_bound_candidates(sized_conditions, &mut candidates);
} else if tcx.is_lang_item(def_id, LangItem::Unsize) {
@ -230,13 +222,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
) -> Result<(), SelectionError<'tcx>> {
debug!(?stack.obligation);
// An error type will unify with anything. So, avoid
// matching an error type with `ParamCandidate`.
// This helps us avoid spurious errors like issue #121941.
if stack.obligation.predicate.references_error() {
return Ok(());
}
let bounds = stack
.obligation
.param_env
@ -563,19 +548,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation: &PolyTraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>,
) {
// Essentially any user-written impl will match with an error type,
// so creating `ImplCandidates` isn't useful. However, we might
// end up finding a candidate elsewhere (e.g. a `BuiltinCandidate` for `Sized`)
// This helps us avoid overflow: see issue #72839
// Since compilation is already guaranteed to fail, this is just
// to try to show the 'nicest' possible errors to the user.
// We don't check for errors in the `ParamEnv` - in practice,
// it seems to cause us to be overly aggressive in deciding
// to give up searching for candidates, leading to spurious errors.
if obligation.predicate.references_error() {
return;
}
let drcx = DeepRejectCtxt::relate_rigid_infer(self.tcx());
let obligation_args = obligation.predicate.skip_binder().trait_ref.args;
self.tcx().for_each_relevant_impl(

View file

@ -2487,10 +2487,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
if trait_ref.references_error() {
return Err(());
}
debug!(?impl_trait_header);
let Normalized { value: impl_trait_ref, obligations: mut nested_obligations } =

View file

@ -6,8 +6,7 @@ use rustc_index::bit_set::BitSet;
use rustc_middle::bug;
use rustc_middle::query::Providers;
use rustc_middle::ty::{
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
TypeVisitor, Upcast,
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, Upcast,
};
use rustc_span::DUMMY_SP;
use rustc_span::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
@ -95,9 +94,6 @@ fn adt_sized_constraint<'tcx>(
let tail_ty = tcx.type_of(tail_def.did).instantiate_identity();
let constraint_ty = sized_constraint_for_ty(tcx, tail_ty)?;
if let Err(guar) = constraint_ty.error_reported() {
return Some(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
}
// perf hack: if there is a `constraint_ty: Sized` bound, then we know
// that the type is sized and do not need to check it on the impl.

View file

@ -1,17 +0,0 @@
//@ known-bug: #124350
struct Node<const D: usize> {}
impl Node<D>
where
SmallVec<{ D * 2 }>:,
{
fn new() -> Self {
let mut node = Node::new();
(&a, 0)();
node
}
}
struct SmallVec<T1, T2> {}

View file

@ -1,26 +0,0 @@
//@ known-bug: rust-lang/rust#125758
#![feature(impl_trait_in_assoc_type)]
trait Trait: Sized {
type Assoc2;
}
impl Trait for Bar {
type Assoc2 = impl std::fmt::Debug;
}
struct Foo {
field: <Bar as Trait>::Assoc2,
}
enum Bar {
C = 42,
D = 99,
}
static BAR: u8 = 42;
static FOO2: (&Foo, &<Bar as Trait>::Assoc2) =
unsafe { (std::mem::transmute(&BAR), std::mem::transmute(&BAR)) };
fn main() {}

View file

@ -1,17 +0,0 @@
//@ known-bug: #127351
#![feature(lazy_type_alias)]
#![allow(incomplete_features)]
struct Outer0<'a, T>(ExplicitTypeOutlives<'a, T>);
type ExplicitTypeOutlives<'a, T: 'a> = (&'a (), T);
pub struct Warns {
_significant_drop: ExplicitTypeOutlives,
field: String,
}
pub fn test(w: Warns) {
_ = || drop(w.field);
}
fn main() {}

View file

@ -1,18 +0,0 @@
//@ known-bug: #127353
#![feature(type_alias_impl_trait)]
trait Trait<T> {}
type Alias<'a, U> = impl Trait<U>;
fn f<'a>() -> Alias<'a, ()> {}
pub enum UninhabitedVariants {
Tuple(Alias),
}
struct A;
fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A {
match x {}
}
fn main() {}

View file

@ -1,11 +0,0 @@
//@ known-bug: #127742
struct Vtable(dyn Cap); // missing lifetime
trait Cap<'a> {}
union Transmute {
t: u64, // ICEs with u64, u128, or usize. Correctly errors with u32.
u: &'static Vtable,
}
const G: &'static Vtable = unsafe { Transmute { t: 1 }.u };

View file

@ -6,7 +6,7 @@ struct Vtable(dyn Cap);
trait Cap<'a> {}
union Transmute {
t: u64,
t: u128,
u: &'static Vtable,
}

View file

@ -0,0 +1,18 @@
// regression test for #124350
struct Node<const D: usize> {}
impl<const D: usize> Node<D>
where
SmallVec<{ D * 2 }>:,
//~^ ERROR generic parameters may not be used in const operations
//~| ERROR constant provided when a type was expected
{
fn new() -> Self {
Node::new()
}
}
struct SmallVec<T1>(T1);
fn main() {}

View file

@ -0,0 +1,18 @@
error: generic parameters may not be used in const operations
--> $DIR/bad-multiply.rs:7:16
|
LL | SmallVec<{ D * 2 }>:,
| ^ cannot perform const operation using `D`
|
= help: const parameters may only be used as standalone arguments, i.e. `D`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0747]: constant provided when a type was expected
--> $DIR/bad-multiply.rs:7:14
|
LL | SmallVec<{ D * 2 }>:,
| ^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0747`.

View file

@ -20,5 +20,4 @@ pub fn remove_key<K, S: SubsetExcept<K>>() -> S {
fn main() {
let map: KeyHolder<0> = remove_key::<_, _>();
//~^ ERROR: the trait bound `KeyHolder<0>: SubsetExcept<_>` is not satisfied
}

View file

@ -14,26 +14,6 @@ LL | impl<K> ContainsKey<K> for KeyHolder<K> {}
| |
| help: consider changing this type parameter to a const parameter: `const K: u8`
error[E0277]: the trait bound `KeyHolder<0>: SubsetExcept<_>` is not satisfied
--> $DIR/kind_mismatch.rs:22:45
|
LL | let map: KeyHolder<0> = remove_key::<_, _>();
| ^ the trait `ContainsKey<0>` is not implemented for `KeyHolder<0>`
|
note: required for `KeyHolder<0>` to implement `SubsetExcept<_>`
--> $DIR/kind_mismatch.rs:15:28
|
LL | impl<P, T: ContainsKey<0>> SubsetExcept<P> for T {}
| -------------- ^^^^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required by a bound in `remove_key`
--> $DIR/kind_mismatch.rs:17:25
|
LL | pub fn remove_key<K, S: SubsetExcept<K>>() -> S {
| ^^^^^^^^^^^^^^^ required by this bound in `remove_key`
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0747.
For more information about an error, try `rustc --explain E0277`.
For more information about this error, try `rustc --explain E0747`.

View file

@ -16,6 +16,8 @@ struct Holder<B> {
fn main() {
Holder {
inner: Box::new(()), //~ ERROR: the trait `Provider` cannot be made into an object
inner: Box::new(()),
//~^ ERROR: the trait `Provider` cannot be made into an object
//~| ERROR: the trait `Provider` cannot be made into an object
};
}

View file

@ -80,7 +80,24 @@ LL | type A<'a>;
= help: consider moving `A` to another trait
= help: only type `()` implements the trait, consider using it directly instead
error: aborting due to 5 previous errors
error[E0038]: the trait `Provider` cannot be made into an object
--> $DIR/issue-71176.rs:19:16
|
LL | inner: Box::new(()),
| ^^^^^^^^^^^^ `Provider` cannot be made into an object
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-71176.rs:2:10
|
LL | trait Provider {
| -------- this trait cannot be made into an object...
LL | type A<'a>;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= note: required for the cast from `Box<()>` to `Box<(dyn Provider<A<'_> = _> + 'static), {type error}>`
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.

View file

@ -1,3 +1,5 @@
//@ normalize-stderr-test: "\d+ bits" -> "$$BITS bits"
// Regression test for issue #124031
// Checks that we don't ICE when the tail
// of an ADT has a type error
@ -16,5 +18,6 @@ struct Other {
fn main() {
unsafe {
std::mem::transmute::<Option<()>, Option<&Other>>(None);
//~^ ERROR cannot transmute between types of different sizes
}
}

View file

@ -1,5 +1,5 @@
error[E0046]: not all trait items implemented, missing: `RefTarget`
--> $DIR/ice-type-error-in-tail-124031.rs:9:1
--> $DIR/ice-type-error-in-tail-124031.rs:11:1
|
LL | type RefTarget;
| -------------- `RefTarget` from trait
@ -7,6 +7,16 @@ LL | type RefTarget;
LL | impl Trait for () {}
| ^^^^^^^^^^^^^^^^^ missing `RefTarget` in implementation
error: aborting due to 1 previous error
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/ice-type-error-in-tail-124031.rs:20:9
|
LL | std::mem::transmute::<Option<()>, Option<&Other>>(None);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `Option<()>` ($BITS bits)
= note: target type: `Option<&Other>` ($BITS bits)
For more information about this error, try `rustc --explain E0046`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0046, E0512.
For more information about an error, try `rustc --explain E0046`.

View file

@ -0,0 +1,18 @@
// regression test for #127351
#![feature(lazy_type_alias)]
//~^ WARN the feature `lazy_type_alias` is incomplete
type ExplicitTypeOutlives<T> = T;
pub struct Warns {
_significant_drop: ExplicitTypeOutlives,
//~^ ERROR missing generics for type alias `ExplicitTypeOutlives`
field: String,
}
pub fn test(w: Warns) {
let _ = || drop(w.field);
}
fn main() {}

View file

@ -0,0 +1,28 @@
warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/bad-lazy-type-alias.rs:3:12
|
LL | #![feature(lazy_type_alias)]
| ^^^^^^^^^^^^^^^
|
= note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0107]: missing generics for type alias `ExplicitTypeOutlives`
--> $DIR/bad-lazy-type-alias.rs:9:24
|
LL | _significant_drop: ExplicitTypeOutlives,
| ^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
|
note: type alias defined here, with 1 generic parameter: `T`
--> $DIR/bad-lazy-type-alias.rs:6:6
|
LL | type ExplicitTypeOutlives<T> = T;
| ^^^^^^^^^^^^^^^^^^^^ -
help: add missing generic argument
|
LL | _significant_drop: ExplicitTypeOutlives<T>,
| +++
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0107`.

View file

@ -11,5 +11,4 @@ impl Lt<'missing> for () { //~ ERROR undeclared lifetime
fn main() {
let _: <() as Lt<'_>>::T = &();
//~^ ERROR the trait bound `(): Lt<'_>` is not satisfied
}

View file

@ -21,13 +21,6 @@ help: consider introducing lifetime `'missing` here
LL | impl<'missing> Lt<'missing> for () {
| ++++++++++
error[E0277]: the trait bound `(): Lt<'_>` is not satisfied
--> $DIR/region-error-ice-109072.rs:13:13
|
LL | let _: <() as Lt<'_>>::T = &();
| ^^ the trait `Lt<'_>` is not implemented for `()`
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0261, E0277.
For more information about an error, try `rustc --explain E0261`.
For more information about this error, try `rustc --explain E0261`.

View file

@ -17,7 +17,6 @@ impl<T, D> MyTrait<T> for D {
}
impl<T> MyTrait<T> for BadStruct {
//~^ ERROR: conflicting implementations of trait `MyTrait<_>` for type `BadStruct`
fn foo() {}
}

View file

@ -4,16 +4,6 @@ error[E0412]: cannot find type `MissingType` in this scope
LL | err: MissingType
| ^^^^^^^^^^^ not found in this scope
error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `BadStruct`
--> $DIR/issue-68830-spurious-diagnostics.rs:19:1
|
LL | impl<T, D> MyTrait<T> for D {
| --------------------------- first implementation here
...
LL | impl<T> MyTrait<T> for BadStruct {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `BadStruct`
error: aborting due to 1 previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0119, E0412.
For more information about an error, try `rustc --explain E0119`.
For more information about this error, try `rustc --explain E0412`.

View file

@ -1,5 +1,6 @@
fn function<T: PartialEq>() {
foo == 2; //~ ERROR cannot find value `foo` in this scope [E0425]
//~^ ERROR mismatched types
}
fn main() {}

View file

@ -4,6 +4,18 @@ error[E0425]: cannot find value `foo` in this scope
LL | foo == 2;
| ^^^ not found in this scope
error: aborting due to 1 previous error
error[E0308]: mismatched types
--> $DIR/dont-match-error-ty-with-calller-supplied-obligation-issue-121941.rs:2:12
|
LL | fn function<T: PartialEq>() {
| - expected this type parameter
LL | foo == 2;
| ^ expected type parameter `T`, found integer
|
= note: expected type parameter `T`
found type `{integer}`
For more information about this error, try `rustc --explain E0425`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.

View file

@ -10,5 +10,4 @@ trait X<T> {
}
trait Marker {}
impl Marker for dyn Foo {}
//~^ ERROR cannot be made into an object
fn main() {}

View file

@ -55,24 +55,6 @@ LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
= help: add `#![feature(dispatch_from_dyn)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/issue-78372.rs:12:17
|
LL | fn foo(self: Smaht<Self, T>);
| -------------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self`
...
LL | impl Marker for dyn Foo {}
| ^^^^^^^ `Foo` cannot be made into an object
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-78372.rs:9:18
|
LL | trait Foo: X<u32> {}
| --- this trait cannot be made into an object...
LL | trait X<T> {
LL | fn foo(self: Smaht<Self, T>);
| ^^^^^^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
error[E0307]: invalid `self` parameter type: `Smaht<Self, T>`
--> $DIR/issue-78372.rs:9:18
|
@ -88,7 +70,7 @@ error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion
LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0038, E0307, E0378, E0412, E0658.
For more information about an error, try `rustc --explain E0038`.
Some errors have detailed explanations: E0307, E0378, E0412, E0658.
For more information about an error, try `rustc --explain E0307`.

View file

@ -10,6 +10,7 @@ fn w<'a, T: 'a, F: Fn(&'a T)>() {
let b: &dyn FromResidual = &();
//~^ ERROR: the trait `FromResidual` cannot be made into an object
//~| ERROR: the trait `FromResidual` cannot be made into an object
//~| ERROR: the trait `FromResidual` cannot be made into an object
}
fn main() {}

View file

@ -6,6 +6,29 @@ LL | let b: &dyn FromResidual = &();
|
= note: it cannot use `Self` as a type parameter in a supertrait or `where`-clause
error[E0038]: the trait `FromResidual` cannot be made into an object
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:32
|
LL | let b: &dyn FromResidual = &();
| ^^^ `FromResidual` cannot be made into an object
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:2:8
|
LL | trait FromResidual<R = <Self as Try>::Residual> {
| ------------ this trait cannot be made into an object...
LL | fn from_residual(residual: R) -> Self;
| ^^^^^^^^^^^^^ ...because associated function `from_residual` has no `self` parameter
= note: required for the cast from `&()` to `&dyn FromResidual<{type error}>`
help: consider turning `from_residual` into a method by giving it a `&self` argument
|
LL | fn from_residual(&self, residual: R) -> Self;
| ++++++
help: alternatively, consider constraining `from_residual` so it does not apply to trait objects
|
LL | fn from_residual(residual: R) -> Self where Self: Sized;
| +++++++++++++++++
error[E0038]: the trait `FromResidual` cannot be made into an object
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:12
|
@ -28,6 +51,6 @@ help: alternatively, consider constraining `from_residual` so it does not apply
LL | fn from_residual(residual: R) -> Self where Self: Sized;
| +++++++++++++++++
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0038`.

View file

@ -6,8 +6,7 @@ impl<'a> Bar for Foo<'f> { //~ ERROR undeclared lifetime
type Type = u32;
}
fn test() //~ ERROR the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
//~| ERROR the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
fn test()
where
for<'a> <Foo<'a> as Bar>::Type: Sized,
{

View file

@ -6,22 +6,6 @@ LL | impl<'a> Bar for Foo<'f> {
| |
| help: consider introducing lifetime `'f` here: `'f,`
error[E0277]: the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
--> $DIR/span-bug-issue-121414.rs:9:1
|
LL | / fn test()
LL | |
LL | | where
LL | | for<'a> <Foo<'a> as Bar>::Type: Sized,
| |__________________________________________^ the trait `for<'a> Bar` is not implemented for `Foo<'a>`
error: aborting due to 1 previous error
error[E0277]: the trait bound `for<'a> Foo<'a>: Bar` is not satisfied
--> $DIR/span-bug-issue-121414.rs:9:4
|
LL | fn test()
| ^^^^ the trait `for<'a> Bar` is not implemented for `Foo<'a>`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0261, E0277.
For more information about an error, try `rustc --explain E0261`.
For more information about this error, try `rustc --explain E0261`.

View file

@ -0,0 +1,21 @@
// regression test for #127353
#![feature(type_alias_impl_trait)]
trait Trait<T> {}
type Alias<'a, U> = impl Trait<U>;
//~^ ERROR unconstrained opaque type
pub enum UninhabitedVariants {
Tuple(Alias),
//~^ ERROR missing lifetime specifier
//~| ERROR missing generics
//~| ERROR non-defining opaque type use in defining scope
}
fn uwu(x: UninhabitedVariants) {
//~^ ERROR item does not constrain
match x {}
//~^ ERROR non-exhaustive patterns
}
fn main() {}

View file

@ -0,0 +1,86 @@
error[E0106]: missing lifetime specifier
--> $DIR/bad-tait-no-substs.rs:9:11
|
LL | Tuple(Alias),
| ^^^^^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
LL ~ pub enum UninhabitedVariants<'a> {
LL ~ Tuple(Alias<'a>),
|
error[E0107]: missing generics for type alias `Alias`
--> $DIR/bad-tait-no-substs.rs:9:11
|
LL | Tuple(Alias),
| ^^^^^ expected 1 generic argument
|
note: type alias defined here, with 1 generic parameter: `U`
--> $DIR/bad-tait-no-substs.rs:5:6
|
LL | type Alias<'a, U> = impl Trait<U>;
| ^^^^^ -
help: add missing generic argument
|
LL | Tuple(Alias<U>),
| +++
error[E0792]: non-defining opaque type use in defining scope
--> $DIR/bad-tait-no-substs.rs:9:11
|
LL | Tuple(Alias),
| ^^^^^ argument `'_` is not a generic parameter
|
note: for this opaque type
--> $DIR/bad-tait-no-substs.rs:5:21
|
LL | type Alias<'a, U> = impl Trait<U>;
| ^^^^^^^^^^^^^
error: item does not constrain `Alias::{opaque#0}`, but has it in its signature
--> $DIR/bad-tait-no-substs.rs:15:4
|
LL | fn uwu(x: UninhabitedVariants) {
| ^^^
|
= note: consider moving the opaque type's declaration and defining uses into a separate module
note: this opaque type is in the signature
--> $DIR/bad-tait-no-substs.rs:5:21
|
LL | type Alias<'a, U> = impl Trait<U>;
| ^^^^^^^^^^^^^
error: unconstrained opaque type
--> $DIR/bad-tait-no-substs.rs:5:21
|
LL | type Alias<'a, U> = impl Trait<U>;
| ^^^^^^^^^^^^^
|
= note: `Alias` must be used in combination with a concrete type within the same module
error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` not covered
--> $DIR/bad-tait-no-substs.rs:17:11
|
LL | match x {}
| ^ pattern `UninhabitedVariants::Tuple(_)` not covered
|
note: `UninhabitedVariants` defined here
--> $DIR/bad-tait-no-substs.rs:8:10
|
LL | pub enum UninhabitedVariants {
| ^^^^^^^^^^^^^^^^^^^
LL | Tuple(Alias),
| ----- not covered
= note: the matched value is of type `UninhabitedVariants`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match x {
LL + UninhabitedVariants::Tuple(_) => todo!(),
LL + }
|
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0004, E0106, E0107, E0792.
For more information about an error, try `rustc --explain E0004`.

View file

@ -0,0 +1,22 @@
// regression test for rust-lang/rust#125758
#![feature(impl_trait_in_assoc_type)]
trait Trait {
type Assoc2;
}
struct Bar;
impl Trait for Bar {
type Assoc2 = impl std::fmt::Debug;
//~^ ERROR unconstrained opaque type
}
struct Foo {
field: <Bar as Trait>::Assoc2,
}
static BAR: u8 = 42;
static FOO2: &Foo = unsafe { std::mem::transmute(&BAR) };
fn main() {}

View file

@ -0,0 +1,10 @@
error: unconstrained opaque type
--> $DIR/bad-transmute-itiat.rs:11:19
|
LL | type Assoc2 = impl std::fmt::Debug;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `Assoc2` must be used in combination with a concrete type within the same impl
error: aborting due to 1 previous error

View file

@ -1,8 +1,11 @@
//@ known-bug: #130956
// Regression test for #130956
#![feature(type_alias_impl_trait)]
mod impl_trait_mod {
use super::*;
pub type OpaqueBlock = impl Trait;
//~^ ERROR unconstrained opaque type
pub type OpaqueIf = impl Trait;
pub struct BlockWrapper(OpaqueBlock);

View file

@ -0,0 +1,10 @@
error: unconstrained opaque type
--> $DIR/drop-analysis-on-unconstrained-tait.rs:7:28
|
LL | pub type OpaqueBlock = impl Trait;
| ^^^^^^^^^^
|
= note: `OpaqueBlock` must be used in combination with a concrete type within the same module
error: aborting due to 1 previous error

View file

@ -14,5 +14,4 @@ impl Trait for Ref {} //~ ERROR: implicit elided lifetime not allowed here
extern "C" {
pub fn repro(_: Wrapper<Ref>);
//~^ ERROR the trait bound `Ref<'_>: Trait` is not satisfied
}

View file

@ -9,19 +9,6 @@ help: indicate the anonymous lifetime
LL | impl Trait for Ref<'_> {}
| ++++
error[E0277]: the trait bound `Ref<'_>: Trait` is not satisfied
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:21
|
LL | pub fn repro(_: Wrapper<Ref>);
| ^^^^^^^^^^^^ the trait `Trait` is not implemented for `Ref<'_>`
|
note: required by a bound in `Wrapper`
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:8:23
|
LL | pub struct Wrapper<T: Trait>(T);
| ^^^^^ required by this bound in `Wrapper`
error: aborting due to 1 previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0726.
For more information about an error, try `rustc --explain E0277`.
For more information about this error, try `rustc --explain E0726`.