@@ -1944,89 +1944,6 @@ To learn more about traits, take a look at the Book:
1944
1944
https://doc.rust-lang.org/book/traits.html
1945
1945
"## ,
1946
1946
1947
- E0174 : r##"
1948
- This error occurs because of the explicit use of unboxed closure methods
1949
- that are an experimental feature in current Rust version.
1950
-
1951
- Example of erroneous code:
1952
-
1953
- ```compile_fail
1954
- fn foo<F: Fn(&str)>(mut f: F) {
1955
- f.call(("call",));
1956
- // error: explicit use of unboxed closure method `call`
1957
- f.call_mut(("call_mut",));
1958
- // error: explicit use of unboxed closure method `call_mut`
1959
- f.call_once(("call_once",));
1960
- // error: explicit use of unboxed closure method `call_once`
1961
- }
1962
-
1963
- fn bar(text: &str) {
1964
- println!("Calling {} it works!", text);
1965
- }
1966
-
1967
- fn main() {
1968
- foo(bar);
1969
- }
1970
- ```
1971
-
1972
- Rust's implementation of closures is a bit different than other languages.
1973
- They are effectively syntax sugar for traits `Fn`, `FnMut` and `FnOnce`.
1974
- To understand better how the closures are implemented see here:
1975
- https://doc.rust-lang.org/book/closures.html#closure-implementation
1976
-
1977
- To fix this you can call them using parenthesis, like this: `foo()`.
1978
- When you execute the closure with parenthesis, under the hood you are executing
1979
- the method `call`, `call_mut` or `call_once`. However, using them explicitly is
1980
- currently an experimental feature.
1981
-
1982
- Example of an implicit call:
1983
-
1984
- ```
1985
- fn foo<F: Fn(&str)>(f: F) {
1986
- f("using ()"); // Calling using () it works!
1987
- }
1988
-
1989
- fn bar(text: &str) {
1990
- println!("Calling {} it works!", text);
1991
- }
1992
-
1993
- fn main() {
1994
- foo(bar);
1995
- }
1996
- ```
1997
-
1998
- To enable the explicit calls you need to add `#![feature(unboxed_closures)]`.
1999
-
2000
- This feature is still unstable so you will also need to add
2001
- `#![feature(fn_traits)]`.
2002
- More details about this issue here:
2003
- https://github.com/rust-lang/rust/issues/29625
2004
-
2005
- Example of use:
2006
-
2007
- ```
2008
- #![feature(fn_traits)]
2009
- #![feature(unboxed_closures)]
2010
-
2011
- fn foo<F: Fn(&str)>(mut f: F) {
2012
- f.call(("call",)); // Calling 'call' it works!
2013
- f.call_mut(("call_mut",)); // Calling 'call_mut' it works!
2014
- f.call_once(("call_once",)); // Calling 'call_once' it works!
2015
- }
2016
-
2017
- fn bar(text: &str) {
2018
- println!("Calling '{}' it works!", text);
2019
- }
2020
-
2021
- fn main() {
2022
- foo(bar);
2023
- }
2024
- ```
2025
-
2026
- To see more about closures take a look here:
2027
- https://doc.rust-lang.org/book/closures.html`
2028
- "## ,
2029
-
2030
1947
E0178 : r##"
2031
1948
In types, the `+` type operator has low precedence, so it is often necessary
2032
1949
to use parentheses.
@@ -4049,6 +3966,7 @@ register_diagnostics! {
4049
3966
E0167 ,
4050
3967
// E0168,
4051
3968
// E0173, // manual implementations of unboxed closure traits are experimental
3969
+ // E0174,
4052
3970
E0182 ,
4053
3971
E0183 ,
4054
3972
// E0187, // can't infer the kind of the closure
0 commit comments