-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Missing dyn keyword in bare_trait_objects with Rust 2015 edition produces faulty error instead of warnings #98726
Comments
@rustbot labels:+T-compiler |
@rustbot label A-diagnostics |
@rustbot labels: +regression-from-stable-to-nightly |
@rustbot label -regression-untriaged Bisection: |
Seems like, possibly, the code without the explicit fn a<F>(_f: F) where F: FnMut(&i32) {}
fn b<'a, F>(_f: F) where F: FnMut(&mut FnMut(&'a i32)) {}
fn main()
{
b(|f| {
a(|v| f(v))
});
} rather than fn a<F>(_f: F) where F: FnMut(&i32) {}
fn b<F>(_f: F) where F: FnMut(&mut for<'a> FnMut(&'a i32)) {}
fn main()
{
b(|f| {
a(|v| f(v))
});
} Edit: Or perhaps it incorrectly desugars to fn a<F>(_f: F) where F: FnMut(&i32) {}
fn b<F>(_f: F) where F: for<'a> FnMut(&mut FnMut(&'a i32)) {}
fn main()
{
b(|f| {
a(|v| f(v))
});
} |
Here’s another kind of code example that reproduces the issue fn f<F>()
where
F: FnOnce() -> Box<FnOnce(&())>,
{
}
Which does confirm the idea that this appears to be interpreted like |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-critical |
Code
I tried this code with
edition = "2015"
:https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=40892217ad5a83b67570be18e19a43c4
I expected to see only warning without error, like this:
Instead, this happened (extra error E0521 emitted, which is incorrect):
If I add
dyn
in line 3, it compiles without any error or warning:So the E0521 error emitted by the compiler is incorrect. The test code using
Rust=2015
should only produce warnings without an error.Version it worked on
It most recently worked on: 1.63.0-nightly (a4c1cd0eb 2022-05-18)
Version with regression
The text was updated successfully, but these errors were encountered: