Skip to content

Commit a80d329

Browse files
committed
Don't gate methods Fn(Mut,Once)::call(mut,once) with feature unboxed_closures
They are already gated with feature `fn_traits`
1 parent 724f811 commit a80d329

File tree

96 files changed

+20
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+20
-282
lines changed

src/libcollections/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#![feature(specialization)]
5050
#![feature(staged_api)]
5151
#![feature(step_by)]
52-
#![feature(unboxed_closures)]
5352
#![feature(unicode)]
5453
#![feature(unique)]
5554
#![feature(unsafe_no_drop_flag)]

src/libcoretest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#![feature(step_by)]
3232
#![feature(test)]
3333
#![feature(try_from)]
34-
#![feature(unboxed_closures)]
3534
#![feature(unicode)]
3635
#![feature(unique)]
3736

src/librustc_driver/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#![feature(set_stdio)]
3232
#![feature(staged_api)]
3333
#![feature(question_mark)]
34-
#![feature(unboxed_closures)]
3534

3635
extern crate arena;
3736
extern crate flate;

src/librustc_typeck/check/callee.rs

+2-27
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,8 @@ use rustc::hir;
2727
/// to `trait_id` (this only cares about the trait, not the specific
2828
/// method that is called)
2929
pub fn check_legal_trait_for_method_call(ccx: &CrateCtxt, span: Span, trait_id: DefId) {
30-
let tcx = ccx.tcx;
31-
let did = Some(trait_id);
32-
let li = &tcx.lang_items;
33-
34-
if did == li.drop_trait() {
35-
span_err!(tcx.sess, span, E0040, "explicit use of destructor method");
36-
} else if !tcx.sess.features.borrow().unboxed_closures {
37-
// the #[feature(unboxed_closures)] feature isn't
38-
// activated so we need to enforce the closure
39-
// restrictions.
40-
41-
let method = if did == li.fn_trait() {
42-
"call"
43-
} else if did == li.fn_mut_trait() {
44-
"call_mut"
45-
} else if did == li.fn_once_trait() {
46-
"call_once"
47-
} else {
48-
return // not a closure method, everything is OK.
49-
};
50-
51-
struct_span_err!(tcx.sess, span, E0174,
52-
"explicit use of unboxed closure method `{}` is experimental",
53-
method)
54-
.help("add `#![feature(unboxed_closures)]` to the crate \
55-
attributes to enable")
56-
.emit();
30+
if ccx.tcx.lang_items.drop_trait() == Some(trait_id) {
31+
span_err!(ccx.tcx.sess, span, E0040, "explicit use of destructor method");
5732
}
5833
}
5934

src/librustc_typeck/diagnostics.rs

+1-83
Original file line numberDiff line numberDiff line change
@@ -1944,89 +1944,6 @@ To learn more about traits, take a look at the Book:
19441944
https://doc.rust-lang.org/book/traits.html
19451945
"##,
19461946

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-
20301947
E0178: r##"
20311948
In types, the `+` type operator has low precedence, so it is often necessary
20321949
to use parentheses.
@@ -4049,6 +3966,7 @@ register_diagnostics! {
40493966
E0167,
40503967
// E0168,
40513968
// E0173, // manual implementations of unboxed closure traits are experimental
3969+
// E0174,
40523970
E0182,
40533971
E0183,
40543972
// E0187, // can't infer the kind of the closure

src/test/compile-fail/associated-types/bound-lifetime-constrained.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![allow(dead_code)]
1414
#![feature(rustc_attrs)]
15-
#![feature(unboxed_closures)]
1615
#![deny(hr_lifetime_in_assoc_type)]
1716

1817
trait Foo<'a> {

src/test/compile-fail/associated-types/cache/wasm-issue-32330.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#![allow(dead_code, unused_variables)]
1515
#![deny(hr_lifetime_in_assoc_type)]
16-
#![feature(unboxed_closures)]
1716

1817
use std::str::Chars;
1918

src/test/compile-fail/borrowck/borrowck-call-is-borrow-issue-12224.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Ensure that invoking a closure counts as a unique immutable borrow
1212

13-
#![feature(unboxed_closures)]
14-
1513
type Fn<'a> = Box<FnMut() + 'a>;
1614

1715
struct Test<'a> {

src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(overloaded_calls, unboxed_closures)]
12-
1311
fn a<F:Fn(isize, isize) -> isize>(mut f: F) {
1412
let g = &mut f;
1513
f(1, 2); //~ ERROR cannot borrow `f` as immutable

src/test/compile-fail/feature-gate-unboxed-closures-method-calls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#![allow(dead_code)]
1212

1313
fn foo<F: Fn()>(mut f: F) {
14-
f.call(()); //~ ERROR explicit use of unboxed closure method `call`
15-
f.call_mut(()); //~ ERROR explicit use of unboxed closure method `call_mut`
16-
f.call_once(()); //~ ERROR explicit use of unboxed closure method `call_once`
14+
f.call(()); //~ ERROR use of unstable library feature 'fn_traits'
15+
f.call_mut(()); //~ ERROR use of unstable library feature 'fn_traits'
16+
f.call_once(()); //~ ERROR use of unstable library feature 'fn_traits'
1717
}
1818

1919
fn main() {}

src/test/compile-fail/feature-gate-unboxed-closures-ufcs-calls.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
#![allow(dead_code)]
1212

13-
fn foo<F: Fn()>(mut f: F, mut g: F) {
14-
Fn::call(&g, ()); //~ ERROR explicit use of unboxed closure method `call`
15-
FnMut::call_mut(&mut g, ()); //~ ERROR explicit use of unboxed closure method `call_mut`
16-
FnOnce::call_once(g, ()); //~ ERROR explicit use of unboxed closure method `call_once`
13+
fn foo<F: Fn()>(mut f: F) {
14+
Fn::call(&f, ()); //~ ERROR use of unstable library feature 'fn_traits'
15+
FnMut::call_mut(&mut f, ()); //~ ERROR use of unstable library feature 'fn_traits'
16+
FnOnce::call_once(f, ()); //~ ERROR use of unstable library feature 'fn_traits'
1717
}
1818

1919
fn main() {}

src/test/compile-fail/fn-trait-formatting.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
1211
#![feature(box_syntax)]
1312

1413
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}

src/test/compile-fail/issue-16939.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(overloaded_calls, unboxed_closures)]
12-
1311
// Make sure we don't ICE when making an overloaded call with the
1412
// wrong arity.
1513

src/test/compile-fail/issue-17033.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(overloaded_calls)]
12-
1311
fn f<'r>(p: &'r mut fn(p: &mut ())) {
1412
(*p)(()) //~ ERROR mismatched types
1513
//~| expected type `&mut ()`

src/test/compile-fail/issue-17545.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
pub fn foo<'a, F: Fn(&'a ())>(bar: F) {
1412
bar.call((
1513
&(), //~ ERROR borrowed value does not live long enough

src/test/compile-fail/issue-17551.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
use std::marker;
1412

1513
struct B<T>(marker::PhantomData<T>);

src/test/compile-fail/issue-18532.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// when a type error or unconstrained type variable propagates
1313
// into it.
1414

15-
#![feature(unboxed_closures)]
16-
1715
fn main() {
1816
(return)((),());
1917
//~^ ERROR the type of this value must be known

src/test/compile-fail/issue-19521.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
fn main() {
1412
"".homura()(); //~ ERROR no method named `homura` found
1513
}

src/test/compile-fail/issue-19707.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
1211
#![allow(dead_code)]
1312

1413
type foo = fn(&u8, &u8) -> &u8; //~ ERROR missing lifetime specifier

src/test/compile-fail/issue-4335.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
fn id<T>(t: T) -> T { t }
1412

1513
fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {

src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// bound must be noncopyable. For details see
1313
// http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/
1414

15-
#![feature(unboxed_closures)]
16-
1715
struct R<'a> {
1816
// This struct is needed to create the
1917
// otherwise infinite type of a fn that

src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures, overloaded_calls)]
12-
1311
use std::ops::FnMut;
1412

1513
fn main() {

src/test/compile-fail/regions-escape-unboxed-closure.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
fn with_int(f: &mut FnMut(&isize)) {
1412
}
1513

src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Test that closures cannot subvert aliasing restrictions
1212

13-
#![feature(overloaded_calls, unboxed_closures)]
14-
1513
fn main() {
1614
// Unboxed closure case
1715
{

src/test/compile-fail/regions-steal-closure.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
struct closure_box<'a> {
1412
cl: Box<FnMut() + 'a>,
1513
}

src/test/compile-fail/unboxed-closure-immutable-capture.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
// Test that even unboxed closures that are capable of mutating their
1412
// environment cannot mutate captured variables that have not been
1513
// declared mutable (#18335)

src/test/compile-fail/unboxed-closure-region.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
// Test that an unboxed closure that captures a free variable by
1412
// reference cannot escape the region of that variable.
1513
fn main() {

src/test/compile-fail/unboxed-closure-sugar-nonexistent-trait.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
fn f<F:Nonexist(isize) -> isize>(x: F) {} //~ ERROR trait `Nonexist` is not in scope
1412

1513
type Typedef = isize;

src/test/compile-fail/unboxed-closures-borrow-conflict.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
// Test that an unboxed closure that mutates a free variable will
1412
// cause borrow conflicts.
1513

src/test/compile-fail/unboxed-closures-infer-argument-types-two-region-pointers.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// That a closure whose expected argument types include two distinct
1212
// bound regions.
1313

14-
#![feature(unboxed_closures)]
15-
1614
use std::cell::Cell;
1715

1816
fn doit<T,F>(val: T, f: &F)

src/test/compile-fail/unboxed-closures-infer-explicit-call-too-early.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(unboxed_closures)]
12-
1311
fn main() {
1412
let mut zero = || {};
1513
let () = zero.call_mut(());

0 commit comments

Comments
 (0)