Rollup merge of #148290 - oli-obk:push-qwxvxyopypry, r=nnethercote

Do not emit solver errors that contain error types

any follow-up errors are going to either be duplicates or often disappear if the error itself is fixed.

in this PR it mostly silences dyn-compat errors as all the other errors are already deduplicated outside of the test suite. The dyn compat errors are independent errors and I think if the dyn compatiblity depended on an error type it would not actually show, so this is PR is actually silencing independent errors, too.

I am opening this PR because I am seeing lots of `{type error}: const Trait` errors when adding more const checking. So instead of targetting just those specific errors, I wanted to try out fully avoiding such errors near the trait solver.

cc ````@rust-lang/types```` for thoughts
This commit is contained in:
Matthias Krüger 2025-11-02 09:10:38 +01:00 committed by GitHub
commit 844a41903e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 35 additions and 670 deletions

View file

@ -2,6 +2,7 @@
use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage};
use rustc_data_structures::undo_log::Rollback;
use rustc_macros::TypeVisitable;
use rustc_middle::traits::EvaluationResult;
use rustc_middle::ty;
use tracing::{debug, info};
@ -12,7 +13,7 @@ use crate::infer::snapshot::undo_log::InferCtxtUndoLogs;
pub(crate) type UndoLog<'tcx> =
snapshot_map::UndoLog<ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>>;
#[derive(Clone)]
#[derive(Clone, TypeVisitable)]
pub struct MismatchedProjectionTypes<'tcx> {
pub err: ty::error::TypeError<'tcx>,
}

View file

