diff --git a/tests/crashes/123461.rs b/tests/crashes/123461.rs deleted file mode 100644 index 6dbfb5c8092..00000000000 --- a/tests/crashes/123461.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ known-bug: #123461 - -fn main() { - let _: [_; unsafe { std::mem::transmute(|o_b: Option<_>| {}) }]; -} diff --git a/tests/ui/transmute/ambiguity-in-closure-arg.rs b/tests/ui/transmute/ambiguity-in-closure-arg.rs new file mode 100644 index 00000000000..4c2d1ce2ad4 --- /dev/null +++ b/tests/ui/transmute/ambiguity-in-closure-arg.rs @@ -0,0 +1,11 @@ +// Minimized test for . + +struct Unconstrained(T); + +fn main() { + unsafe { std::mem::transmute::<_, ()>(|o_b: Unconstrained<_>| {}) }; + //~^ ERROR type annotations needed + // We unfortunately don't check `Wf(Unconstrained<_>)`, so we won't + // hit an ambiguity error before checking the transmute. That means + // we still may have inference variables in our transmute src. +} diff --git a/tests/ui/transmute/ambiguity-in-closure-arg.stderr b/tests/ui/transmute/ambiguity-in-closure-arg.stderr new file mode 100644 index 00000000000..24a10a6d210 --- /dev/null +++ b/tests/ui/transmute/ambiguity-in-closure-arg.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/ambiguity-in-closure-arg.rs:6:44 + | +LL | unsafe { std::mem::transmute::<_, ()>(|o_b: Unconstrained<_>| {}) }; + | ^^^^^^^^^^^^^^^^^^^^^ cannot infer type + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/wf/closure-wf.rs b/tests/ui/wf/closure-wf.rs new file mode 100644 index 00000000000..48baeb30ce5 --- /dev/null +++ b/tests/ui/wf/closure-wf.rs @@ -0,0 +1,11 @@ +trait Bound {} +struct NeedsBound(T); + +// Checks that we enforce that closure args are WF. + +fn constrain_inner FnOnce(&'a (), NeedsBound)>(_: T, _: F) {} + +fn main() { + constrain_inner(1u32, |&(), _| ()); + //~^ ERROR the trait bound `u32: Bound` is not satisfied +} diff --git a/tests/ui/wf/closure-wf.stderr b/tests/ui/wf/closure-wf.stderr new file mode 100644 index 00000000000..4beef3bb7c5 --- /dev/null +++ b/tests/ui/wf/closure-wf.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `u32: Bound` is not satisfied + --> $DIR/closure-wf.rs:9:33 + | +LL | constrain_inner(1u32, |&(), _| ()); + | ^ the trait `Bound` is not implemented for `u32` + | +help: this trait has no implementations, consider adding one + --> $DIR/closure-wf.rs:1:1 + | +LL | trait Bound {} + | ^^^^^^^^^^^ +note: required by a bound in `NeedsBound` + --> $DIR/closure-wf.rs:2:22 + | +LL | struct NeedsBound(T); + | ^^^^^ required by this bound in `NeedsBound` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`.