Merge from rustc

This commit is contained in:
The Miri Cronjob Bot 2025-05-25 05:01:19 +00:00
commit da39cbec73
289 changed files with 3997 additions and 2428 deletions

View file

@ -2,7 +2,13 @@ error[E0223]: ambiguous associated type
--> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:12
|
LL | let _: S::<bool>::Pr = ();
| ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<S<bool> as Tr>::Pr`
| ^^^^^^^^^^^^^
|
help: use fully-qualified syntax
|
LL - let _: S::<bool>::Pr = ();
LL + let _: <S<bool> as Tr>::Pr = ();
|
error: aborting due to 1 previous error

View file

@ -2,7 +2,12 @@ error[E0223]: ambiguous associated type
--> $DIR/ambiguous-associated-type-with-generics.rs:13:13
|
LL | let _x: <dyn Trait<i32>>::Ty;
| ^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<dyn Trait<i32> as Assoc>::Ty`
| ^^^^^^^^^^^^^^^^^^^^
|
help: use fully-qualified syntax
|
LL | let _x: <dyn Trait<i32> as Assoc>::Ty;
| ++++++++
error: aborting due to 1 previous error

View file

@ -13,7 +13,13 @@ error[E0223]: ambiguous associated type
--> $DIR/associated-item-duplicate-names-3.rs:18:12
|
LL | let x: Baz::Bar = 5;
| ^^^^^^^^ help: use fully-qualified syntax: `<Baz as Foo>::Bar`
| ^^^^^^^^
|
help: use fully-qualified syntax
|
LL - let x: Baz::Bar = 5;
LL + let x: <Baz as Foo>::Bar = 5;
|
error: aborting due to 2 previous errors

View file

@ -7,7 +7,7 @@ LL | Trait::method(..): Send,
help: if there were a type named `Example` that implemented `Trait`, you could use the fully-qualified path
|
LL - Trait::method(..): Send,
LL + <Example as Trait>::method: Send,
LL + <Example as Trait>::method(..): Send,
|
error: aborting due to 1 previous error

View file

@ -3,18 +3,35 @@ error[E0223]: ambiguous associated function
|
LL | <()>::method(..): Send,
| ^^^^^^^^^^^^^^^^
|
help: if there were a trait named `Example` with associated function `method` implemented for `()`, you could use the fully-qualified path
|
LL | <() as Example>::method(..): Send,
| ++++++++++
error[E0223]: ambiguous associated function
--> $DIR/path-non-param-qself.rs:13:5
|
LL | i32::method(..): Send,
| ^^^^^^^^^^^^^^^
|
help: if there were a trait named `Example` with associated function `method` implemented for `i32`, you could use the fully-qualified path
|
LL - i32::method(..): Send,
LL + <i32 as Example>::method(..): Send,
|
error[E0223]: ambiguous associated function
--> $DIR/path-non-param-qself.rs:15:5
|
LL | Adt::method(..): Send,
| ^^^^^^^^^^^^^^^
|
help: if there were a trait named `Example` with associated function `method` implemented for `Adt`, you could use the fully-qualified path
|
LL - Adt::method(..): Send,
LL + <Adt as Example>::method(..): Send,
|
error: aborting due to 3 previous errors

View file

@ -14,7 +14,13 @@ error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:22:17
|
LL | trait Foo where Foo::Assoc: Bar {
| ^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Foo>::Assoc`
| ^^^^^^^^^^
|
help: use fully-qualified syntax
|
LL - trait Foo where Foo::Assoc: Bar {
LL + trait Foo where <Self as Foo>::Assoc: Bar {
|
error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:27:10
@ -42,7 +48,13 @@ error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:13:23
|
LL | fn grab(&self) -> Grab::Value;
| ^^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Grab>::Value`
| ^^^^^^^^^^^
|
help: use fully-qualified syntax
|
LL - fn grab(&self) -> Grab::Value;
LL + fn grab(&self) -> <Self as Grab>::Value;
|
error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:16:22

View file

@ -0,0 +1,15 @@
//@ edition:2021
//@ check-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
fn call_once<F>(_: impl FnOnce() -> F) {}
fn main() {
let mut i = 0;
let c = async || {
i += 1;
};
call_once(c);
}

View file

@ -0,0 +1,21 @@
//@compile-flags: -Zvalidate-mir -Zinline-mir=yes --crate-type=lib
#![feature(async_drop)]
#![allow(incomplete_features)]
use std::{
future::{Future, async_drop_in_place},
pin::pin,
task::Context,
};
fn wrong() -> impl Sized {
//~^ ERROR: the size for values of type `str` cannot be known at compilation time
*"abc" // Doesn't implement Sized
}
fn weird(context: &mut Context<'_>) {
let mut e = wrong();
let h = unsafe { async_drop_in_place(&raw mut e) };
let i = pin!(h);
i.poll(context);
}

View file

@ -0,0 +1,19 @@
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/open-drop-error2.rs:12:15
|
LL | fn wrong() -> impl Sized {
| ^^^^^^^^^^ doesn't have a size known at compile-time
LL |
LL | *"abc" // Doesn't implement Sized
| ------ return type was inferred to be `str` here
|
= help: the trait `Sized` is not implemented for `str`
help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression
|
LL - *"abc" // Doesn't implement Sized
LL + "abc" // Doesn't implement Sized
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -42,30 +42,6 @@ LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output;
= help: consider moving `async_dispatch` to another trait
= note: required for the cast from `Pin<&mut {async block@$DIR/mut-is-pointer-like.rs:32:32: 32:37}>` to `Pin<&mut dyn AsyncTrait<Output = ()>>`
error[E0277]: the trait bound `dyn AsyncTrait<Output = ()>: AsyncTrait` is not satisfied
--> $DIR/mut-is-pointer-like.rs:36:11
|
LL | x.async_dispatch().await;
| ^^^^^^^^^^^^^^ the trait `AsyncTrait` is not implemented for `dyn AsyncTrait<Output = ()>`
error: aborting due to 2 previous errors; 1 warning emitted
error[E0038]: the trait `AsyncTrait` is not dyn compatible
--> $DIR/mut-is-pointer-like.rs:36:9
|
LL | x.async_dispatch().await;
| ^^^^^^^^^^^^^^^^^^ `AsyncTrait` 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/mut-is-pointer-like.rs:16:14
|
LL | trait AsyncTrait {
| ---------- this trait is not dyn compatible...
...
LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output;
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
= help: consider moving `async_dispatch` to another trait
error: aborting due to 4 previous errors; 1 warning emitted
Some errors have detailed explanations: E0038, E0277.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0038`.

View file

@ -42,40 +42,6 @@ LL | async fn async_dispatch(&self);
= help: consider moving `async_dispatch` to another trait
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
error[E0038]: the trait `AsyncTrait` is not dyn compatible
--> $DIR/works.rs:28:11
|
LL | x.async_dispatch().await;
| ^^^^^^^^^^^^^^ `AsyncTrait` 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/works.rs:14:14
|
LL | trait AsyncTrait {
| ---------- this trait is not dyn compatible...
LL | async fn async_dispatch(&self);
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
= help: consider moving `async_dispatch` to another trait
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
error[E0038]: the trait `AsyncTrait` is not dyn compatible
--> $DIR/works.rs:28:9
|
LL | x.async_dispatch().await;
| ^^^^^^^^^^^^^^^^^^ `AsyncTrait` 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/works.rs:14:14
|
LL | trait AsyncTrait {
| ---------- this trait is not dyn compatible...
LL | async fn async_dispatch(&self);
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
= help: consider moving `async_dispatch` to another trait
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
error: aborting due to 4 previous errors; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0038`.

View file

@ -0,0 +1,22 @@
// Regression test for #122704
use std::any::Any;
pub struct Foo {
bar: Box<dyn for<'a> Fn(&'a usize) -> Box<dyn Any + 'a>>,
}
impl Foo {
pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
self.bar = Box::new(|baz| Box::new(f(baz)));
//~^ ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
//~| ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
//~| ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
//~| ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
//~| ERROR the parameter type `I` may not live long enough
//~| ERROR the parameter type `I` may not live long enough
//~| ERROR the parameter type `I` may not live long enough
//~| ERROR `f` does not live long enough
}
}
fn main() {}

View file

@ -0,0 +1,119 @@
error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:9
|
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| ^^^^^^^^
| |
| the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
| ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
| +++++++++
error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:9
|
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| ^^^^^^^^
| |
| the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
| ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider adding an explicit lifetime bound
|
LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
| +++++++++
error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:20
|
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| ^^^^^^^^
| |
| the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
| ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
| +++++++++
error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:20
|
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime...
| ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) {
| +++++++++
error[E0310]: the parameter type `I` may not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:35
|
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| ^^^^^^^^^^^^^^^^
| |
| the parameter type `I` must be valid for the static lifetime...
| ...so that the type `I` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
| +++++++++
error[E0310]: the parameter type `I` may not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:35
|
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| ^^^^^^^^^^^^^^^^
| |
| the parameter type `I` must be valid for the static lifetime...
| ...so that the type `I` will meet its required lifetime bounds
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider adding an explicit lifetime bound
|
LL | pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
| +++++++++
error[E0311]: the parameter type `I` may not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:35
|
LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
| --------- the parameter type `I` must be valid for the anonymous lifetime defined here...
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| ^^^^^^^^^^^^^^^^ ...so that the type `I` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | pub fn ack<'a, I: 'a>(&'a mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
| +++ ++++ ++
error[E0597]: `f` does not live long enough
--> $DIR/unconstrained-closure-lifetime-generic.rs:10:44
|
LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) {
| - binding `f` declared here
LL | self.bar = Box::new(|baz| Box::new(f(baz)));
| -------- ----- ^ borrowed value does not live long enough
| | |
| | value captured here
| coercion requires that `f` is borrowed for `'static`
...
LL | }
| - `f` dropped here while still borrowed
|
= note: due to object lifetime defaults, `Box<dyn for<'a> Fn(&'a usize) -> Box<(dyn Any + 'a)>>` actually means `Box<(dyn for<'a> Fn(&'a usize) -> Box<(dyn Any + 'a)> + 'static)>`
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0310, E0311, E0597.
For more information about an error, try `rustc --explain E0310`.

View file

@ -0,0 +1,11 @@
// Regression test for #139004
use std::any::Any;
type B = Box<dyn for<'a> Fn(&(dyn Any + 'a)) -> Box<dyn Any + 'a>>;
fn foo<E>() -> B {
Box::new(|e| Box::new(e.is::<E>()))
//~^ ERROR the parameter type `E` may not live long enough
}
fn main() {}

View file