@ -20,7 +20,7 @@ use rustc_infer::traits::{
PredicateObligation, SelectionError,
};
use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt as _};
use rustc_span::{DesugaringKind, ErrorGuaranteed, ExpnKind, Span};
use tracing::{info, instrument};
@ -253,7 +253,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
for from_expansion in [false, true] {
for (error, suppressed) in iter::zip(&errors, &is_suppressed) {
if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion {
if !suppressed
&& error.obligation.cause.span.from_expansion() == from_expansion
&& !error.references_error()
{
let guar = self.report_fulfillment_error(error);
self.infcx.set_tainted_by_errors(guar);
reported = Some(guar);

View file

@ -29,6 +29,7 @@ use std::ops::ControlFlow;
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::DefKind;
pub use rustc_infer::traits::*;
use rustc_macros::TypeVisitable;
use rustc_middle::query::Providers;
use rustc_middle::span_bug;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
@ -75,7 +76,7 @@ use crate::infer::{InferCtxt, TyCtxtInferExt};
use crate::regions::InferCtxtRegionExt;
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
#[derive(Debug)]
#[derive(Debug, TypeVisitable)]
pub struct FulfillmentError<'tcx> {
pub obligation: PredicateObligation<'tcx>,
pub code: FulfillmentErrorCode<'tcx>,
@ -107,7 +108,7 @@ impl<'tcx> FulfillmentError<'tcx> {
}
}
#[derive(Clone)]
#[derive(Clone, TypeVisitable)]
pub enum FulfillmentErrorCode<'tcx> {
/// Inherently impossible to fulfill; this trait is implemented if and only
/// if it is already implemented.

View file

@ -4,8 +4,3 @@ trait X {
fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
//~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR trait `X` is not dyn compatible

View file

@ -28,87 +28,6 @@ note: associated type defined here, with 0 generic parameters
LL | type Y<'a>;
| ^
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn f<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {}
| +++
error: aborting due to 2 previous errors
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn f<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {}
| +++
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/invalid_const_in_lifetime_position.rs:4:20
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0107`.

View file

@ -9,11 +9,6 @@ const _: () = {
fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
//~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR `X` is not dyn compatible
};
fn main() {}

View file

@ -28,87 +28,6 @@ note: associated type defined here, with 0 generic parameters
LL | type Y<'a>;
| ^
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/issue-102768.rs:9:30
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-102768.rs:5:10
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn f2<'a>(arg: Box<dyn X<Y<'_, 1> = &'a ()>>) {}
| +++
error: aborting due to 2 previous errors
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/issue-102768.rs:9:30
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/issue-102768.rs:5:10
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/issue-102768.rs:9:30
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-102768.rs:5:10
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn f2<'a>(arg: Box<dyn X<Y<'_, 1> = &'a ()>>) {}
| +++
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/issue-102768.rs:9:30
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/issue-102768.rs:5:10
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/issue-102768.rs:9:24
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/issue-102768.rs:5:10
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0107`.

View file

@ -6,7 +6,4 @@ fn main() {
fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
//~^ ERROR: use of undeclared lifetime name `'x`
//~| ERROR: binding for associated type `Y` references lifetime
//~| ERROR: binding for associated type `Y` references lifetime
//~| ERROR: binding for associated type `Y` references lifetime
//~| ERROR: the trait `X` is not dyn compatible
}

View file

@ -20,39 +20,7 @@ error[E0582]: binding for associated type `Y` references lifetime `'a`, which do
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^^^^^^^^^^^^^^^^
error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:33
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:33
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:19
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:2:8
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'x>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0038, E0261, E0582.
For more information about an error, try `rustc --explain E0038`.
Some errors have detailed explanations: E0261, E0582.
For more information about an error, try `rustc --explain E0261`.

View file

@ -7,19 +7,10 @@ fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
//~| ERROR: parenthesized generic arguments cannot be used
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR at least one trait is required
//~| ERROR: the trait `X` is not dyn compatible
fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
//~^ ERROR: parenthesized generic arguments cannot be used
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR: the trait `X` is not dyn compatible
fn main() {}

View file

@ -22,7 +22,7 @@ LL + fn foo<'a>(arg: Box<dyn X<Y<'a> = &'a ()>>) {}
|
error: parenthesized generic arguments cannot be used in associated type constraints
--> $DIR/gat-trait-path-parenthesised-args.rs:18:27
--> $DIR/gat-trait-path-parenthesised-args.rs:12:27
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^--
@ -60,93 +60,7 @@ LL | type Y<'a>;
| ^
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn foo<'a>(arg: Box<dyn X<Y('_, 'a) = &'a ()>>) {}
| +++
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^---- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn foo<'a>(arg: Box<dyn X<Y('_, 'a) = &'a ()>>) {}
| +++
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^---- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0224]: at least one trait is required for an object type
--> $DIR/gat-trait-path-parenthesised-args.rs:5:29
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/gat-trait-path-parenthesised-args.rs:5:21
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:18:27
--> $DIR/gat-trait-path-parenthesised-args.rs:12:27
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^ expected 1 lifetime argument
@ -161,57 +75,6 @@ help: add missing lifetime argument
LL | fn bar<'a>(arg: Box<dyn X<Y('_) = ()>>) {}
| ++
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:18:27
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn bar<'a>(arg: Box<dyn X<Y('_) = ()>>) {}
| ++
error: aborting due to 6 previous errors
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:18:27
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn bar<'a>(arg: Box<dyn X<Y('_) = ()>>) {}
| ++
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/gat-trait-path-parenthesised-args.rs:18:21
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error: aborting due to 15 previous errors
Some errors have detailed explanations: E0038, E0107, E0224.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0107`.

View file

@ -5,6 +5,5 @@ trait X {
fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
//~^ ERROR: use of undeclared lifetime name `'a`
//~| ERROR: use of undeclared lifetime name `'a`
//~| ERROR: the trait `X` is not dyn compatible [E0038]
fn main() {}

View file

@ -29,23 +29,6 @@ help: consider introducing lifetime `'a` here
LL | fn f<'a>(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ++++
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/issue-67510.rs:5:13
|
LL | fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/issue-67510.rs:2:10
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0261.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0261`.

View file

@ -9,14 +9,10 @@ impl Provider for () {
struct Holder<B> {
inner: Box<dyn Provider<A = B>>,
//~^ ERROR: missing generics for associated type
//~| ERROR: missing generics for associated type
//~| ERROR: missing generics for associated type
//~| ERROR: the trait `Provider` is not dyn compatible
}
fn main() {
Holder {
inner: Box::new(()),
//~^ ERROR: the trait `Provider` is not dyn compatible
};
}

View file

@ -14,75 +14,6 @@ help: add missing lifetime argument
LL | inner: Box<dyn Provider<A<'a> = B>>,
| ++++
error[E0107]: missing generics for associated type `Provider::A`
--> $DIR/issue-71176.rs:10:27
|
LL | inner: Box<dyn Provider<A = B>>,
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-71176.rs:2:10
|
LL | type A<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | inner: Box<dyn Provider<A<'a> = B>>,
| ++++
error: aborting due to 1 previous error
error[E0107]: missing generics for associated type `Provider::A`
--> $DIR/issue-71176.rs:10:27
|
LL | inner: Box<dyn Provider<A = B>>,
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-71176.rs:2:10
|
LL | type A<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | inner: Box<dyn Provider<A<'a> = B>>,
| ++++
error[E0038]: the trait `Provider` is not dyn compatible
--> $DIR/issue-71176.rs:10:14
|
LL | inner: Box<dyn Provider<A = B>>,
| ^^^^^^^^^^^^^^^^^^^ `Provider` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/issue-71176.rs:2:10
|
LL | trait Provider {
| -------- this trait is not dyn compatible...
LL | type A<'a>;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: only type `()` implements `Provider`; consider using it directly instead.
error[E0038]: the trait `Provider` is not dyn compatible
--> $DIR/issue-71176.rs:19:16
|
LL | inner: Box::new(()),
| ^^^^^^^^^^^^ `Provider` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/issue-71176.rs:2:10
|
LL | trait Provider {
| -------- this trait is not dyn compatible...
LL | type A<'a>;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: only type `()` implements `Provider`; consider using it directly instead.
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0107`.

View file

@ -10,9 +10,6 @@ struct Foo<'a, 'b, 'c> {
fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
//~^ ERROR missing generics for associated type
//~| ERROR missing generics for associated type
//~| ERROR missing generics for associated type
//~| ERROR the trait `X` is not dyn compatible
fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {}
//~^ ERROR struct takes 3 lifetime arguments but 2 lifetime

View file

@ -14,58 +14,8 @@ help: add missing lifetime arguments
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'_, '_> = (&'c u32, &'d u32)>>) {}
| ++++++++
error[E0107]: missing generics for associated type `X::Y`
--> $DIR/missing_lifetime_args.rs:11:32
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
| ^ expected 2 lifetime arguments
|
note: associated type defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/missing_lifetime_args.rs:2:10
|
LL | type Y<'a, 'b>;
| ^ -- --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime arguments
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'_, '_> = (&'c u32, &'d u32)>>) {}
| ++++++++
error[E0107]: missing generics for associated type `X::Y`
--> $DIR/missing_lifetime_args.rs:11:32
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
| ^ expected 2 lifetime arguments
|
note: associated type defined here, with 2 lifetime parameters: `'a`, `'b`
--> $DIR/missing_lifetime_args.rs:2:10
|
LL | type Y<'a, 'b>;
| ^ -- --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime arguments
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'_, '_> = (&'c u32, &'d u32)>>) {}
| ++++++++
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/missing_lifetime_args.rs:11:26
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/missing_lifetime_args.rs:2:10
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'a, 'b>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error[E0107]: struct takes 3 lifetime arguments but 2 lifetime arguments were supplied
--> $DIR/missing_lifetime_args.rs:17:26
--> $DIR/missing_lifetime_args.rs:14:26
|
LL | fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {}
| ^^^ -- -- supplied 2 lifetime arguments
@ -83,7 +33,7 @@ LL | fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b, 'a>) {}
| ++++
error[E0107]: struct takes 3 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/missing_lifetime_args.rs:20:16
--> $DIR/missing_lifetime_args.rs:17:16
|
LL | fn f<'a>(_arg: Foo<'a>) {}
| ^^^ -- supplied 1 lifetime argument
@ -100,7 +50,6 @@ help: add missing lifetime arguments
LL | fn f<'a>(_arg: Foo<'a, 'a, 'a>) {}
| ++++++++
error: aborting due to 6 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0107`.

View file

@ -6,11 +6,6 @@ const _: () = {
fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
//~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR the trait `X` is not dyn compatible
};
fn main() {}

View file

@ -28,87 +28,6 @@ note: associated type defined here, with 0 generic parameters
LL | type Y<'a>;
| ^
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/trait-path-type-error-once-implemented.rs:6:29
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/trait-path-type-error-once-implemented.rs:2:10
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn f2<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {}
| +++
error: aborting due to 2 previous errors
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/trait-path-type-error-once-implemented.rs:6:29
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/trait-path-type-error-once-implemented.rs:2:10
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/trait-path-type-error-once-implemented.rs:6:29
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/trait-path-type-error-once-implemented.rs:2:10
|
LL | type Y<'a>;
| ^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | fn f2<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {}
| +++
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/trait-path-type-error-once-implemented.rs:6:29
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/trait-path-type-error-once-implemented.rs:2:10
|
LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/trait-path-type-error-once-implemented.rs:6:23
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/trait-path-type-error-once-implemented.rs:2:10
|
LL | trait X {
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0107`.

