Skip to content

Commit

Permalink
Delay a bug and mark precise_capturing as not incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jun 18, 2024
1 parent 579bc3c commit 2273747
Show file tree
Hide file tree
Showing 36 changed files with 53 additions and 230 deletions.
6 changes: 5 additions & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
None
}
// Ignore `use` syntax since that is not valid in objects.
GenericBound::Use(..) => None,
GenericBound::Use(_, span) => {
this.dcx()
.span_delayed_bug(*span, "use<> not allowed in dyn types");
None
}
}));
let lifetime_bound =
lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ declare_features! (
/// Allows postfix match `expr.match { ... }`
(unstable, postfix_match, "1.79.0", Some(121618)),
/// Allows `use<'a, 'b, A, B>` in `impl Trait + use<...>` for precise capture of generic args.
(incomplete, precise_capturing, "1.79.0", Some(123432)),
(unstable, precise_capturing, "1.79.0", Some(123432)),
/// Allows macro attributes on expressions, statements and non-inline modules.
(unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/call_method_ambiguous.next.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
--> $DIR/call_method_ambiguous.rs:29:13
--> $DIR/call_method_ambiguous.rs:28:13
|
LL | let mut iter = foo(n - 1, m);
| ^^^^^^^^
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/impl-trait/call_method_ambiguous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//@[current] run-pass

#![feature(precise_capturing)]
#![allow(incomplete_features)]

trait Get {
fn get(&mut self) -> u32;
Expand All @@ -24,7 +23,7 @@ where
}
}

fn foo(n: usize, m: &mut ()) -> impl use<'_> Get {
fn foo(n: usize, m: &mut ()) -> impl Get + use<'_> {
if n > 0 {
let mut iter = foo(n - 1, m);
//[next]~^ type annotations needed
Expand Down
1 change: 0 additions & 1 deletion tests/ui/impl-trait/precise-capturing/apit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(precise_capturing)]
//~^ WARN the feature `precise_capturing` is incomplete

fn hello(_: impl Sized + use<>) {}
//~^ ERROR `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
Expand Down
13 changes: 2 additions & 11 deletions tests/ui/impl-trait/precise-capturing/apit.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/apit.rs:1:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
--> $DIR/apit.rs:4:26
--> $DIR/apit.rs:3:26
|
LL | fn hello(_: impl Sized + use<>) {}
| ^^^^^

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

1 change: 0 additions & 1 deletion tests/ui/impl-trait/precise-capturing/bad-lifetimes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(precise_capturing)]
//~^ WARN the feature `precise_capturing` is incomplete

fn no_elided_lt() -> impl Sized + use<'_> {}
//~^ ERROR missing lifetime specifier
Expand Down
19 changes: 5 additions & 14 deletions tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0106]: missing lifetime specifier
--> $DIR/bad-lifetimes.rs:4:39
--> $DIR/bad-lifetimes.rs:3:39
|
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
| ^^ expected named lifetime parameter
Expand All @@ -11,35 +11,26 @@ LL | fn no_elided_lt() -> impl Sized + use<'static> {}
| ~~~~~~~

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

warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/bad-lifetimes.rs:1:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: expected lifetime parameter in `use<...>` precise captures list, found `'_`
--> $DIR/bad-lifetimes.rs:4:39
--> $DIR/bad-lifetimes.rs:3:39
|
LL | fn no_elided_lt() -> impl Sized + use<'_> {}
| ^^

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

error: aborting due to 4 previous errors; 1 warning emitted
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0106, E0261.
For more information about an error, try `rustc --explain E0106`.
1 change: 0 additions & 1 deletion tests/ui/impl-trait/precise-capturing/bad-params.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(precise_capturing)]
//~^ WARN the feature `precise_capturing` is incomplete

fn missing() -> impl Sized + use<T> {}
//~^ ERROR cannot find type `T` in this scope
Expand Down
19 changes: 5 additions & 14 deletions tests/ui/impl-trait/precise-capturing/bad-params.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0412]: cannot find type `T` in this scope
--> $DIR/bad-params.rs:4:34
--> $DIR/bad-params.rs:3:34
|
LL | fn missing() -> impl Sized + use<T> {}
| ^ not found in this scope
Expand All @@ -10,37 +10,28 @@ LL | fn missing<T>() -> impl Sized + use<T> {}
| +++

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

warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/bad-params.rs:1:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: `Self` can't be captured in `use<...>` precise captures list, since it is an alias
--> $DIR/bad-params.rs:12:48
--> $DIR/bad-params.rs:11:48
|
LL | impl MyType {
| ----------- `Self` is not a generic argument, but an alias to the type of the implementation
LL | fn self_is_not_param() -> impl Sized + use<Self> {}
| ^^^^

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

error: aborting due to 4 previous errors; 1 warning emitted
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0411, E0412.
For more information about an error, try `rustc --explain E0411`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(precise_capturing)]
//~^ WARN the feature `precise_capturing` is incomplete

trait Tr {
type Assoc;
Expand Down
15 changes: 3 additions & 12 deletions tests/ui/impl-trait/precise-capturing/capture-parent-arg.stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/capture-parent-arg.rs:1:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
--> $DIR/capture-parent-arg.rs:28:31
--> $DIR/capture-parent-arg.rs:27:31
|
LL | impl<'a> W<'a> {
| -- this lifetime parameter is captured
LL | fn bad1() -> impl Into<<W<'a> as Tr>::Assoc> + use<> {}
| -------------^^------------------------ lifetime captured due to being mentioned in the bounds of the `impl Trait`

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

error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors

This file was deleted.

13 changes: 2 additions & 11 deletions tests/ui/impl-trait/precise-capturing/duplicated-use.real.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
error: duplicate `use<...>` precise capturing syntax
--> $DIR/duplicated-use.rs:8:32
--> $DIR/duplicated-use.rs:7:32
|
LL | fn hello<'a>() -> impl Sized + use<'a> + use<'a> {}
| ^^^^^^^ ------- second `use<...>` here

warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/duplicated-use.rs:4:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

1 change: 0 additions & 1 deletion tests/ui/impl-trait/precise-capturing/duplicated-use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//@[pre_expansion] check-pass

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

#[cfg(real)]
fn hello<'a>() -> impl Sized + use<'a> + use<'a> {}
Expand Down
1 change: 0 additions & 1 deletion tests/ui/impl-trait/precise-capturing/elided.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ check-pass

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

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

Expand Down
11 changes: 0 additions & 11 deletions tests/ui/impl-trait/precise-capturing/elided.stderr

This file was deleted.

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

fn constant<const C: usize>() -> impl Sized + use<> {}
//~^ ERROR `impl Trait` must mention all const parameters in scope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/forgot-to-capture-const.rs:1:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: `impl Trait` must mention all const parameters in scope in `use<...>`
--> $DIR/forgot-to-capture-const.rs:4:34
--> $DIR/forgot-to-capture-const.rs:3:34
|
LL | fn constant<const C: usize>() -> impl Sized + use<> {}
| -------------- ^^^^^^^^^^^^^^^^^^
Expand All @@ -17,5 +8,5 @@ LL | fn constant<const C: usize>() -> impl Sized + use<> {}
|
= note: currently, all const parameters are required to be mentioned in the precise captures list

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

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

fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x }
//~^ ERROR `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/forgot-to-capture-lifetime.rs:1:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list
--> $DIR/forgot-to-capture-lifetime.rs:4:52
--> $DIR/forgot-to-capture-lifetime.rs:3:52
|
LL | fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x }
| -- -----------^^------------
Expand All @@ -17,7 +8,7 @@ LL | fn lifetime_in_bounds<'a>(x: &'a ()) -> impl Into<&'a ()> + use<> { x }
| this lifetime parameter is captured

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

error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0700`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(precise_capturing)]
//~^ WARN the feature `precise_capturing` is incomplete

fn type_param<T>() -> impl Sized + use<> {}
//~^ ERROR `impl Trait` must mention all type parameters in scope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/forgot-to-capture-type.rs:1:12
|
LL | #![feature(precise_capturing)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
= note: `#[warn(incomplete_features)]` on by default

error: `impl Trait` must mention all type parameters in scope in `use<...>`
--> $DIR/forgot-to-capture-type.rs:4:23
--> $DIR/forgot-to-capture-type.rs:3:23
|
LL | fn type_param<T>() -> impl Sized + use<> {}
| - ^^^^^^^^^^^^^^^^^^
Expand All @@ -18,7 +9,7 @@ LL | fn type_param<T>() -> impl Sized + use<> {}
= note: currently, all type parameters are required to be mentioned in the precise captures list

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

error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors

1 change: 0 additions & 1 deletion tests/ui/impl-trait/precise-capturing/higher-ranked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Show how precise captures allow us to skip capturing a higher-ranked lifetime

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

trait Trait<'a> {
type Item;
Expand Down
Loading

0 comments on commit 2273747

Please sign in to comment.