@ -0,0 +1,17 @@
error[E0310]: the parameter type `E` may not live long enough
--> $DIR/unconstrained-closure-lifetime-trait-object.rs:7:29
|
LL | Box::new(|e| Box::new(e.is::<E>()))
| ^^
| |
| the parameter type `E` must be valid for the static lifetime...
| ...so that the type `E` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
LL | fn foo<E: 'static>() -> B {
| +++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0310`.

View file

@ -0,0 +1,14 @@
// Check warning for wrong `cfg(version("1.27"))` syntax
//
//@ check-pass
//@ no-auto-check-cfg
//@ compile-flags: --check-cfg=cfg()
//@ run-rustfix
#![feature(cfg_version)]
#[cfg(not(version("1.48.0")))]
//~^ WARNING unexpected `cfg` condition name: `version`
pub fn g() {}
pub fn main() {}

View file

@ -0,0 +1,14 @@
// Check warning for wrong `cfg(version("1.27"))` syntax
//
//@ check-pass
//@ no-auto-check-cfg
//@ compile-flags: --check-cfg=cfg()
//@ run-rustfix
#![feature(cfg_version)]
#[cfg(not(version = "1.48.0"))]
//~^ WARNING unexpected `cfg` condition name: `version`
pub fn g() {}
pub fn main() {}

View file

@ -0,0 +1,17 @@
warning: unexpected `cfg` condition name: `version`
--> $DIR/wrong-version-syntax.rs:10:11
|
LL | #[cfg(not(version = "1.48.0"))]
| ^^^^^^^^^^^^^^^^^^
|
= help: to expect this configuration use `--check-cfg=cfg(version, values("1.48.0"))`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
help: there is a similar config predicate: `version("..")`
|
LL - #[cfg(not(version = "1.48.0"))]
LL + #[cfg(not(version("1.48.0")))]
|
warning: 1 warning emitted

View file

@ -0,0 +1,24 @@
#![feature(generic_arg_infer, associated_const_equality, generic_const_items)]
#![expect(incomplete_features)]
// Regression test for #133066 where we would try to evaluate `<() as Foo>::ASSOC<_>` even
// though it contained inference variables, which would cause ICEs.
trait Foo {
const ASSOC<const N: u32>: u32;
}
impl Foo for () {
const ASSOC<const N: u32>: u32 = N;
}
fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {}
fn main() {
bar::<_, ()>();
//~^ ERROR: type mismatch resolving `<() as Foo>::ASSOC<_> == 10`
// FIXME(mgca):
// FIXME(associated_const_equality):
// This ought to start compiling once const items are aliases rather than bodies
}

View file

@ -0,0 +1,17 @@
error[E0271]: type mismatch resolving `<() as Foo>::ASSOC<_> == 10`
--> $DIR/equality_bound_with_infer.rs:18:14
|
LL | bar::<_, ()>();
| ^^ expected `10`, found `<() as Foo>::ASSOC::<_>`
|
= note: expected constant `10`
found constant `<() as Foo>::ASSOC::<_>`
note: required by a bound in `bar`
--> $DIR/equality_bound_with_infer.rs:15:29
|
LL | fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {}
| ^^^^^^^^^^^^^ required by this bound in `bar`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.

View file

@ -0,0 +1,26 @@
// regression test for #137813 where we would assume all constants in the type system
// cannot contain inference variables, even though associated const equality syntax
// was still lowered without the feature gate enabled.
trait AssocConst {
const A: u8;
}
impl<T> AssocConst for (T,) {
const A: u8 = 0;
}
trait Trait {}
impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
//~^ ERROR associated const equality is incomplete
//~| ERROR the type parameter `U` is not constrained by the impl trait
fn foo()
where
(): Trait,
//~^ ERROR type mismatch resolving
{
}
fn main() {}

View file

@ -0,0 +1,39 @@
error[E0658]: associated const equality is incomplete
--> $DIR/unconstrained_impl_param.rs:15:45
|
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
| ^^^^^^^^^
|
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
= help: add `#![feature(associated_const_equality)]` 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[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/unconstrained_impl_param.rs:15:6
|
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
| ^ unconstrained type parameter
error[E0271]: type mismatch resolving `<(_,) as AssocConst>::A == 0`
--> $DIR/unconstrained_impl_param.rs:21:5
|
LL | (): Trait,
| ^^^^^^^^^ expected `0`, found `<(_,) as AssocConst>::A`
|
= note: expected constant `0`
found constant `<(_,) as AssocConst>::A`
note: required for `()` to implement `Trait`
--> $DIR/unconstrained_impl_param.rs:15:9
|
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
| ^^^^^ ^^ --------- unsatisfied trait bound introduced here
= help: see issue #48214
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
|
LL + #![feature(trivial_bounds)]
|
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0207, E0271, E0658.
For more information about an error, try `rustc --explain E0207`.

View file

@ -0,0 +1,13 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
pub struct Foo<const N: usize>;
impl<const N: usize> Foo<N>
where
[u8; N.div_ceil(8)]: Sized,
{
pub fn new() -> Self {
todo!()
}
}

View file

@ -0,0 +1,10 @@
//@ check-pass
//@ aux-build: cross-crate-2.rs
extern crate cross_crate_2;
use cross_crate_2::Foo;
fn main() {
Foo::<7>::new();
}

View file

@ -1,5 +1,5 @@
error: generic parameters may not be used in const operations
--> $DIR/dependence_lint.rs:14:32
--> $DIR/dependence_lint.rs:15:32
|
LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
| ^ cannot perform const operation using `T`
@ -8,7 +8,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/dependence_lint.rs:21:37
--> $DIR/dependence_lint.rs:22:37
|
LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
| ^ cannot perform const operation using `T`
@ -27,7 +27,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_
= note: `#[warn(const_evaluatable_unchecked)]` on by default
warning: cannot use constants which depend on generic parameters in types
--> $DIR/dependence_lint.rs:17:9
--> $DIR/dependence_lint.rs:18:9
|
LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -9,8 +9,19 @@ help: try adding a `where` bound
LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
| ++++++++++++++++++++++++++++++++
error: unconstrained generic constant
--> $DIR/dependence_lint.rs:10:5
|
LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try adding a `where` bound
|
LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
| ++++++++++++++++++++++++++++++++
error: overly complex generic constant
--> $DIR/dependence_lint.rs:17:9
--> $DIR/dependence_lint.rs:18:9
|
LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants
@ -18,7 +29,7 @@ LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error w
= help: consider moving this anonymous constant into a `const` function
error: unconstrained generic constant
--> $DIR/dependence_lint.rs:14:12
--> $DIR/dependence_lint.rs:15:12
|
LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -29,12 +40,12 @@ LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
| ++++++++++++++++++++++++++++++++
error: overly complex generic constant
--> $DIR/dependence_lint.rs:21:17
--> $DIR/dependence_lint.rs:22:17
|
LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants
|
= help: consider moving this anonymous constant into a `const` function
error: aborting due to 4 previous errors
error: aborting due to 5 previous errors

View file