View file

@ -8,8 +8,6 @@ static FOO: (dyn AsRef<OsStr>, u8) = ("hello", 42);
const BAR: (&Path, [u8], usize) = ("hello", [], 42);
//~^ ERROR cannot find type `Path` in this scope
//~| ERROR the size for values of type `[u8]` cannot be known at compilation time
//~| ERROR the size for values of type `[u8]` cannot be known at compilation time
//~| ERROR mismatched types
static BAZ: ([u8], usize) = ([], 0);

View file

@ -21,16 +21,7 @@ LL + use std::path::Path;
|
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/issue-84108.rs:9:12
|
LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42);
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= note: only the last element of a tuple may have a dynamically sized type
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/issue-84108.rs:15:13
--> $DIR/issue-84108.rs:13:13
|
LL | static BAZ: ([u8], usize) = ([], 0);
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@ -38,16 +29,6 @@ LL | static BAZ: ([u8], usize) = ([], 0);
= help: the trait `Sized` is not implemented for `[u8]`
= note: only the last element of a tuple may have a dynamically sized type
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/issue-84108.rs:9:12
|
LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42);
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= note: only the last element of a tuple may have a dynamically sized type
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0308]: mismatched types
--> $DIR/issue-84108.rs:9:45
|
@ -57,7 +38,7 @@ LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42);
= note: expected slice `[u8]`
found array `[_; 0]`
error: aborting due to 6 previous errors
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0308, E0412.
For more information about an error, try `rustc --explain E0277`.

View file

@ -18,7 +18,5 @@ impl<T> Overlap<T> for T {}
impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T> {}
//~^ ERROR cannot find type `Missing` in this scope
//~| ERROR the trait bound `T: Overlap<for<'a> fn(Assoc<'a, T>)>` is not satisfied
//~| ERROR the trait bound `for<'a> *const T: ToUnit<'a>` is not satisfied
fn main() {}

View file

@ -26,30 +26,7 @@ LL | trait ToUnit<'a> {
| ^^^^^^^^^^^^^^^^
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a)), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), .. }
error[E0277]: the trait bound `for<'a> *const T: ToUnit<'a>` is not satisfied
--> $DIR/issue-118950-root-region.rs:19:9
|
LL | impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `*const T`
|
help: this trait has no implementations, consider adding one
--> $DIR/issue-118950-root-region.rs:8:1
|
LL | trait ToUnit<'a> {
| ^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `T: Overlap<for<'a> fn(Assoc<'a, T>)>` is not satisfied
--> $DIR/issue-118950-root-region.rs:19:47
|
LL | impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T> {}
| ^ the trait `Overlap<for<'a> fn(Assoc<'a, T>)>` is not implemented for `T`
|
help: consider further restricting type parameter `T` with trait `Overlap`
|
LL | impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T>, T: Overlap<for<'a> fn(Assoc<'a, T>)> {}
| ++++++++++++++++++++++++++++++++++++++
error: aborting due to 4 previous errors; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0277, E0412.
For more information about an error, try `rustc --explain E0277`.

View file

@ -6,7 +6,6 @@ mod assert {
pub fn is_transmutable<Src, const ASSUME_ALIGNMENT: bool>()
where
Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope
//~| ERROR the constant `ASSUME_ALIGNMENT` is not of type `Assume`
{
}
}

View file

@ -4,15 +4,6 @@ error[E0412]: cannot find type `Dst` in this scope
LL | Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>,
| ^^^ not found in this scope
error: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
--> $DIR/issue-101739-1.rs:8:14
|
LL | Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
note: required by a const generic parameter in `TransmuteFrom`
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
error: aborting due to 2 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0412`.