Skip to content

Commit 2273747

Browse files
Delay a bug and mark precise_capturing as not incomplete
1 parent 579bc3c commit 2273747

36 files changed

+53
-230
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13851385
None
13861386
}
13871387
// Ignore `use` syntax since that is not valid in objects.
1388-
GenericBound::Use(..) => None,
1388+
GenericBound::Use(_, span) => {
1389+
this.dcx()
1390+
.span_delayed_bug(*span, "use<> not allowed in dyn types");
1391+
None
1392+
}
13891393
}));
13901394
let lifetime_bound =
13911395
lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span));

compiler/rustc_feature/src/unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ declare_features! (
568568
/// Allows postfix match `expr.match { ... }`
569569
(unstable, postfix_match, "1.79.0", Some(121618)),
570570
/// Allows `use<'a, 'b, A, B>` in `impl Trait + use<...>` for precise capture of generic args.
571-
(incomplete, precise_capturing, "1.79.0", Some(123432)),
571+
(unstable, precise_capturing, "1.79.0", Some(123432)),
572572
/// Allows macro attributes on expressions, statements and non-inline modules.
573573
(unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
574574
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.

tests/ui/impl-trait/call_method_ambiguous.next.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/call_method_ambiguous.rs:29:13
2+
--> $DIR/call_method_ambiguous.rs:28:13
33
|
44
LL | let mut iter = foo(n - 1, m);
55
| ^^^^^^^^

tests/ui/impl-trait/call_method_ambiguous.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//@[current] run-pass
44

55
#![feature(precise_capturing)]
6-
#![allow(incomplete_features)]
76

87
trait Get {
98
fn get(&mut self) -> u32;
@@ -24,7 +23,7 @@ where
2423
}
2524
}
2625

27-
fn foo(n: usize, m: &mut ()) -> impl use<'_> Get {
26+
fn foo(n: usize, m: &mut ()) -> impl Get + use<'_> {
2827
if n > 0 {
2928
let mut iter = foo(n - 1, m);
3029
//[next]~^ type annotations needed

tests/ui/impl-trait/precise-capturing/apit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(precise_capturing)]
2-
//~^ WARN the feature `precise_capturing` is incomplete
32

43
fn hello(_: impl Sized + use<>) {}
54
//~^ ERROR `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/apit.rs:1:12
3-
|
4-
LL | #![feature(precise_capturing)]
5-
| ^^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
8-
= note: `#[warn(incomplete_features)]` on by default
9-
101
error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
11-
--> $DIR/apit.rs:4:26
2+
--> $DIR/apit.rs:3:26
123
|
134
LL | fn hello(_: impl Sized + use<>) {}
145
| ^^^^^
156

16-
error: aborting due to 1 previous error; 1 warning emitted
7+
error: aborting due to 1 previous error
178

tests/ui/impl-trait/precise-capturing/bad-lifetimes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(precise_capturing)]
2-
//~^ WARN the feature `precise_capturing` is incomplete
32

43
fn no_elided_lt() -> impl Sized + use<'_> {}
54
//~^ ERROR missing lifetime specifier
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/bad-lifetimes.rs:4:39
2+
--> $DIR/bad-lifetimes.rs:3:39
33
|
44
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
55
| ^^ expected named lifetime parameter
@@ -11,35 +11,26 @@ LL | fn no_elided_lt() -> impl Sized + use<'static> {}
1111
| ~~~~~~~
1212

1313
error[E0261]: use of undeclared lifetime name `'missing`
14-
--> $DIR/bad-lifetimes.rs:11:37
14+
--> $DIR/bad-lifetimes.rs:10:37
1515
|
1616
LL | fn missing_lt() -> impl Sized + use<'missing> {}
1717
| - ^^^^^^^^ undeclared lifetime
1818
| |
1919
| help: consider introducing lifetime `'missing` here: `<'missing>`
2020

21-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
22-
--> $DIR/bad-lifetimes.rs:1:12
23-
|
24-
LL | #![feature(precise_capturing)]
25-
| ^^^^^^^^^^^^^^^^^
26-
|
27-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
28-
= note: `#[warn(incomplete_features)]` on by default
29-
3021
error: expected lifetime parameter in `use<...>` precise captures list, found `'_`
31-
--> $DIR/bad-lifetimes.rs:4:39
22+
--> $DIR/bad-lifetimes.rs:3:39
3223
|
3324
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
3425
| ^^
3526

3627
error: expected lifetime parameter in `use<...>` precise captures list, found `'static`
37-
--> $DIR/bad-lifetimes.rs:8:36
28+
--> $DIR/bad-lifetimes.rs:7:36
3829
|
3930
LL | fn static_lt() -> impl Sized + use<'static> {}
4031
| ^^^^^^^
4132

42-
error: aborting due to 4 previous errors; 1 warning emitted
33+
error: aborting due to 4 previous errors
4334

4435
Some errors have detailed explanations: E0106, E0261.
4536
For more information about an error, try `rustc --explain E0106`.

tests/ui/impl-trait/precise-capturing/bad-params.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(precise_capturing)]
2-
//~^ WARN the feature `precise_capturing` is incomplete
32

43
fn missing() -> impl Sized + use<T> {}
54
//~^ ERROR cannot find type `T` in this scope
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0412]: cannot find type `T` in this scope
2-
--> $DIR/bad-params.rs:4:34
2+
--> $DIR/bad-params.rs:3:34
33
|
44
LL | fn missing() -> impl Sized + use<T> {}
55
| ^ not found in this scope
@@ -10,37 +10,28 @@ LL | fn missing<T>() -> impl Sized + use<T> {}
1010
| +++
1111

1212
error[E0411]: cannot find type `Self` in this scope
13-
--> $DIR/bad-params.rs:7:39
13+
--> $DIR/bad-params.rs:6:39
1414
|
1515
LL | fn missing_self() -> impl Sized + use<Self> {}
1616
| ------------ ^^^^ `Self` is only available in impls, traits, and type definitions
1717
| |
1818
| `Self` not allowed in a function
1919

20-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
21-
--> $DIR/bad-params.rs:1:12
22-
|
23-
LL | #![feature(precise_capturing)]
24-
| ^^^^^^^^^^^^^^^^^
25-
|
26-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
27-
= note: `#[warn(incomplete_features)]` on by default
28-
2920
error: `Self` can't be captured in `use<...>` precise captures list, since it is an alias
30-
--> $DIR/bad-params.rs:12:48
21+
--> $DIR/bad-params.rs:11:48
3122
|
3223
LL | impl MyType {
3324
| ----------- `Self` is not a generic argument, but an alias to the type of the implementation
3425
LL | fn self_is_not_param() -> impl Sized + use<Self> {}
3526
| ^^^^
3627

3728
error: expected type or const parameter in `use<...>` precise captures list, found function
38-
--> $DIR/bad-params.rs:16:32
29+
--> $DIR/bad-params.rs:15:32
3930
|
4031
LL | fn hello() -> impl Sized + use<hello> {}
4132
| ^^^^^
4233

43-
error: aborting due to 4 previous errors; 1 warning emitted
34+
error: aborting due to 4 previous errors
4435

4536
Some errors have detailed explanations: E0411, E0412.
4637
For more information about an error, try `rustc --explain E0411`.

tests/ui/impl-trait/precise-capturing/capture-parent-arg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(precise_capturing)]
2-
//~^ WARN the feature `precise_capturing` is incomplete
32

43
trait Tr {
54
type Assoc;
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/capture-parent-arg.rs:1:12
3-
|
4-
LL | #![feature(precise_capturing)]
5-
| ^^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
8-
= note: `#[warn(incomplete_features)]` on by default
9-
101
error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
11-
--> $DIR/capture-parent-arg.rs:28:31
2+
--> $DIR/capture-parent-arg.rs:27:31
123
|
134
LL | impl<'a> W<'a> {
145
| -- this lifetime parameter is captured
156
LL | fn bad1() -> impl Into<<W<'a> as Tr>::Assoc> + use<> {}
167
| -------------^^------------------------ lifetime captured due to being mentioned in the bounds of the `impl Trait`
178

189
error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
19-
--> $DIR/capture-parent-arg.rs:34:18
10+
--> $DIR/capture-parent-arg.rs:33:18
2011
|
2112
LL | impl<'a> W<'a> {
2213
| -- this lifetime parameter is captured
2314
LL | fn bad2() -> impl Into<<Self as Tr>::Assoc> + use<> {}
2415
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime captured due to being mentioned in the bounds of the `impl Trait`
2516

26-
error: aborting due to 2 previous errors; 1 warning emitted
17+
error: aborting due to 2 previous errors
2718

tests/ui/impl-trait/precise-capturing/duplicated-use.pre_expansion.stderr

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
error: duplicate `use<...>` precise capturing syntax
2-
--> $DIR/duplicated-use.rs:8:32
2+
--> $DIR/duplicated-use.rs:7:32
33
|
44
LL | fn hello<'a>() -> impl Sized + use<'a> + use<'a> {}
55
| ^^^^^^^ ------- second `use<...>` here
66

7-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
8-
--> $DIR/duplicated-use.rs:4:12
9-
|
10-
LL | #![feature(precise_capturing)]
11-
| ^^^^^^^^^^^^^^^^^
12-
|
13-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
14-
= note: `#[warn(incomplete_features)]` on by default
15-
16-
error: aborting due to 1 previous error; 1 warning emitted
7+
error: aborting due to 1 previous error
178

tests/ui/impl-trait/precise-capturing/duplicated-use.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@[pre_expansion] check-pass
33

44
#![feature(precise_capturing)]
5-
//~^ WARN the feature `precise_capturing` is incomplete
65

76
#[cfg(real)]
87
fn hello<'a>() -> impl Sized + use<'a> + use<'a> {}

tests/ui/impl-trait/precise-capturing/elided.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ check-pass
22

33
#![feature(precise_capturing)]
4-
//~^ WARN the feature `precise_capturing` is incomplete
54

65
fn elided(x: &()) -> impl Sized + use<'_> { x }
76

tests/ui/impl-trait/precise-capturing/elided.stderr

-11
This file was deleted.

tests/ui/impl-trait/precise-capturing/forgot-to-capture-const.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(precise_capturing)]
2-
//~^ WARN the feature `precise_capturing` is incomplete
32

43
fn constant<const C: usize>() -> impl Sized + use<> {}
54
//~^ ERROR `impl Trait` must mention all const parameters in scope
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/forgot-to-capture-const.rs:1:12
3-
|
4-
LL | #![feature(precise_capturing)]
5-
| ^^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
8-
= note: `#[warn(incomplete_features)]` on by default
9-
101
error: `impl Trait` must mention all const parameters in scope in `use<...>`
11-
--> $DIR/forgot-to-capture-const.rs:4:34
2+
--> $DIR/forgot-to-capture-const.rs:3:34
123
|
134
LL | fn constant<const C: usize>() -> impl Sized + use<> {}
145
| -------------- ^^^^^^^^^^^^^^^^^^
@@ -17,5 +8,5 @@ LL | fn constant<const C: usize>() -> impl Sized + use<> {}
178
|
189
= note: currently, all const parameters are required to be mentioned in the precise captures list
1910

20-
error: aborting due to 1 previous error; 1 warning emitted
11+
error: aborting due to 1 previous error
2112

tests/ui/impl-trait/precise-capturing/forgot-to-capture-lifetime.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(precise_capturing)]
2-
//~^ WARN the feature `precise_capturing` is incomplete
32

43
fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x }
54
//~^ ERROR `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/forgot-to-capture-lifetime.rs:1:12
3-
|
4-
LL | #![feature(precise_capturing)]
5-
| ^^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
8-
= note: `#[warn(incomplete_features)]` on by default
9-
101
error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
11-
--> $DIR/forgot-to-capture-lifetime.rs:4:52
2+
--> $DIR/forgot-to-capture-lifetime.rs:3:52
123
|
134
LL | fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x }
145
| -- -----------^^------------
@@ -17,7 +8,7 @@ LL | fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x }
178
| this lifetime parameter is captured
189

1910
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds
20-
--> $DIR/forgot-to-capture-lifetime.rs:7:62
11+
--> $DIR/forgot-to-capture-lifetime.rs:6:62
2112
|
2213
LL | fn lifetime_in_hidden<'a>(x: &'a ()) -> impl Sized + use<> { x }
2314
| -- ------------------ ^
@@ -30,6 +21,6 @@ help: to declare that `impl Sized` captures `'a`, you can add an explicit `'a` l
3021
LL | fn lifetime_in_hidden<'a>(x: &'a ()) -> impl Sized + use<> + 'a { x }
3122
| ++++
3223

33-
error: aborting due to 2 previous errors; 1 warning emitted
24+
error: aborting due to 2 previous errors
3425

3526
For more information about this error, try `rustc --explain E0700`.

tests/ui/impl-trait/precise-capturing/forgot-to-capture-type.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(precise_capturing)]
2-
//~^ WARN the feature `precise_capturing` is incomplete
32

43
fn type_param<T>() -> impl Sized + use<> {}
54
//~^ ERROR `impl Trait` must mention all type parameters in scope
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/forgot-to-capture-type.rs:1:12
3-
|
4-
LL | #![feature(precise_capturing)]
5-
| ^^^^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
8-
= note: `#[warn(incomplete_features)]` on by default
9-
101
error: `impl Trait` must mention all type parameters in scope in `use<...>`
11-
--> $DIR/forgot-to-capture-type.rs:4:23
2+
--> $DIR/forgot-to-capture-type.rs:3:23
123
|
134
LL | fn type_param<T>() -> impl Sized + use<> {}
145
| - ^^^^^^^^^^^^^^^^^^
@@ -18,7 +9,7 @@ LL | fn type_param<T>() -> impl Sized + use<> {}
189
= note: currently, all type parameters are required to be mentioned in the precise captures list
1910

2011
error: `impl Trait` must mention the `Self` type of the trait in `use<...>`
21-
--> $DIR/forgot-to-capture-type.rs:8:17
12+
--> $DIR/forgot-to-capture-type.rs:7:17
2213
|
2314
LL | trait Foo {
2415
| --------- `Self` type parameter is implicitly captured by this `impl Trait`
@@ -27,5 +18,5 @@ LL | fn bar() -> impl Sized + use<>;
2718
|
2819
= note: currently, all type parameters are required to be mentioned in the precise captures list
2920

30-
error: aborting due to 2 previous errors; 1 warning emitted
21+
error: aborting due to 2 previous errors
3122

tests/ui/impl-trait/precise-capturing/higher-ranked.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// Show how precise captures allow us to skip capturing a higher-ranked lifetime
44

55
#![feature(lifetime_capture_rules_2024, precise_capturing)]
6-
//~^ WARN the feature `precise_capturing` is incomplete
76

87
trait Trait<'a> {
98
type Item;

0 commit comments

Comments
 (0)