@ -9,7 +9,8 @@ use std::mem::size_of;
fn foo<T>() {
[0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
//[gce]~^ ERROR unconstrained
//[full]~^^ WARNING cannot use constants
//[gce]~| ERROR unconstrained generic constant
//[full]~^^^ WARNING cannot use constants
//[full]~| WARNING this was previously accepted
let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
//[full]~^ ERROR generic parameters may not be used

View file

@ -2,10 +2,10 @@ error[E0308]: mismatched types
--> $DIR/different-fn.rs:10:5
|
LL | [0; size_of::<Foo<T>>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `size_of::<T>()`, found `0`
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `size_of::<T>()`, found `size_of::<Foo<T>>()`
|
= note: expected constant `size_of::<T>()`
found constant `0`
found constant `size_of::<Foo<T>>()`
error: unconstrained generic constant
--> $DIR/different-fn.rs:10:9

View file

@ -15,7 +15,7 @@ impl Foo for () {
}
fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` is not dyn compatible
v.test(); //~ERROR the trait `Foo` is not dyn compatible
v.test();
}
fn main() {}

View file

@ -17,25 +17,6 @@ LL | fn test(&self) -> [u8; bar::<Self>()];
= help: consider moving `test` to another trait
= help: only type `()` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-ret.rs:18:5
|
LL | v.test();
| ^^^^^^^^ `Foo` 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/dyn-compatibility-err-ret.rs:8:8
|
LL | trait Foo {
| --- this trait is not dyn compatible...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
| |
| ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements `Foo`; consider using it directly instead.
error: aborting due to 2 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.

View file

@ -15,7 +15,6 @@ impl Foo for () {
fn use_dyn(v: &dyn Foo) {
//~^ ERROR the trait `Foo` is not dyn compatible
v.test();
//~^ ERROR the trait `Foo` is not dyn compatible
}
fn main() {}

View file

@ -15,23 +15,6 @@ LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
= help: consider moving `test` to another trait
= help: only type `()` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-where-bounds.rs:17:5
|
LL | v.test();
| ^^^^^^^^ `Foo` 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/dyn-compatibility-err-where-bounds.rs:8:8
|
LL | trait Foo {
| --- this trait is not dyn compatible...
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements `Foo`; consider using it directly instead.
error: aborting due to 2 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.

View file

@ -0,0 +1,16 @@
//@ check-pass
// regression test for #136894.
// I (BoxyUwU) don't know what the underlying cause was here
#![feature(generic_const_exprs)]
#![crate_type = "lib"]
#![allow(incomplete_features, dead_code)]
struct X<T>([(); f::<T>()])
where
[(); f::<T>()]:;
const fn f<T>() -> usize {
panic!()
}

View file

@ -25,7 +25,9 @@ impl<T: Copy> DataHolder<T> {
}
<IsCopy<T>>::VALUE
} as usize] = []; //~ ERROR unconstrained generic constant
} as usize] = [];
//~^ ERROR unconstrained generic constant
//~^^ ERROR mismatched types
}
fn main() {}

View file

@ -59,5 +59,49 @@ LL + <IsCopy<T>>::VALUE
LL ~ } as usize]: = [];
|
error: aborting due to 2 previous errors
error[E0308]: mismatched types
--> $DIR/issue-71202.rs:28:19
|
LL | } as usize] = [];
| ^^ expected `1 - {
trait NotCopy {
const VALUE: bool = false;
}
impl<__Type: ?Sized> NotCopy for __Type {}
struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
impl<__Type> IsCopy<__Type>
where
__Type: Sized + Copy,
{
const VALUE: bool = true;
}
<IsCopy<T>>::VALUE
} as usize`, found `0`
|
= note: expected constant `1 - {
trait NotCopy {
const VALUE: bool = false;
}
impl<__Type: ?Sized> NotCopy for __Type {}
struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
impl<__Type> IsCopy<__Type>
where
__Type: Sized + Copy,
{
const VALUE: bool = true;
}
<IsCopy<T>>::VALUE
} as usize`
found constant `0`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -3,10 +3,6 @@
trait TensorDimension {
const DIM: usize;
//~^ ERROR cycle detected when resolving instance
//~| ERROR cycle detected when resolving instance
// FIXME Given the current state of the compiler its expected that we cycle here,
// but the cycle is still wrong.
const ISSCALAR: bool = Self::DIM == 0;
fn is_scalar(&self) -> bool {
Self::ISSCALAR
@ -49,6 +45,7 @@ impl<'a, T: Broadcastable, const DIM: usize> TensorDimension for LazyUpdim<'a, T
impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T::DIM }, DIM> {
fn size(&self) -> [usize; DIM] {
//~^ ERROR: method not compatible with trait
self.size
}
}
@ -56,12 +53,17 @@ impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T
impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> {
type Element = T::Element;
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
//~^ ERROR: method not compatible with trait
assert!(DIM >= T::DIM);
if !self.inbounds(index) {
//~^ ERROR: unconstrained generic constant
//~| ERROR: mismatched types
return None;
}
let size = self.size();
//~^ ERROR: unconstrained generic constant
let newindex: [usize; T::DIM] = Default::default();
//~^ ERROR: the trait bound
self.reference.bget(newindex)
}
}
@ -82,6 +84,8 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSi
fn size(&self) -> [usize; DIM] {
//~^ ERROR: method not compatible with trait
self.reference.size()
//~^ ERROR: unconstrained generic constant
//~| ERROR: mismatched types
}
}
@ -92,6 +96,8 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcas
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
//~^ ERROR: method not compatible with trait
self.reference.bget(index).map(&self.closure)
//~^ ERROR: unconstrained generic constant
//~| ERROR: mismatched types
}
}
@ -100,12 +106,14 @@ impl<T> TensorDimension for Vec<T> {
}
impl<T> TensorSize for Vec<T> {
fn size(&self) -> [usize; 1] {
//~^ ERROR: method not compatible with trait
[self.len()]
}
}
impl<T: Clone> Broadcastable for Vec<T> {
type Element = T;
fn bget(&self, index: [usize; 1]) -> Option<T> {
//~^ ERROR: method not compatible with trait
self.get(index[0]).cloned()
}
}

View file

@ -1,43 +1,5 @@
error[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`
--> $DIR/issue-83765.rs:5:5
|
LL | const DIM: usize;
| ^^^^^^^^^^^^^^^^
|
note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`...
--> $DIR/issue-83765.rs:4:1
|
LL | trait TensorDimension {
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle
note: cycle used when checking assoc item `<impl at $DIR/issue-83765.rs:50:1: 50:94>::size` is compatible with trait definition
--> $DIR/issue-83765.rs:51:5
|
LL | fn size(&self) -> [usize; DIM] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`
--> $DIR/issue-83765.rs:5:5
|
LL | const DIM: usize;
| ^^^^^^^^^^^^^^^^
|
note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`...
--> $DIR/issue-83765.rs:4:1
|
LL | trait TensorDimension {
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle
note: cycle used when checking assoc item `<impl at $DIR/issue-83765.rs:56:1: 56:97>::bget` is compatible with trait definition
--> $DIR/issue-83765.rs:58:5
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:82:5
--> $DIR/issue-83765.rs:47:5
|
LL | fn size(&self) -> [usize; DIM] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
@ -46,7 +8,7 @@ LL | fn size(&self) -> [usize; DIM] {
found constant `DIM`
error[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:92:5
--> $DIR/issue-83765.rs:55:5
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
@ -54,7 +16,145 @@ LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
= note: expected constant `Self::DIM`
found constant `DIM`
error: aborting due to 4 previous errors
error[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:84:5
|
LL | fn size(&self) -> [usize; DIM] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`
Some errors have detailed explanations: E0308, E0391.
For more information about an error, try `rustc --explain E0308`.
error[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:96:5
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`
error[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:108:5
|
LL | fn size(&self) -> [usize; 1] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1`
|
= note: expected constant `Self::DIM`
found constant `1`
error[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:115:5
|
LL | fn bget(&self, index: [usize; 1]) -> Option<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1`
|
= note: expected constant `Self::DIM`
found constant `1`
error: unconstrained generic constant
--> $DIR/issue-83765.rs:58:13
|
LL | if !self.inbounds(index) {
| ^^^^
|
note: required by a bound in `TensorSize::inbounds`
--> $DIR/issue-83765.rs:14:39
|
LL | fn inbounds(&self, index: [usize; Self::DIM]) -> bool {
| ^^^^^^^^^ required by this bound in `TensorSize::inbounds`
help: try adding a `where` bound
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
| ++++++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/issue-83765.rs:58:27
|
LL | if !self.inbounds(index) {
| ^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`
error: unconstrained generic constant
--> $DIR/issue-83765.rs:63:25
|
LL | let size = self.size();
| ^^^^
|
note: required by a bound in `TensorSize::size`
--> $DIR/issue-83765.rs:13:31
|
LL | fn size(&self) -> [usize; Self::DIM];
| ^^^^^^^^^ required by this bound in `TensorSize::size`
help: try adding a `where` bound
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
| ++++++++++++++++++++++
error[E0277]: the trait bound `[usize; T::DIM]: Default` is not satisfied
--> $DIR/issue-83765.rs:65:41
|
LL | let newindex: [usize; T::DIM] = Default::default();
| ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[usize; T::DIM]`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> where [usize; T::DIM]: Default {
| ++++++++++++++++++++++++++++++
error: unconstrained generic constant
--> $DIR/issue-83765.rs:86:24
|
LL | self.reference.size()
| ^^^^
|
note: required by a bound in `TensorSize::size`
--> $DIR/issue-83765.rs:13:31
|
LL | fn size(&self) -> [usize; Self::DIM];
| ^^^^^^^^^ required by this bound in `TensorSize::size`
help: try adding a `where` bound
|
LL | fn size(&self) -> [usize; DIM] where [(); Self::DIM]: {
| ++++++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/issue-83765.rs:86:9
|
LL | self.reference.size()
| ^^^^^^^^^^^^^^^^^^^^^ expected `DIM`, found `Self::DIM`
|
= note: expected constant `DIM`
found constant `Self::DIM`
error: unconstrained generic constant
--> $DIR/issue-83765.rs:98:9
|
LL | self.reference.bget(index).map(&self.closure)
| ^^^^^^^^^^^^^^
|
note: required by a bound in `Broadcastable::bget`
--> $DIR/issue-83765.rs:21:35
|
LL | fn bget(&self, index: [usize; Self::DIM]) -> Option<Self::Element>;
| ^^^^^^^^^ required by this bound in `Broadcastable::bget`
help: try adding a `where` bound
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
| ++++++++++++++++++++++
error[E0308]: mismatched types
--> $DIR/issue-83765.rs:98:29
|
LL | self.reference.bget(index).map(&self.closure)
| ^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`
error: aborting due to 14 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

View file

@ -0,0 +1,17 @@
#![feature(min_generic_const_args)]
#![expect(incomplete_features)]
// Regression test for #140642. Test that normalizing const aliases
// containing erroneous types normalizes to a const error instead of
// a type error.
pub trait Tr<A> {
const SIZE: usize;
}
fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
//~^ ERROR: cannot find type `T` in this scope
//~| ERROR: cannot find type `T` in this scope
fn main() {}

View file

@ -0,0 +1,39 @@
error[E0412]: cannot find type `T` in this scope
--> $DIR/projection-error.rs:13:17
|
LL | pub trait Tr<A> {
| --------------- similarly named trait `Tr` defined here
...
LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| ^
|
help: a trait with a similar name exists
|
LL | fn mk_array(_x: Tr) -> [(); <T as Tr<bool>>::SIZE] {}
| +
help: you might be missing a type parameter
|
LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| +++
error[E0412]: cannot find type `T` in this scope
--> $DIR/projection-error.rs:13:29
|
LL | pub trait Tr<A> {
| --------------- similarly named trait `Tr` defined here
...
LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| ^
|
help: a trait with a similar name exists
|
LL | fn mk_array(_x: T) -> [(); <Tr as Tr<bool>>::SIZE] {}
| +
help: you might be missing a type parameter
|
LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
| +++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0412`.

View file

@ -3,7 +3,7 @@
//@ reference: attributes.diagnostic.on_unimplemented.syntax
//@ reference: attributes.diagnostic.on_unimplemented.invalid-formats
#[diagnostic::on_unimplemented(
on(_Self = "&str"),
on(Self = "&str"),
//~^WARN malformed `on_unimplemented` attribute
//~|WARN malformed `on_unimplemented` attribute
message = "trait has `{Self}` and `{T}` as params",
@ -41,7 +41,7 @@ impl Bar for i32 {}
//~|WARN there is no parameter `integral` on trait `Baz`
//~|WARN there is no parameter `integer` on trait `Baz`
//~|WARN there is no parameter `integer` on trait `Baz`
label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
//~^WARN there is no parameter `float` on trait `Baz`
//~|WARN there is no parameter `float` on trait `Baz`
//~|WARN there is no parameter `_Self` on trait `Baz`
@ -52,6 +52,8 @@ impl Bar for i32 {}
//~|WARN there is no parameter `Trait` on trait `Baz`
//~|WARN there is no parameter `ItemContext` on trait `Baz`
//~|WARN there is no parameter `ItemContext` on trait `Baz`
//~|WARN there is no parameter `This` on trait `Baz`
//~|WARN there is no parameter `This` on trait `Baz`
)]
trait Baz {}

View file

@ -9,8 +9,8 @@ LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:6:5
|
LL | on(_Self = "&str"),
| ^^^^^^^^^^^^^^^^^^ invalid option found here
LL | on(Self = "&str"),
| ^^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
@ -81,7 +81,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
warning: there is no parameter `float` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:15
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -89,7 +89,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `_Self` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:22
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -97,7 +97,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `crate_local` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:29
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^^^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -105,7 +105,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `Trait` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:42
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -113,16 +113,24 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `ItemContext` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:49
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^^^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
warning: there is no parameter `This` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:62
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:6:5
|
LL | on(_Self = "&str"),
| ^^^^^^^^^^^^^^^^^^ invalid option found here
LL | on(Self = "&str"),
| ^^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
@ -146,7 +154,7 @@ LL | append_const_msg
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: trait has `()` and `i32` as params
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:63:15
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:65:15
|
LL | takes_foo(());
| --------- ^^ trait has `()` and `i32` as params
@ -161,7 +169,7 @@ help: this trait has no implementations, consider adding one
LL | trait Foo<T> {}
| ^^^^^^^^^^^^
note: required by a bound in `takes_foo`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:58:22
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:60:22
|
LL | fn takes_foo(_: impl Foo<i32>) {}
| ^^^^^^^^ required by this bound in `takes_foo`
@ -176,7 +184,7 @@ LL | #[diagnostic::on_unimplemented = "Message"]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `(): Bar` is not satisfied
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:65:15
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:67:15
|
LL | takes_bar(());
| --------- ^^ the trait `Bar` is not implemented for `()`
@ -185,7 +193,7 @@ LL | takes_bar(());
|
= help: the trait `Bar` is implemented for `i32`
note: required by a bound in `takes_bar`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:59:22
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:61:22
|
LL | fn takes_bar(_: impl Bar) {}
| ^^^ required by this bound in `takes_bar`
@ -238,7 +246,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
warning: there is no parameter `float` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:15
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -247,7 +255,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `_Self` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:22
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -256,7 +264,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `crate_local` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:29
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^^^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -265,7 +273,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `Trait` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:42
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
@ -274,32 +282,41 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
warning: there is no parameter `ItemContext` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:49
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^^^^^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: there is no parameter `This` on trait `Baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:62
|
LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}"
| ^^^^
|
= help: expect either a generic argument name or `{Self}` as format argument
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: {from_desugaring}{direct}{cause}{integral}{integer}
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:67:15
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:69:15
|
LL | takes_baz(());
| --------- ^^ {float}{_Self}{crate_local}{Trait}{ItemContext}
| --------- ^^ {float}{_Self}{crate_local}{Trait}{ItemContext}{This}
| |
| required by a bound introduced by this call
|
= help: the trait `Baz` is not implemented for `()`
help: this trait has no implementations, consider adding one
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:56:1
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:58:1
|
LL | trait Baz {}
| ^^^^^^^^^
note: required by a bound in `takes_baz`
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:60:22
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:62:22
|
LL | fn takes_baz(_: impl Baz) {}
| ^^^ required by this bound in `takes_baz`
error: aborting due to 3 previous errors; 29 warnings emitted
error: aborting due to 3 previous errors; 31 warnings emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -14,11 +14,15 @@ struct Bar {}
//~|WARN malformed `on_unimplemented` attribute
trait Baz {}
#[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
#[diagnostic::on_unimplemented(message = "Boom", on(Self = "i32", message = "whatever"))]
//~^WARN malformed `on_unimplemented` attribute
//~|WARN malformed `on_unimplemented` attribute
trait Boom {}
#[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
//~^WARN malformed `on_unimplemented` attribute
trait _Self {}
#[diagnostic::on_unimplemented = "boom"]
//~^WARN malformed `on_unimplemented` attribute
trait Doom {}

View file

@ -25,13 +25,21 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:17:50
|
LL | #[diagnostic::on_unimplemented(message = "Boom", on(Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:22:50
|
LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:22:32
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:32
|
LL | #[diagnostic::on_unimplemented = "boom"]
| ^^^^^^^^ invalid option found here
@ -39,7 +47,7 @@ LL | #[diagnostic::on_unimplemented = "boom"]
= help: only `message`, `note` and `label` are allowed as options
warning: missing options for `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:30:1
|
LL | #[diagnostic::on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -47,7 +55,7 @@ LL | #[diagnostic::on_unimplemented]
= help: at least one of the `message`, `note` and `label` options are expected
warning: there is no parameter `DoesNotExist` on trait `Test`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:31:44
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:35:44
|
LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
| ^^^^^^^^^^^^
@ -64,7 +72,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `i32: Foo` is not satisfied
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:43:14
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:47:14
|
LL | take_foo(1_i32);
| -------- ^^^^^ the trait `Foo` is not implemented for `i32`
@ -77,7 +85,7 @@ help: this trait has no implementations, consider adding one
LL | trait Foo {}
| ^^^^^^^^^
note: required by a bound in `take_foo`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:36:21
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:40:21
|
LL | fn take_foo(_: impl Foo) {}
| ^^^ required by this bound in `take_foo`
@ -92,7 +100,7 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: Boom
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:45:14
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:49:14
|
LL | take_baz(1_i32);
| -------- ^^^^^ the trait `Baz` is not implemented for `i32`
@ -105,7 +113,7 @@ help: this trait has no implementations, consider adding one
LL | trait Baz {}
| ^^^^^^^^^
note: required by a bound in `take_baz`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:37:21
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:41:21
|
LL | fn take_baz(_: impl Baz) {}
| ^^^ required by this bound in `take_baz`
@ -113,14 +121,14 @@ LL | fn take_baz(_: impl Baz) {}
warning: malformed `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:17:50
|
LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
LL | #[diagnostic::on_unimplemented(message = "Boom", on(Self = "i32", message = "whatever"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: Boom
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:47:15
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:51:15
|
LL | take_boom(1_i32);
| --------- ^^^^^ the trait `Boom` is not implemented for `i32`
@ -133,13 +141,13 @@ help: this trait has no implementations, consider adding one
LL | trait Boom {}
| ^^^^^^^^^^
note: required by a bound in `take_boom`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:38:22
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:42:22
|
LL | fn take_boom(_: impl Boom) {}
| ^^^^ required by this bound in `take_boom`
warning: missing options for `on_unimplemented` attribute
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:30:1
|
LL | #[diagnostic::on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -148,7 +156,7 @@ LL | #[diagnostic::on_unimplemented]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `i32: Whatever` is not satisfied
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:49:19
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:53:19
|
LL | take_whatever(1_i32);
| ------------- ^^^^^ the trait `Whatever` is not implemented for `i32`
@ -156,18 +164,18 @@ LL | take_whatever(1_i32);
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:29:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:33:1
|
LL | trait Whatever {}
| ^^^^^^^^^^^^^^
note: required by a bound in `take_whatever`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:39:26
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:43:26
|
LL | fn take_whatever(_: impl Whatever) {}
| ^^^^^^^^ required by this bound in `take_whatever`
warning: there is no parameter `DoesNotExist` on trait `Test`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:31:44
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:35:44
|
LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
| ^^^^^^^^^^^^
@ -176,7 +184,7 @@ LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: {DoesNotExist}
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:51:15
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:55:15
|
LL | take_test(());
| --------- ^^ the trait `Test` is not implemented for `()`
@ -184,16 +192,16 @@ LL | take_test(());
| required by a bound introduced by this call
|
help: this trait has no implementations, consider adding one
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:34:1
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:38:1
|
LL | trait Test {}
| ^^^^^^^^^^
note: required by a bound in `take_test`
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:40:22
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:44:22
|
LL | fn take_test(_: impl Test) {}
| ^^^^ required by this bound in `take_test`
error: aborting due to 5 previous errors; 12 warnings emitted
error: aborting due to 5 previous errors; 13 warnings emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -25,5 +25,4 @@ pub fn foo() {
let fetcher = fetcher();
//~^ ERROR the trait `Fetcher` is not dyn compatible
let _ = fetcher.get();
//~^ ERROR the trait `Fetcher` is not dyn compatible
}

View file

@ -34,24 +34,6 @@ LL | pub trait Fetcher: Send + Sync {
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
error[E0038]: the trait `Fetcher` is not dyn compatible
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:27:13
|
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
...
LL | let _ = fetcher.get();
| ^^^^^^^^^^^^^ `Fetcher` 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/undispatchable-receiver-and-wc-references-Self.rs:11:22
|
LL | pub trait Fetcher: Send + Sync {
| ------- this trait is not dyn compatible...
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0038`.

View file

@ -5,8 +5,6 @@ trait Trait {
fn call_foo(x: Box<dyn Trait>) {
//~^ ERROR E0038
let y = x.foo();
//~^ ERROR E0038
//~| ERROR E0277
}
fn main() {

View file

@ -14,33 +14,6 @@ LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/E0038.rs:7:13
|
LL | let y = x.foo();
| ^^^^^^^ `Trait` 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/E0038.rs:2:22
|
LL | trait Trait {
| ----- this trait is not dyn compatible...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait
error: aborting due to 1 previous error
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
--> $DIR/E0038.rs:7:9
|
LL | let y = x.foo();
| ^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Trait`
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0277.
For more information about an error, try `rustc --explain E0038`.
For more information about this error, try `rustc --explain E0038`.

View file

@ -2,7 +2,13 @@ error[E0223]: ambiguous associated type
--> $DIR/E0223.rs:8:14
|
LL | let foo: MyTrait::X;
| ^^^^^^^^^^ help: use fully-qualified syntax: `<MyStruct as MyTrait>::X`
| ^^^^^^^^^^
|
help: use fully-qualified syntax
|
LL - let foo: MyTrait::X;
LL + let foo: <MyStruct as MyTrait>::X;
|
error: aborting due to 1 previous error

View file

@ -7,8 +7,6 @@ trait Foo {
async fn takes_dyn_trait(x: &dyn Foo) {
//~^ ERROR the trait `Foo` is not dyn compatible
x.bar().await;
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
}
fn main() {}

View file

@ -14,38 +14,6 @@ LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:7
|
LL | x.bar().await;
| ^^^ `Foo` 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/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:5
|
LL | x.bar().await;
| ^^^^^^^ `Foo` 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/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
error: aborting due to 3 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.

View file

@ -8,8 +8,6 @@ trait StreamingIterator {
fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
//~^ ERROR the trait `StreamingIterator` is not dyn compatible
x.size_hint().0
//~^ ERROR the trait `StreamingIterator` is not dyn compatible
//~| ERROR the trait `StreamingIterator` is not dyn compatible
}
fn main() {}

View file

@ -14,38 +14,6 @@ LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
= help: consider moving `Item` to another trait
error[E0038]: the trait `StreamingIterator` is not dyn compatible
--> $DIR/trait-objects.rs:10:7
|
LL | x.size_hint().0
| ^^^^^^^^^ `StreamingIterator` 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-objects.rs:2:10
|
LL | trait StreamingIterator {
| ----------------- this trait is not dyn compatible...
LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
= help: consider moving `Item` to another trait
error[E0038]: the trait `StreamingIterator` is not dyn compatible
--> $DIR/trait-objects.rs:10:5
|
LL | x.size_hint().0
| ^^^^^^^^^^^^^ `StreamingIterator` 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-objects.rs:2:10
|
LL | trait StreamingIterator {
| ----------------- this trait is not dyn compatible...
LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
= help: consider moving `Item` to another trait
error: aborting due to 3 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.

View file

@ -15,6 +15,4 @@ fn main() {
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
let s = i.baz();
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
}

View file

@ -15,40 +15,6 @@ LL | fn baz(&self) -> impl Debug;
= help: consider moving `baz` to another trait
= help: only type `u32` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility.rs:17:15
|
LL | let s = i.baz();
| ^^^ `Foo` 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/dyn-compatibility.rs:4:22
|
LL | trait Foo {
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
= help: only type `u32` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility.rs:17:13
|
LL | let s = i.baz();
| ^^^^^^^ `Foo` 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/dyn-compatibility.rs:4:22
|
LL | trait Foo {
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
= help: only type `u32` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility.rs:14:13
|
@ -67,6 +33,6 @@ LL | fn baz(&self) -> impl Debug;
= help: only type `u32` implements `Foo`; consider using it directly instead.
= note: required for the cast from `Box<u32>` to `Box<dyn Foo>`
error: aborting due to 4 previous errors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0038`.

View file

@ -11,7 +11,6 @@ impl Foo for Thing {
fn foo(b: &dyn Bar) {
//~^ ERROR E0038
b.foo(&0)
//~^ ERROR E0038
}
fn main() {

View file

@ -15,23 +15,7 @@ LL | pub trait Bar: Foo { }
= help: consider moving `foo` to another trait
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/issue-18959.rs:13:5
|
LL | b.foo(&0)
| ^^^^^^^^^ `Bar` 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-18959.rs:1:20
|
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
| ^^^ ...because method `foo` has generic type parameters
LL | pub trait Bar: Foo { }
| --- this trait is not dyn compatible...
= help: consider moving `foo` to another trait
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/issue-18959.rs:19:26
--> $DIR/issue-18959.rs:18:26
|
LL | let test: &dyn Bar = &mut thing;
| ^^^^^^^^^^ `Bar` is not dyn compatible
@ -48,7 +32,7 @@ LL | pub trait Bar: Foo { }
= note: required for the cast from `&mut Thing` to `&dyn Bar`
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/issue-18959.rs:19:15
--> $DIR/issue-18959.rs:18:15
|
LL | let test: &dyn Bar = &mut thing;
| ^^^^^^^^ `Bar` is not dyn compatible
@ -63,6 +47,6 @@ LL | pub trait Bar: Foo { }
| --- this trait is not dyn compatible...
= help: consider moving `foo` to another trait
error: aborting due to 4 previous errors
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0038`.

View file

@ -49,12 +49,14 @@ fn ice() {
// Use index
let arr = [0; 5];
let _ = arr[2];
//~^ ERROR cannot index into a value of type `[{integer}; 5]`
// Use phantomdata
let _ = MyPhantomData::<(), i32>;
// Use Foo
let _: () = Foo;
//~^ ERROR mismatched types
}
// use `start`

View file

@ -76,9 +76,23 @@ LL | r + a;
| |
| {integer}
error[E0608]: cannot index into a value of type `[{integer}; 5]`
--> $DIR/lang-item-generic-requirements.rs:51:16
|
LL | let _ = arr[2];
| ^^^
error[E0308]: mismatched types
--> $DIR/lang-item-generic-requirements.rs:58:17
|
LL | let _: () = Foo;
| -- ^^^ expected `()`, found `Foo`
| |
| expected due to this
error: requires `copy` lang_item
error: aborting due to 10 previous errors
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0369, E0392, E0718.
For more information about an error, try `rustc --explain E0369`.
Some errors have detailed explanations: E0308, E0369, E0392, E0608, E0718.
For more information about an error, try `rustc --explain E0308`.

View file

@ -55,7 +55,13 @@ error[E0223]: ambiguous associated type
--> $DIR/bare-trait-objects-path.rs:23:12
|
LL | let _: Dyn::Ty;
| ^^^^^^^ help: use fully-qualified syntax: `<dyn Dyn as Assoc>::Ty`
| ^^^^^^^
|
help: use fully-qualified syntax
|
LL - let _: Dyn::Ty;
LL + let _: <dyn Dyn as Assoc>::Ty;
|
error: aborting due to 1 previous error; 4 warnings emitted

View file

@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/hr-projection-mismatch.rs:20:5
|
LL | wrap::<_, Thing>();
| ^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected reference `&'a _`
found reference `&_`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,20 @@
error[E0271]: type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32`
--> $DIR/hr-projection-mismatch.rs:20:15
|
LL | wrap::<_, Thing>();
| ^^^^^ type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32`
|
note: types differ
--> $DIR/hr-projection-mismatch.rs:14:18
|
LL | type Assoc = &'a i32;
| ^^^^^^^
note: required by a bound in `wrap`
--> $DIR/hr-projection-mismatch.rs:17:33
|
LL | fn wrap<T, U: for<'a> Trait<'a, Assoc = T>>() {}
| ^^^^^^^^^ required by this bound in `wrap`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.

View file

@ -0,0 +1,25 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
// Regression test for <https://github.com/rust-lang/rust/issues/141322>.
trait Trait<'a> {
type Assoc;
}
struct Thing;
impl<'a> Trait<'a> for Thing {
type Assoc = &'a i32;
}
fn wrap<T, U: for<'a> Trait<'a, Assoc = T>>() {}
fn foo() {
wrap::<_, Thing>();
//[next]~^ ERROR type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32
//[current]~^^ ERROR mismatched types
}
fn main() {}

View file

@ -59,7 +59,7 @@ trait EmptyOn {}
//~^^^ NOTE expected value here
trait ExpectedPredicateInOn {}
#[rustc_on_unimplemented(on(x = "y"), message = "y")]
#[rustc_on_unimplemented(on(Self = "y"), message = "y")]
trait OnWithoutDirectives {}
#[rustc_on_unimplemented(on(from_desugaring, on(from_desugaring, message = "x")), message = "y")]
@ -107,3 +107,13 @@ trait InvalidPredicate {}
//~^ ERROR invalid flag in `on`-clause
//~^^ NOTE expected one of the `crate_local`, `direct` or `from_desugaring` flags, not `something`
trait InvalidFlag {}
#[rustc_on_unimplemented(on(_Self = "y", message = "y"))]
//~^ ERROR invalid name in `on`-clause
//~^^ NOTE expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `_Self`
trait InvalidName {}
#[rustc_on_unimplemented(on(abc = "y", message = "y"))]
//~^ ERROR invalid name in `on`-clause
//~^^ NOTE expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `abc`
trait InvalidName2 {}

View file

@ -125,7 +125,19 @@ error[E0232]: invalid flag in `on`-clause
LL | #[rustc_on_unimplemented(on(something, message = "y"))]
| ^^^^^^^^^ expected one of the `crate_local`, `direct` or `from_desugaring` flags, not `something`
error: aborting due to 18 previous errors
error[E0232]: invalid name in `on`-clause
--> $DIR/bad-annotation.rs:111:29
|
LL | #[rustc_on_unimplemented(on(_Self = "y", message = "y"))]
| ^^^^^ expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `_Self`
error[E0232]: invalid name in `on`-clause
--> $DIR/bad-annotation.rs:116:29
|
LL | #[rustc_on_unimplemented(on(abc = "y", message = "y"))]
| ^^^ expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `abc`
error: aborting due to 20 previous errors
Some errors have detailed explanations: E0230, E0231, E0232.
For more information about an error, try `rustc --explain E0230`.

View file

@ -3,7 +3,7 @@
#![feature(rustc_attrs)]
pub mod Bar {
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"]
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{This}`"]
pub trait Foo<Bar, Baz, Quux> {}
}

View file

@ -0,0 +1,12 @@
//@ run-fail
//@ compile-flags: -Cstrip=none -Cdebuginfo=line-tables-only -Copt-level=0
//@ exec-env:RUST_BACKTRACE=1
//@ regex-error-pattern: location-detail-unwrap-multiline\.rs:11(:10)?\n
//@ needs-unwind
//@ ignore-android FIXME #17520
fn main() {
let opt: Option<u32> = None;
opt
.unwrap();
}

View file

@ -0,0 +1,19 @@
//@ check-pass
// Tests that const patterns that use generic parameters are
// allowed if we are still able to evaluate them.
trait Trait { const ASSOC: usize; }
impl<T> Trait for T {
const ASSOC: usize = 10;
}
fn foo<T>(a: usize) {
match a {
<T as Trait>::ASSOC => (),
_ => (),
}
}
fn main() {}

View file

@ -7,7 +7,7 @@ LL | type A = <S as Tr>::A::f<u8>;
help: if there were a trait named `Example` with associated type `f` implemented for `<S as Tr>::A`, you could use the fully-qualified path
|
LL - type A = <S as Tr>::A::f<u8>;
LL + type A = <<S as Tr>::A as Example>::f;
LL + type A = <<S as Tr>::A as Example>::f<u8>;
|
error: aborting due to 1 previous error

View file

@ -0,0 +1,72 @@
#![feature(generic_arg_infer)]
// Test when deferring repeat expr copy checks to end of typechecking whether elements
// that are const items allow for repeat counts to go uninferred without an error being
// emitted if they would later wind up inferred by integer fallback.
//
// This test should be updated if we wind up deferring repeat expr checks until *after*
// integer fallback as the point of the test is not *specifically* about integer fallback
// but rather about the behaviour of `const` element exprs.
trait Trait<const N: usize> {}
// We impl `Trait` for both `i32` and `u32` to avoid being able
// to prove `?int: Trait<?n>` from there only being one impl.
impl Trait<2> for i32 {}
impl Trait<2> for u32 {}
fn tie_and_make_goal<const N: usize, T: Trait<N>>(_: &T, _: &[String; N]) {}
fn const_block() {
// Deferred repeat expr `String; ?n`
let a = [const { String::new() }; _];
// `?int: Trait<?n>` goal
tie_and_make_goal(&1, &a);
// If repeat expr checks structurally resolve the `?n`s before checking if the
// element is a `const` then we would error here. Otherwise we avoid doing so,
// integer fallback occurs, allowing `?int: Trait<?n>` goals to make progress,
// inferring the repeat counts (to `2` but that doesn't matter as the element is `const`).
}
fn const_item() {
const MY_CONST: String = String::new();
// Deferred repeat expr `String; ?n`
let a = [MY_CONST; _];
// `?int: Trait<?n>` goal
tie_and_make_goal(&1, &a);
// ... same as `const_block`
}
fn assoc_const() {
trait Dummy {
const ASSOC: String;
}
impl Dummy for () {
const ASSOC: String = String::new();
}
// Deferred repeat expr `String; ?n`
let a = [<() as Dummy>::ASSOC; _];
// `?int: Trait<?n>` goal
tie_and_make_goal(&1, &a);
// ... same as `const_block`
}
fn const_block_but_uninferred() {
// Deferred repeat expr `String; ?n`
let a = [const { String::new() }; _];
//~^ ERROR: type annotations needed for `[String; _]`
// Even if we don't structurally resolve the repeat count as part of repeat expr
// checks, we still error on the repeat count being uninferred as we require all
// types/consts to be inferred by the end of type checking.
}
fn main() {}

View file

@ -0,0 +1,15 @@
error[E0284]: type annotations needed for `[String; _]`
--> $DIR/copy-check-const-element-uninferred-count.rs:64:9
|
LL | let a = [const { String::new() }; _];
| ^ ---------------------------- type must be known at this point
|
= note: the length of array `[String; _]` must be type `usize`
help: consider giving `a` an explicit type, where the placeholders `_` are specified
|
LL | let a: [_; _] = [const { String::new() }; _];
| ++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0284`.

View file

@ -1,37 +1,53 @@
#![feature(generic_arg_infer)]
// Test that would start passing if we defer repeat expr copy checks to end of
// typechecking and they're checked after integer fallback occurs. We accomplish
// this by contriving a situation where integer fallback allows progress to be
// made on a trait goal that infers the length of a repeat expr.
// Test when deferring repeat expr copy checks to end of typechecking whether they're
// checked before integer fallback occurs or not. We accomplish this by having a repeat
// count that can only be inferred after integer fallback has occured. This test will
// pass if we were to check repeat exprs after integer fallback.
use std::marker::PhantomData;
struct Foo<T>(PhantomData<T>);
struct NotCopy;
// We impl Copy/Clone for multiple (but not all) substitutions
// to ensure that `Foo<?int>: Copy` can't be proven on the basis
// of there only being one applying impl.
impl Clone for Foo<u32> {
fn clone(&self) -> Self {
Foo(PhantomData)
}
}
impl Clone for Foo<i32> {
fn clone(&self) -> Self {
Foo(PhantomData)
}
}
impl Copy for Foo<u32> {}
impl Copy for Foo<i32> {}
trait Trait<const N: usize> {}
impl Trait<2> for u32 {}
// We impl `Trait` for both `i32` and `u32` to avoid being able
// to prove `?int: Trait<?n>` from there only being one impl.
impl Trait<1> for i32 {}
impl Trait<2> for u32 {}
fn make_goal<T: Trait<N>, const N: usize>(_: &T, _: [NotCopy; N]) {}
fn tie_and_make_goal<const N: usize, T: Trait<N>>(_: &T, _: &[Foo<T>; N]) {}
fn main() {
let a = 1;
let b = [NotCopy; _];
//~^ ERROR: type annotations needed
// Deferred repeat expr `Foo<?int>; ?n`
let b = [Foo(PhantomData); _];
//~^ ERROR: type annotations needed for `[Foo<{integer}>; _]`
// a is of type `?y`
// b is of type `[NotCopy; ?x]`
// there is a goal ?y: Trait<?x>` with two candidates:
// - `i32: Trait<1>`, ?y=i32 ?x=1 which doesnt require `NotCopy: Copy`
// - `u32: Trait<2>` ?y=u32 ?x=2 which requires `NotCopy: Copy`
make_goal(&a, b);
// Introduces a `?int: Trait<?n>` goal
tie_and_make_goal(&a, &b);
// final repeat expr checks:
//
// `NotCopy; ?x`
// - succeeds if fallback happens before repeat exprs as `i32: Trait<?x>` infers `?x=1`
// - fails if repeat expr checks happen first as `?x` is unconstrained so cannot be
// structurally resolved
// If fallback doesn't occur:
// - `Foo<?int>; ?n`is ambig as repeat count is unknown -> error
// If fallback occurs:
// - `?int` inferred to `i32`
// - `?int: Trait<?n>` becomes `i32: Trait<?n>` wihhc infers `?n=1`
// - Repeat expr check `Foo<?int>; ?n` is now `Foo<i32>; 1`
// - `Foo<i32>; 1` doesn't require `Foo<i32>: Copy`
}

View file

@ -1,13 +1,13 @@
error[E0282]: type annotations needed for `[NotCopy; _]`
--> $DIR/copy-check-deferred-after-fallback.rs:21:9
error[E0282]: type annotations needed for `[Foo<{integer}>; _]`
--> $DIR/copy-check-deferred-after-fallback.rs:39:9
|
LL | let b = [NotCopy; _];
| ^ ------- type must be known at this point
LL | let b = [Foo(PhantomData); _];
| ^ ---------------- type must be known at this point
|
help: consider giving `b` an explicit type, where the value of const parameter `N` is specified
|
LL | let b: [_; N] = [NotCopy; _];
| ++++++++
LL | let b: [Foo<{integer}>; N] = [Foo(PhantomData); _];
| +++++++++++++++++++++
error: aborting due to 1 previous error

View file

@ -1,18 +1,13 @@
//@ check-pass
#![feature(generic_arg_infer)]
// Test that if we defer repeat expr copy checks to end of typechecking they're
// checked before integer fallback occurs. We accomplish this by contriving a
// situation where we have a goal that can be proven either via another repeat expr
// check or by integer fallback. In the integer fallback case an array length would
// be inferred to `2` requiring `NotCopy: Copy`, and in the repeat expr case it would
// be inferred to `1`.
// Test when deferring repeat expr checks to end of typechecking whether they're
// checked before integer fallback occurs. We accomplish this by having the repeat
// expr check allow inference progress on an ambiguous goal, where the ambiguous goal
// would fail if the inference variable was fallen back to `i32`. This test will
// pass if we check repeat exprs before integer fallback.
use std::marker::PhantomData;
struct NotCopy;
struct Foo<T>(PhantomData<T>);
impl Clone for Foo<u32> {
@ -20,40 +15,34 @@ impl Clone for Foo<u32> {
Foo(PhantomData)
}
}
impl Copy for Foo<u32> {}
fn tie<T>(_: &T, _: [Foo<T>; 2]) {}
trait Trait {}
trait Trait<const N: usize> {}
// Two impls just to ensure that `?int: Trait` wont itself succeed by unifying with
// a self type on an impl here. It also ensures that integer fallback would actually
// be valid for all of the stalled goals incase that's ever something we take into account.
impl Trait for i32 {}
impl Trait for u32 {}
impl Trait<2> for i32 {}
impl Trait<1> for u32 {}
fn make_goal<T: Trait<N>, const N: usize>(_: &T, _: [NotCopy; N]) {}
fn make_goal<T: Trait>(_: &T) {}
fn tie<T>(_: &T, _: &[Foo<T>; 2]) {}
fn main() {
let a = 1;
// `?int: Trait`
make_goal(&a);
// Deferred `Foo<?int>: Copy` requirement
let b: [Foo<_>; 2] = [Foo(PhantomData); _];
tie(&a, b);
let c = [NotCopy; _];
tie(&a, &b);
// a is of type `?y`
// b is of type `[Foo<?y>; 2]`
// c is of type `[NotCopy; ?x]`
// there is a goal ?y: Trait<?x>` with two candidates:
// - `i32: Trait<2>`, ?y=i32 ?x=2 which requires `NotCopy: Copy` when expr checks happen
// - `u32: Trait<1>` ?y=u32 ?x=1 which doesnt require `NotCopy: Copy`
make_goal(&a, c);
// If fallback doesn't occur:
// - `Foo<?int>; 2`is > 1, needs copy
// - `Foo<?int>: Copy` infers `?int=u32`
// - stalled goal `?int: Trait` can now make progress and succeed
// final repeat expr checks:
//
// `Foo<?y>; 2`
// - Foo<?y>: Copy
// - requires ?y=u32
//
// `NotCopy; ?x`
// - fails if fallback happens before repeat exprs as `i32: Trait<?x>` infers `?x=2`
// - succeeds if repeat expr checks happen first as `?y=u32` means `u32: Trait<?x>`
// infers `?x=1`
// If fallback occurs:
// - `Foo<i32>; 2` is > 1, needs copy
// - `Foo<i32>: Copy` doesn't hold -> error
}

View file

@ -0,0 +1,34 @@
#![feature(generic_arg_infer)]
struct Foo<const N: usize>;
impl Clone for Foo<1> {
fn clone(&self) -> Self {
Self
}
}
impl Copy for Foo<1> {}
fn unify<const N: usize>(_: &[Foo<N>; 2], _: &[String; N]) {}
fn works_if_inference_side_effects() {
// This will only pass if inference side effects from proving `Foo<?x>: Copy` are
// able to be relied upon by other repeat expressions.
let a /* : [Foo<?x>; 2] */ = [Foo::<_>; 2];
//~^ ERROR: type annotations needed for `[Foo<_>; 2]`
let b /* : [String; ?x] */ = ["string".to_string(); _];
unify(&a, &b);
}
fn works_if_fixed_point() {
// This will only pass if the *second* array repeat expr is checked first
// allowing `Foo<?x>: Copy` to infer the array length of the first repeat expr.
let b /* : [String; ?x] */ = ["string".to_string(); _];
//~^ ERROR: type annotations needed for `[String; _]`
let a /* : [Foo<?x>; 2] */ = [Foo::<_>; 2];
unify(&a, &b);
}
fn main() {}

View file

@ -0,0 +1,28 @@
error[E0282]: type annotations needed for `[Foo<_>; 2]`
--> $DIR/copy-check-inference-side-effects.rs:17:9
|
LL | let a /* : [Foo<?x>; 2] */ = [Foo::<_>; 2];
| ^
LL |
LL | let b /* : [String; ?x] */ = ["string".to_string(); _];
| -------------------- type must be known at this point
|
help: consider giving `a` an explicit type, where the value of const parameter `N` is specified
|
LL | let a: [Foo<N>; 2] /* : [Foo<?x>; 2] */ = [Foo::<_>; 2];
| +++++++++++++
error[E0282]: type annotations needed for `[String; _]`
--> $DIR/copy-check-inference-side-effects.rs:27:9
|
LL | let b /* : [String; ?x] */ = ["string".to_string(); _];
| ^ -------------------- type must be known at this point
|
help: consider giving `b` an explicit type, where the value of const parameter `N` is specified
|
LL | let b: [_; N] /* : [String; ?x] */ = ["string".to_string(); _];
| ++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0282`.

View file

@ -1,8 +1,3 @@
//@revisions: current gai
//@[current] check-pass
#![cfg_attr(gai, feature(generic_arg_infer))]
use std::marker::PhantomData;
struct Foo<T>(PhantomData<T>);
@ -20,6 +15,6 @@ fn extract<T, const N: usize>(_: [Foo<T>; N]) -> T {
fn main() {
let x = [Foo(PhantomData); 2];
//[gai]~^ ERROR: type annotations needed
_ = extract(x).max(2);
//~^ ERROR: type annotations needed
extract(x).max(2);
}

View file

@ -0,0 +1,17 @@
error[E0282]: type annotations needed for `[Foo<_>; 2]`
--> $DIR/copy-inference-side-effects-are-lazy.rs:17:9
|
LL | let x = [Foo(PhantomData); 2];
| ^
LL |
LL | extract(x).max(2);
| ---------- type must be known at this point
|
help: consider giving `x` an explicit type, where the type for type parameter `T` is specified
|
LL | let x: [Foo<T>; 2] = [Foo(PhantomData); 2];
| +++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.

View file

@ -0,0 +1,18 @@
// Regression test for <https://github.com/rust-lang/rust/issues/141419>.
use std::ops::Deref;
struct W;
trait Foo: Deref<Target = W> {
fn method(self: &W) {}
//~^ ERROR invalid `self` parameter type: `&W`
}
fn test(x: &dyn Foo) {
//~^ ERROR the trait `Foo` is not dyn compatible
x.method();
//~^ ERROR the trait `Foo` is not dyn compatible
}
fn main() {}

View file

@ -0,0 +1,49 @@
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:12:13
|
LL | fn method(self: &W) {}
| -- help: consider changing method `method`'s `self` parameter to be `&self`: `&Self`
...
LL | fn test(x: &dyn Foo) {
| ^^^^^^^ `Foo` 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/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21
|
LL | trait Foo: Deref<Target = W> {
| --- this trait is not dyn compatible...
LL | fn method(self: &W) {}
| ^^ ...because method `method`'s `self` parameter cannot be dispatched on
error[E0307]: invalid `self` parameter type: `&W`
--> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21
|
LL | fn method(self: &W) {}
| ^^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:14:5
|
LL | fn method(self: &W) {}
| -- help: consider changing method `method`'s `self` parameter to be `&self`: `&Self`
...
LL | x.method();
| ^^^^^^^^^^ `Foo` 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/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21
|
LL | trait Foo: Deref<Target = W> {
| --- this trait is not dyn compatible...
LL | fn method(self: &W) {}
| ^^ ...because method `method`'s `self` parameter cannot be dispatched on
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0307.
For more information about an error, try `rustc --explain E0038`.

View file

@ -2,13 +2,25 @@ error[E0223]: ambiguous associated type
--> $DIR/self-impl.rs:23:16
|
LL | let _: <Self>::Baz = true;
| ^^^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz`
| ^^^^^^^^^^^
|
help: use fully-qualified syntax
|
LL - let _: <Self>::Baz = true;
LL + let _: <Bar as Foo>::Baz = true;
|
error[E0223]: ambiguous associated type
--> $DIR/self-impl.rs:25:16
|
LL | let _: Self::Baz = true;
| ^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz`
| ^^^^^^^^^
|
help: use fully-qualified syntax
|
LL - let _: Self::Baz = true;
LL + let _: <Bar as Foo>::Baz = true;
|
error: aborting due to 2 previous errors

View file

@ -48,19 +48,37 @@ error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:32:13
|
LL | let s = S::A {};
| ^^^^ help: use fully-qualified syntax: `<S as Tr>::A`
| ^^^^
|
help: use fully-qualified syntax
|
LL - let s = S::A {};
LL + let s = <S as Tr>::A {};
|
error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:33:13
|
LL | let z = S::A::<u8> {};
| ^^^^ help: use fully-qualified syntax: `<S as Tr>::A`
| ^^^^
|
help: use fully-qualified syntax
|
LL - let z = S::A::<u8> {};
LL + let z = <S as Tr>::A::<u8> {};
|
error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:35:9
|
LL | S::A {} => {}
| ^^^^ help: use fully-qualified syntax: `<S as Tr>::A`
| ^^^^
|
help: use fully-qualified syntax
|
LL - S::A {} => {}
LL + <S as Tr>::A {} => {}
|
error: aborting due to 8 previous errors

View file

@ -0,0 +1,14 @@
//@ compile-flags: --crate-type=lib
//@ compile-flags: --target=aarch64-unknown-none-softfloat
//@ needs-llvm-components: aarch64
#![feature(no_core, lang_items)]
#![no_core]
#![deny(aarch64_softfloat_neon)]
#[lang = "sized"]
pub trait Sized {}
#[target_feature(enable = "neon")]
//~^ERROR: enabling the `neon` target feature on the current target is unsound
//~|WARN: previously accepted
pub unsafe fn my_fun() {}

View file

@ -0,0 +1,31 @@
error: enabling the `neon` target feature on the current target is unsound due to ABI issues
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18
|
LL | #[target_feature(enable = "neon")]
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #134375 <https://github.com/rust-lang/rust/issues/134375>
note: the lint level is defined here
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:6:9
|
LL | #![deny(aarch64_softfloat_neon)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
Future incompatibility report: Future breakage diagnostic:
error: enabling the `neon` target feature on the current target is unsound due to ABI issues
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18
|
LL | #[target_feature(enable = "neon")]
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #134375 <https://github.com/rust-lang/rust/issues/134375>
note: the lint level is defined here
--> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:6:9
|
LL | #![deny(aarch64_softfloat_neon)]
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -230,13 +230,25 @@ error[E0223]: ambiguous associated type
--> $DIR/item-privacy.rs:119:12
|
LL | let _: S::B;
| ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::B>::B`
| ^^^^
|
help: use fully-qualified syntax
|
LL - let _: S::B;
LL + let _: <S as assoc_ty::B>::B;
|
error[E0223]: ambiguous associated type
--> $DIR/item-privacy.rs:120:12
|
LL | let _: S::C;
| ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::C>::C`
| ^^^^
|
help: use fully-qualified syntax
|
LL - let _: S::C;
LL + let _: <S as assoc_ty::C>::C;
|
error[E0624]: associated type `A` is private
--> $DIR/item-privacy.rs:122:12

View file

@ -13,5 +13,4 @@ fn main() {
(Box::new(10) as Box<dyn bar>).dup();
//~^ ERROR E0038
//~| ERROR E0038
//~| ERROR E0038
}

View file

@ -49,29 +49,6 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
consider defining an enum where each variant holds one of these types,
implementing `bar` for this new enum and using it instead
error[E0038]: the trait `bar` is not dyn compatible
--> $DIR/test-2.rs:13:5
|
LL | (Box::new(10) as Box<dyn bar>).dup();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` 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/test-2.rs:4:30
|
LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| --- ^^^^ ^^^^ ...because method `blah` has generic type parameters
| | |
| | ...because method `dup` references the `Self` type in its return type
| this trait is not dyn compatible...
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait
= help: the following types implement `bar`:
i32
u32
consider defining an enum where each variant holds one of these types,
implementing `bar` for this new enum and using it instead
error[E0038]: the trait `bar` is not dyn compatible
--> $DIR/test-2.rs:13:6
|
@ -96,7 +73,7 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
implementing `bar` for this new enum and using it instead
= note: required for the cast from `Box<{integer}>` to `Box<dyn bar>`
error: aborting due to 5 previous errors
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.

View file

@ -8,7 +8,27 @@ pub fn bytes_at_home(x: u32) -> [u8; 4] {
//~^ ERROR
}
pub const fn intinator_const(from: bool) -> u8 {
unsafe { (from) as u8 }
//~^ ERROR
}
pub static X: u8 = unsafe { (true) as u8 };
//~^ ERROR
pub const Y: u8 = unsafe { (true) as u8 };
//~^ ERROR
pub struct Z {}
impl Z {
pub const fn intinator_assoc(x: bool) -> u8 {
unsafe { (x) as u8 }
//~^ ERROR
}
}
fn main() {
const { unsafe { (true) as u8 } };
//~^ ERROR
unsafe {
let x: u16 = u16::from_ne_bytes(*b"01");
//~^ ERROR
@ -83,12 +103,12 @@ fn main() {
let z: bool = transmute(1u8);
// clippy
let z: u8 = (z) as u8;
let z: u8 = u8::from(z);
//~^ ERROR
let z: bool = transmute(1i8);
// clippy
let z: i8 = (z) as i8;
let z: i8 = i8::from(z);
//~^ ERROR
}
}

View file

@ -8,7 +8,27 @@ pub fn bytes_at_home(x: u32) -> [u8; 4] {
//~^ ERROR
}
pub const fn intinator_const(from: bool) -> u8 {
unsafe { transmute(from) }
//~^ ERROR
}
pub static X: u8 = unsafe { transmute(true) };
//~^ ERROR
pub const Y: u8 = unsafe { transmute(true) };
//~^ ERROR
pub struct Z {}
impl Z {
pub const fn intinator_assoc(x: bool) -> u8 {
unsafe { transmute(x) }
//~^ ERROR
}
}
fn main() {
const { unsafe { transmute::<_, u8>(true) } };
//~^ ERROR
unsafe {
let x: u16 = transmute(*b"01");
//~^ ERROR

View file

@ -1,10 +1,9 @@
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:7:14
--> $DIR/unnecessary-transmutation.rs:16:29
|
LL | unsafe { transmute(x) }
| ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)`
LL | pub static X: u8 = unsafe { transmute(true) };
| ^^^^^^^^^^^^^^^ help: replace this with: `(true) as u8`
|
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
note: the lint level is defined here
--> $DIR/unnecessary-transmutation.rs:2:9
|
@ -12,7 +11,33 @@ LL | #![deny(unnecessary_transmutes)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:13:22
--> $DIR/unnecessary-transmutation.rs:18:28
|
LL | pub const Y: u8 = unsafe { transmute(true) };
| ^^^^^^^^^^^^^^^ help: replace this with: `(true) as u8`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:7:14
|
LL | unsafe { transmute(x) }
| ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)`
|
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:12:14
|
LL | unsafe { transmute(from) }
| ^^^^^^^^^^^^^^^ help: replace this with: `(from) as u8`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:24:18
|
LL | unsafe { transmute(x) }
| ^^^^^^^^^^^^ help: replace this with: `(x) as u8`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:33:22
|
LL | let x: u16 = transmute(*b"01");
| ^^^^^^^^^^^^^^^^^ help: replace this with: `u16::from_ne_bytes(*b"01")`
@ -20,7 +45,7 @@ LL | let x: u16 = transmute(*b"01");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:15:26
--> $DIR/unnecessary-transmutation.rs:35:26
|
LL | let x: [u8; 2] = transmute(x);
| ^^^^^^^^^^^^ help: replace this with: `u16::to_ne_bytes(x)`
@ -28,7 +53,7 @@ LL | let x: [u8; 2] = transmute(x);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:17:22
--> $DIR/unnecessary-transmutation.rs:37:22
|
LL | let x: u32 = transmute(*b"0123");
| ^^^^^^^^^^^^^^^^^^^ help: replace this with: `u32::from_ne_bytes(*b"0123")`
@ -36,7 +61,7 @@ LL | let x: u32 = transmute(*b"0123");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:19:26
--> $DIR/unnecessary-transmutation.rs:39:26
|
LL | let x: [u8; 4] = transmute(x);
| ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)`
@ -44,7 +69,7 @@ LL | let x: [u8; 4] = transmute(x);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:21:22
--> $DIR/unnecessary-transmutation.rs:41:22
|
LL | let x: u64 = transmute(*b"feriscat");
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `u64::from_ne_bytes(*b"feriscat")`
@ -52,7 +77,7 @@ LL | let x: u64 = transmute(*b"feriscat");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:23:26
--> $DIR/unnecessary-transmutation.rs:43:26
|
LL | let x: [u8; 8] = transmute(x);
| ^^^^^^^^^^^^ help: replace this with: `u64::to_ne_bytes(x)`
@ -60,7 +85,7 @@ LL | let x: [u8; 8] = transmute(x);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:26:22
--> $DIR/unnecessary-transmutation.rs:46:22
|
LL | let y: i16 = transmute(*b"01");
| ^^^^^^^^^^^^^^^^^ help: replace this with: `i16::from_ne_bytes(*b"01")`
@ -68,7 +93,7 @@ LL | let y: i16 = transmute(*b"01");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:28:26
--> $DIR/unnecessary-transmutation.rs:48:26
|
LL | let y: [u8; 2] = transmute(y);
| ^^^^^^^^^^^^ help: replace this with: `i16::to_ne_bytes(y)`
@ -76,7 +101,7 @@ LL | let y: [u8; 2] = transmute(y);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:30:22
--> $DIR/unnecessary-transmutation.rs:50:22
|
LL | let y: i32 = transmute(*b"0123");
| ^^^^^^^^^^^^^^^^^^^ help: replace this with: `i32::from_ne_bytes(*b"0123")`
@ -84,7 +109,7 @@ LL | let y: i32 = transmute(*b"0123");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:32:26
--> $DIR/unnecessary-transmutation.rs:52:26
|
LL | let y: [u8; 4] = transmute(y);
| ^^^^^^^^^^^^ help: replace this with: `i32::to_ne_bytes(y)`
@ -92,7 +117,7 @@ LL | let y: [u8; 4] = transmute(y);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:34:22
--> $DIR/unnecessary-transmutation.rs:54:22
|
LL | let y: i64 = transmute(*b"feriscat");
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `i64::from_ne_bytes(*b"feriscat")`
@ -100,7 +125,7 @@ LL | let y: i64 = transmute(*b"feriscat");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:36:26
--> $DIR/unnecessary-transmutation.rs:56:26
|
LL | let y: [u8; 8] = transmute(y);
| ^^^^^^^^^^^^ help: replace this with: `i64::to_ne_bytes(y)`
@ -108,7 +133,7 @@ LL | let y: [u8; 8] = transmute(y);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:39:22
--> $DIR/unnecessary-transmutation.rs:59:22
|
LL | let z: f32 = transmute(*b"0123");
| ^^^^^^^^^^^^^^^^^^^ help: replace this with: `f32::from_ne_bytes(*b"0123")`
@ -116,7 +141,7 @@ LL | let z: f32 = transmute(*b"0123");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:41:26
--> $DIR/unnecessary-transmutation.rs:61:26
|
LL | let z: [u8; 4] = transmute(z);
| ^^^^^^^^^^^^ help: replace this with: `f32::to_ne_bytes(z)`
@ -124,7 +149,7 @@ LL | let z: [u8; 4] = transmute(z);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:43:22
--> $DIR/unnecessary-transmutation.rs:63:22
|
LL | let z: f64 = transmute(*b"feriscat");
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `f64::from_ne_bytes(*b"feriscat")`
@ -132,7 +157,7 @@ LL | let z: f64 = transmute(*b"feriscat");
= help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:45:26
--> $DIR/unnecessary-transmutation.rs:65:26
|
LL | let z: [u8; 8] = transmute(z);
| ^^^^^^^^^^^^ help: replace this with: `f64::to_ne_bytes(z)`
@ -140,13 +165,13 @@ LL | let z: [u8; 8] = transmute(z);
= help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:48:22
--> $DIR/unnecessary-transmutation.rs:68:22
|
LL | let y: u32 = transmute('🦀');
| ^^^^^^^^^^^^^^^ help: replace this with: `u32::from('🦀')`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:50:23
--> $DIR/unnecessary-transmutation.rs:70:23
|
LL | let y: char = transmute(y);
| ^^^^^^^^^^^^ help: replace this with: `char::from_u32_unchecked(y)`
@ -154,13 +179,13 @@ LL | let y: char = transmute(y);
= help: consider `char::from_u32(…).unwrap()`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:52:22
--> $DIR/unnecessary-transmutation.rs:72:22
|
LL | let y: i32 = transmute('🐱');
| ^^^^^^^^^^^^^^^ help: replace this with: `u32::from('🐱').cast_signed()`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:54:23
--> $DIR/unnecessary-transmutation.rs:74:23
|
LL | let y: char = transmute(y);
| ^^^^^^^^^^^^ help: replace this with: `char::from_u32_unchecked(i32::cast_unsigned(y))`
@ -168,88 +193,94 @@ LL | let y: char = transmute(y);
= help: consider `char::from_u32(i32::cast_unsigned(…)).unwrap()`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:57:22
--> $DIR/unnecessary-transmutation.rs:77:22
|
LL | let x: u16 = transmute(8i16);
| ^^^^^^^^^^^^^^^ help: replace this with: `i16::cast_unsigned(8i16)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:59:22
--> $DIR/unnecessary-transmutation.rs:79:22
|
LL | let x: i16 = transmute(x);
| ^^^^^^^^^^^^ help: replace this with: `u16::cast_signed(x)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:61:22
--> $DIR/unnecessary-transmutation.rs:81:22
|
LL | let x: u32 = transmute(4i32);
| ^^^^^^^^^^^^^^^ help: replace this with: `i32::cast_unsigned(4i32)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:63:22
--> $DIR/unnecessary-transmutation.rs:83:22
|
LL | let x: i32 = transmute(x);
| ^^^^^^^^^^^^ help: replace this with: `u32::cast_signed(x)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:65:22
--> $DIR/unnecessary-transmutation.rs:85:22
|
LL | let x: u64 = transmute(7i64);
| ^^^^^^^^^^^^^^^ help: replace this with: `i64::cast_unsigned(7i64)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:67:22
--> $DIR/unnecessary-transmutation.rs:87:22
|
LL | let x: i64 = transmute(x);
| ^^^^^^^^^^^^ help: replace this with: `u64::cast_signed(x)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:70:22
--> $DIR/unnecessary-transmutation.rs:90:22
|
LL | let y: f32 = transmute(1u32);
| ^^^^^^^^^^^^^^^ help: replace this with: `f32::from_bits(1u32)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:72:22
--> $DIR/unnecessary-transmutation.rs:92:22
|
LL | let y: u32 = transmute(y);
| ^^^^^^^^^^^^ help: replace this with: `f32::to_bits(y)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:74:22
--> $DIR/unnecessary-transmutation.rs:94:22
|
LL | let y: f64 = transmute(3u64);
| ^^^^^^^^^^^^^^^ help: replace this with: `f64::from_bits(3u64)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:76:22
--> $DIR/unnecessary-transmutation.rs:96:22
|
LL | let y: u64 = transmute(2.0);
| ^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(2.0)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:79:22
--> $DIR/unnecessary-transmutation.rs:99:22
|
LL | let y: f64 = transmute(1i64);
| ^^^^^^^^^^^^^^^ help: replace this with: `f64::from_bits(i64::cast_unsigned(1i64))`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:81:22
--> $DIR/unnecessary-transmutation.rs:101:22
|
LL | let y: i64 = transmute(1f64);
| ^^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(1f64).cast_signed()`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:86:21
--> $DIR/unnecessary-transmutation.rs:106:21
|
LL | let z: u8 = transmute(z);
| ^^^^^^^^^^^^ help: replace this with: `(z) as u8`
| ^^^^^^^^^^^^ help: replace this with: `u8::from(z)`
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:91:21
--> $DIR/unnecessary-transmutation.rs:111:21
|
LL | let z: i8 = transmute(z);
| ^^^^^^^^^^^^ help: replace this with: `(z) as i8`
| ^^^^^^^^^^^^ help: replace this with: `i8::from(z)`
error: aborting due to 35 previous errors
error: unnecessary transmute
--> $DIR/unnecessary-transmutation.rs:30:22
|
LL | const { unsafe { transmute::<_, u8>(true) } };
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `(true) as u8`
error: aborting due to 40 previous errors

View file

@ -62,6 +62,11 @@ LL | / fn foo() -> Bar
LL | | where
LL | | Bar: Send,
| |______________^
note: ...which requires computing revealed normalized predicates of `foo::{constant#0}`...
--> $DIR/in-where-clause.rs:13:9
|
LL | [0; 1 + 2]
| ^^^^^
= note: ...which requires revealing opaque types in `[Binder { value: TraitPredicate(<Bar as core::marker::Send>, polarity:Positive), bound_vars: [] }]`...
note: ...which requires computing type of `Bar::{opaque#0}`...
--> $DIR/in-where-clause.rs:5:12

View file

@ -0,0 +1,10 @@
fn main() {
b"abc".iter().for_each(|x| x); //~ ERROR: mismatched types
b"abc".iter().for_each(|x| dbg!(x)); //~ ERROR: mismatched types
b"abc".iter().for_each(|x| {
println!("{}", x);
x //~ ERROR: mismatched types
})
}

View file

@ -0,0 +1,28 @@
error[E0308]: mismatched types
--> $DIR/closure-ty-mismatch-issue-128561.rs:2:32
|
LL | b"abc".iter().for_each(|x| x);
| ^ expected `()`, found `&u8`
|
help: consider ignoring the value
|
LL | b"abc".iter().for_each(|x| _ = x);
| +++
error[E0308]: mismatched types
--> $DIR/closure-ty-mismatch-issue-128561.rs:4:32
|
LL | b"abc".iter().for_each(|x| dbg!(x));
| ^^^^^^^ expected `()`, found `&u8`
|
= note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/closure-ty-mismatch-issue-128561.rs:8:9
|
LL | x
| ^ expected `()`, found `&u8`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -39,7 +39,7 @@ LL | Inner::concat_strs::<"a">::A
help: if there were a trait named `Example` with associated type `concat_strs` implemented for `Inner<_>`, you could use the fully-qualified path
|
LL - Inner::concat_strs::<"a">::A
LL + <Inner<_> as Example>::concat_strs::A
LL + <Inner<_> as Example>::concat_strs::<"a">::A
|
error: aborting due to 3 previous errors

View file

@ -2,7 +2,13 @@ error[E0223]: ambiguous associated type
--> $DIR/issue-107087.rs:16:5
|
LL | A::B::<>::C
| ^^^^^^^^ help: use fully-qualified syntax: `<A<_> as Foo>::B`
| ^^^^^^^^
|
help: use fully-qualified syntax
|
LL - A::B::<>::C
LL + <A<_> as Foo>::B::<>::C
|
error: aborting due to 1 previous error

View file

@ -0,0 +1,17 @@
// regression test for <https://github.com/rust-lang/rust/issues/141422>.
#![feature(unsafe_binders)]
#![allow(incomplete_features)]
#[derive(Copy, Clone)]
struct Adt<'a>(&'a ());
const C: Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)> = None;
fn main() {
match None {
C => {}
//~^ ERROR constant of non-structural type
_ => {}
}
}

View file

@ -0,0 +1,13 @@
error: constant of non-structural type `Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)>` in a pattern
--> $DIR/non-strucutral-type-diag.rs:13:9
|
LL | const C: Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)> = None;
| ---------------------------------------------------- constant defined here
...
LL | C => {}
| ^ constant of non-structural type
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
error: aborting due to 1 previous error