Dont create trait object if it has errors in it
This commit is contained in:
parent
898ccdb754
commit
cfa8fcbf58
14 changed files with 42 additions and 263 deletions
|
@ -8,7 +8,8 @@ use rustc_lint_defs::builtin::UNUSED_ASSOCIATED_TYPE_BOUNDS;
|
||||||
use rustc_middle::span_bug;
|
use rustc_middle::span_bug;
|
||||||
use rustc_middle::ty::fold::BottomUpFolder;
|
use rustc_middle::ty::fold::BottomUpFolder;
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable, Upcast,
|
self, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable,
|
||||||
|
TypeVisitableExt, Upcast,
|
||||||
};
|
};
|
||||||
use rustc_span::{ErrorGuaranteed, Span};
|
use rustc_span::{ErrorGuaranteed, Span};
|
||||||
use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility;
|
use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility;
|
||||||
|
@ -103,6 +104,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||||
let guar = self.report_trait_object_with_no_traits_error(span, &trait_bounds);
|
let guar = self.report_trait_object_with_no_traits_error(span, &trait_bounds);
|
||||||
return Ty::new_error(tcx, guar);
|
return Ty::new_error(tcx, guar);
|
||||||
}
|
}
|
||||||
|
// Don't create a dyn trait if we have errors in the principal.
|
||||||
|
if let Err(guar) = trait_bounds.error_reported() {
|
||||||
|
return Ty::new_error(tcx, guar);
|
||||||
|
}
|
||||||
|
|
||||||
// Check that there are no gross dyn-compatibility violations;
|
// Check that there are no gross dyn-compatibility violations;
|
||||||
// most importantly, that the supertraits don't contain `Self`,
|
// most importantly, that the supertraits don't contain `Self`,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//@ known-bug: #130521
|
//@ known-bug: #130521
|
||||||
|
|
||||||
#![feature(dyn_compatible_for_dispatch)]
|
#![feature(dyn_compatible_for_dispatch)]
|
||||||
struct Vtable(dyn Cap);
|
struct Vtable(dyn Cap<'static>);
|
||||||
|
|
||||||
trait Cap<'a> {}
|
trait Cap<'a> {}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
pub struct Foo<'a, 'b, T> {
|
pub struct Foo<'a, 'b, T> {
|
||||||
field1: dyn Bar<'a, 'b>,
|
field1: dyn Bar<'a, 'b>,
|
||||||
//~^ ERROR
|
//~^ ERROR
|
||||||
//~| ERROR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Bar<'x, 's, U>
|
pub trait Bar<'x, 's, U>
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | field1: dyn Bar<'a, 'b>,
|
||||||
| ^^^ expected 1 generic argument
|
| ^^^ expected 1 generic argument
|
||||||
|
|
|
|
||||||
note: trait defined here, with 1 generic parameter: `U`
|
note: trait defined here, with 1 generic parameter: `U`
|
||||||
--> $DIR/unable-fulfill-trait.rs:9:11
|
--> $DIR/unable-fulfill-trait.rs:8:11
|
||||||
|
|
|
|
||||||
LL | pub trait Bar<'x, 's, U>
|
LL | pub trait Bar<'x, 's, U>
|
||||||
| ^^^ -
|
| ^^^ -
|
||||||
|
@ -14,13 +14,6 @@ help: add missing generic argument
|
||||||
LL | field1: dyn Bar<'a, 'b, U>,
|
LL | field1: dyn Bar<'a, 'b, U>,
|
||||||
| +++
|
| +++
|
||||||
|
|
||||||
error[E0227]: ambiguous lifetime bound, explicit lifetime bound required
|
error: aborting due to 1 previous error
|
||||||
--> $DIR/unable-fulfill-trait.rs:4:13
|
|
||||||
|
|
|
||||||
LL | field1: dyn Bar<'a, 'b>,
|
|
||||||
| ^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0107`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0107, E0227.
|
|
||||||
For more information about an error, try `rustc --explain E0107`.
|
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
trait Trait<const N: dyn Trait = bar> {
|
trait Trait<const N: dyn Trait = bar> {
|
||||||
//~^ ERROR: cannot find value `bar` in this scope
|
//~^ ERROR: cannot find value `bar` in this scope
|
||||||
//~| ERROR: cycle detected when computing type of `Trait::N`
|
//~| ERROR: cycle detected when computing type of `Trait::N`
|
||||||
//~| ERROR: the trait `Trait` cannot be made into an object
|
|
||||||
//~| ERROR: the trait `Trait` cannot be made into an object
|
|
||||||
//~| ERROR: the trait `Trait` cannot be made into an object
|
|
||||||
async fn a() {}
|
async fn a() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,77 +18,7 @@ LL | trait Trait<const N: dyn Trait = bar> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/not_wf_param_in_rpitit.rs:3:22
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: dyn Trait = bar> {
|
|
||||||
| ^^^^^^^^^ `Trait` 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/not_wf_param_in_rpitit.rs:9:14
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: dyn Trait = bar> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
...
|
|
||||||
LL | async fn a() {}
|
|
||||||
| ^ ...because associated function `a` has no `self` parameter
|
|
||||||
help: consider turning `a` into a method by giving it a `&self` argument
|
|
||||||
|
|
|
||||||
LL | async fn a(&self) {}
|
|
||||||
| +++++
|
|
||||||
help: alternatively, consider constraining `a` so it does not apply to trait objects
|
|
||||||
|
|
|
||||||
LL | async fn a() where Self: Sized {}
|
|
||||||
| +++++++++++++++++
|
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
Some errors have detailed explanations: E0391, E0425.
|
||||||
--> $DIR/not_wf_param_in_rpitit.rs:3:13
|
For more information about an error, try `rustc --explain E0391`.
|
||||||
|
|
|
||||||
LL | trait Trait<const N: dyn Trait = bar> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Trait` 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/not_wf_param_in_rpitit.rs:9:14
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: dyn Trait = bar> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
...
|
|
||||||
LL | async fn a() {}
|
|
||||||
| ^ ...because associated function `a` has no `self` parameter
|
|
||||||
help: consider turning `a` into a method by giving it a `&self` argument
|
|
||||||
|
|
|
||||||
LL | async fn a(&self) {}
|
|
||||||
| +++++
|
|
||||||
help: alternatively, consider constraining `a` so it does not apply to trait objects
|
|
||||||
|
|
|
||||||
LL | async fn a() where Self: Sized {}
|
|
||||||
| +++++++++++++++++
|
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
|
||||||
--> $DIR/not_wf_param_in_rpitit.rs:3:13
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: dyn Trait = bar> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Trait` 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/not_wf_param_in_rpitit.rs:9:14
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: dyn Trait = bar> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
...
|
|
||||||
LL | async fn a() {}
|
|
||||||
| ^ ...because associated function `a` has no `self` parameter
|
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
|
||||||
help: consider turning `a` into a method by giving it a `&self` argument
|
|
||||||
|
|
|
||||||
LL | async fn a(&self) {}
|
|
||||||
| +++++
|
|
||||||
help: alternatively, consider constraining `a` so it does not apply to trait objects
|
|
||||||
|
|
|
||||||
LL | async fn a() where Self: Sized {}
|
|
||||||
| +++++++++++++++++
|
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0038, E0391, E0425.
|
|
||||||
For more information about an error, try `rustc --explain E0038`.
|
|
||||||
|
|
|
@ -8,5 +8,4 @@ fn main()
|
||||||
println!("{:?}",(vfnfer[0] as dyn Fn)(3));
|
println!("{:?}",(vfnfer[0] as dyn Fn)(3));
|
||||||
//~^ ERROR the precise format of `Fn`-family traits'
|
//~^ ERROR the precise format of `Fn`-family traits'
|
||||||
//~| ERROR missing generics for trait `Fn`
|
//~| ERROR missing generics for trait `Fn`
|
||||||
//~| ERROR the value of the associated type `Output` in `FnOnce`
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,7 @@ help: add missing generic argument
|
||||||
LL | println!("{:?}",(vfnfer[0] as dyn Fn<Args>)(3));
|
LL | println!("{:?}",(vfnfer[0] as dyn Fn<Args>)(3));
|
||||||
| ++++++
|
| ++++++
|
||||||
|
|
||||||
error[E0191]: the value of the associated type `Output` in `FnOnce` must be specified
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/issue-23024.rs:8:39
|
|
||||||
|
|
|
||||||
LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3));
|
|
||||||
| ^^ help: specify the associated type: `Fn::<Output = Type>`
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
Some errors have detailed explanations: E0107, E0658.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0107, E0191, E0658.
|
|
||||||
For more information about an error, try `rustc --explain E0107`.
|
For more information about an error, try `rustc --explain E0107`.
|
||||||
|
|
|
@ -6,7 +6,6 @@ trait Trait<T> {
|
||||||
|
|
||||||
pub struct Foo<T = Box<Trait<DefaultFoo>>>; //~ ERROR cycle detected
|
pub struct Foo<T = Box<Trait<DefaultFoo>>>; //~ ERROR cycle detected
|
||||||
//~^ ERROR `T` is never used
|
//~^ ERROR `T` is never used
|
||||||
//~| ERROR `Trait` cannot be made into an object
|
|
||||||
type DefaultFoo = Foo;
|
type DefaultFoo = Foo;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: ...which requires expanding type alias `DefaultFoo`...
|
note: ...which requires expanding type alias `DefaultFoo`...
|
||||||
--> $DIR/issue-34373.rs:10:19
|
--> $DIR/issue-34373.rs:9:19
|
||||||
|
|
|
|
||||||
LL | type DefaultFoo = Foo;
|
LL | type DefaultFoo = Foo;
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -17,28 +17,6 @@ LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
|
||||||
--> $DIR/issue-34373.rs:7:24
|
|
||||||
|
|
|
||||||
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
|
||||||
| ^^^^^^^^^^^^^^^^^ `Trait` 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-34373.rs:4:8
|
|
||||||
|
|
|
||||||
LL | trait Trait<T> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
LL | fn foo(_: T) {}
|
|
||||||
| ^^^ ...because associated function `foo` has no `self` parameter
|
|
||||||
help: consider turning `foo` into a method by giving it a `&self` argument
|
|
||||||
|
|
|
||||||
LL | fn foo(&self, _: T) {}
|
|
||||||
| ++++++
|
|
||||||
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
|
||||||
|
|
|
||||||
LL | fn foo(_: T) where Self: Sized {}
|
|
||||||
| +++++++++++++++++
|
|
||||||
|
|
||||||
error[E0392]: type parameter `T` is never used
|
error[E0392]: type parameter `T` is never used
|
||||||
--> $DIR/issue-34373.rs:7:16
|
--> $DIR/issue-34373.rs:7:16
|
||||||
|
|
|
|
||||||
|
@ -48,7 +26,7 @@ LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||||
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
|
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0038, E0391, E0392.
|
Some errors have detailed explanations: E0391, E0392.
|
||||||
For more information about an error, try `rustc --explain E0038`.
|
For more information about an error, try `rustc --explain E0391`.
|
||||||
|
|
|
@ -5,8 +5,7 @@ pub trait T<X, Y> {
|
||||||
}
|
}
|
||||||
pub struct Foo {
|
pub struct Foo {
|
||||||
i: Box<dyn T<usize, usize, usize, usize, B=usize>>,
|
i: Box<dyn T<usize, usize, usize, usize, B=usize>>,
|
||||||
//~^ ERROR must be specified
|
//~^ ERROR trait takes 2 generic arguments but 4 generic arguments were supplied
|
||||||
//~| ERROR trait takes 2 generic arguments but 4 generic arguments were supplied
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,19 +14,6 @@ help: replace the generic bounds with the associated types
|
||||||
LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>,
|
LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>,
|
||||||
| +++ +++
|
| +++ +++
|
||||||
|
|
||||||
error[E0191]: the value of the associated types `C` and `A` in `T` must be specified
|
error: aborting due to 1 previous error
|
||||||
--> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16
|
|
||||||
|
|
|
||||||
LL | type A;
|
|
||||||
| ------ `A` defined here
|
|
||||||
LL | type B;
|
|
||||||
LL | type C;
|
|
||||||
| ------ `C` defined here
|
|
||||||
...
|
|
||||||
LL | i: Box<dyn T<usize, usize, usize, usize, B=usize>>,
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated types `A`, `C` must be specified
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0107`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0107, E0191.
|
|
||||||
For more information about an error, try `rustc --explain E0107`.
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
trait Trait<const N: Trait = bar> {
|
trait Trait<const N: Trait = bar> {
|
||||||
//~^ ERROR cannot find value `bar` in this scope
|
//~^ ERROR cannot find value `bar` in this scope
|
||||||
//~| ERROR cycle detected when computing type of `Trait::N`
|
//~| ERROR cycle detected when computing type of `Trait::N`
|
||||||
//~| ERROR the trait `Trait` cannot be made into an object
|
|
||||||
//~| ERROR the trait `Trait` cannot be made into an object
|
|
||||||
//~| ERROR the trait `Trait` cannot be made into an object
|
|
||||||
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
|
||||||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
|
||||||
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
||||||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
fn fnc<const N: Trait = u32>(&self) -> Trait {
|
fn fnc<const N: Trait = u32>(&self) -> Trait {
|
||||||
|
@ -13,9 +8,6 @@ trait Trait<const N: Trait = bar> {
|
||||||
//~| ERROR expected value, found builtin type `u32`
|
//~| ERROR expected value, found builtin type `u32`
|
||||||
//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
//~| ERROR associated item referring to unboxed trait object for its own trait
|
//~| ERROR associated item referring to unboxed trait object for its own trait
|
||||||
//~| ERROR the trait `Trait` cannot be made into an object
|
|
||||||
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
|
||||||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
|
||||||
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
||||||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters
|
error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:18
|
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:18
|
||||||
|
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
| - first use of `N`
|
| - first use of `N`
|
||||||
|
@ -14,13 +14,13 @@ LL | trait Trait<const N: Trait = bar> {
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
||||||
error[E0423]: expected value, found builtin type `u32`
|
error[E0423]: expected value, found builtin type `u32`
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:29
|
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:29
|
||||||
|
|
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
||||||
| ^^^ not a value
|
| ^^^ not a value
|
||||||
|
|
||||||
error[E0425]: cannot find value `bar` in this scope
|
error[E0425]: cannot find value `bar` in this scope
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:23:9
|
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:15:9
|
||||||
|
|
|
|
||||||
LL | bar
|
LL | bar
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
@ -53,27 +53,8 @@ LL | trait Trait<const N: Trait = bar> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||||
|
|
||||||
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:12
|
|
||||||
|
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: trait objects without an explicit `dyn` are deprecated
|
warning: trait objects without an explicit `dyn` are deprecated
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21
|
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:44
|
||||||
|
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^^^
|
|
||||||
|
|
|
||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
|
||||||
help: if this is a dyn-compatible trait, use `dyn`
|
|
||||||
|
|
|
||||||
LL | fn fnc<const N: dyn Trait = u32>(&self) -> Trait {
|
|
||||||
| +++
|
|
||||||
|
|
||||||
warning: trait objects without an explicit `dyn` are deprecated
|
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:44
|
|
||||||
|
|
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
@ -85,54 +66,27 @@ help: if this is a dyn-compatible trait, use `dyn`
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> dyn Trait {
|
LL | fn fnc<const N: Trait = u32>(&self) -> dyn Trait {
|
||||||
| +++
|
| +++
|
||||||
|
|
||||||
warning: trait objects without an explicit `dyn` are deprecated
|
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22
|
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:12
|
||||||
|
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: trait objects without an explicit `dyn` are deprecated
|
||||||
|
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:21
|
||||||
|
|
|
||||||
|
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
|
||||||
help: if this is a dyn-compatible trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | trait Trait<const N: dyn Trait = bar> {
|
LL | fn fnc<const N: dyn Trait = u32>(&self) -> Trait {
|
||||||
| +++
|
| +++
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
|
||||||
| ^^^^^ `Trait` 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/ice-hir-wf-check-anon-const-issue-122199.rs:11:8
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
...
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^ ...because method `fnc` has generic type parameters
|
|
||||||
= help: consider moving `fnc` to another trait
|
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:13
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `Trait` 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/ice-hir-wf-check-anon-const-issue-122199.rs:11:8
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
...
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^ ...because method `fnc` has generic type parameters
|
|
||||||
= help: consider moving `fnc` to another trait
|
|
||||||
|
|
||||||
error: associated item referring to unboxed trait object for its own trait
|
error: associated item referring to unboxed trait object for its own trait
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:44
|
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:44
|
||||||
|
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
| ----- in this trait
|
| ----- in this trait
|
||||||
|
@ -145,54 +99,7 @@ help: you might have meant to use `Self` to refer to the implementing type
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Self {
|
LL | fn fnc<const N: Trait = u32>(&self) -> Self {
|
||||||
| ~~~~
|
| ~~~~
|
||||||
|
|
||||||
warning: trait objects without an explicit `dyn` are deprecated
|
error: aborting due to 7 previous errors; 3 warnings emitted
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21
|
|
||||||
|
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^^^
|
|
||||||
|
|
|
||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
|
||||||
help: if this is a dyn-compatible trait, use `dyn`
|
|
||||||
|
|
|
||||||
LL | fn fnc<const N: dyn Trait = u32>(&self) -> Trait {
|
|
||||||
| +++
|
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
Some errors have detailed explanations: E0391, E0403, E0423, E0425.
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21
|
For more information about an error, try `rustc --explain E0391`.
|
||||||
|
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^^^ `Trait` 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/ice-hir-wf-check-anon-const-issue-122199.rs:11:8
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
...
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^ ...because method `fnc` has generic type parameters
|
|
||||||
= help: consider moving `fnc` to another trait
|
|
||||||
|
|
||||||
error[E0038]: the trait `Trait` cannot be made into an object
|
|
||||||
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:13
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `Trait` 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/ice-hir-wf-check-anon-const-issue-122199.rs:11:8
|
|
||||||
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
|
||||||
| ----- this trait cannot be made into an object...
|
|
||||||
...
|
|
||||||
LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
|
|
||||||
| ^^^ ...because method `fnc` has generic type parameters
|
|
||||||
= help: consider moving `fnc` to another trait
|
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
|
||||||
|
|
||||||
error: aborting due to 11 previous errors; 5 warnings emitted
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0038, E0391, E0403, E0423, E0425.
|
|
||||||
For more information about an error, try `rustc --explain E0038`.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue