mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Add tests for illegal use bound syntax
This commit is contained in:
parent
b1efe1ab5d
commit
f66558d2bf
@ -128,7 +128,7 @@ ast_lowering_never_pattern_with_guard =
|
||||
a guard on a never pattern will never be run
|
||||
.suggestion = remove this guard
|
||||
|
||||
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed on argument-position `impl Trait`
|
||||
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
|
||||
|
||||
ast_lowering_previously_used_here = previously used here
|
||||
|
||||
|
@ -14,7 +14,7 @@ ast_passes_assoc_type_without_body =
|
||||
associated type in `impl` without body
|
||||
.suggestion = provide a definition for the type
|
||||
|
||||
ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax is not allowed in {$loc}
|
||||
ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax not allowed in {$loc}
|
||||
|
||||
ast_passes_at_least_one_trait = at least one trait must be specified
|
||||
|
||||
|
@ -1424,7 +1424,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
self.dcx().emit_err(errors::PreciseCapturingNotAllowedHere {
|
||||
loc: ctxt.descr(),
|
||||
span: *span,
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
//~^ WARN the feature `precise_capturing` is incomplete
|
||||
|
||||
fn hello(_: impl Sized + use<>) {}
|
||||
//~^ ERROR `use<...>` precise capturing syntax not allowed on argument-position `impl Trait`
|
||||
//~^ ERROR `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
|
||||
|
||||
fn main() {}
|
||||
|
@ -7,7 +7,7 @@ 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 on argument-position `impl Trait`
|
||||
error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
|
||||
--> $DIR/apit.rs:4:26
|
||||
|
|
||||
LL | fn hello(_: impl Sized + use<>) {}
|
||||
|
4
tests/ui/impl-trait/precise-capturing/dyn-use.rs
Normal file
4
tests/ui/impl-trait/precise-capturing/dyn-use.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#![feature(precise_capturing)]
|
||||
|
||||
fn dyn() -> &'static dyn use<> { &() }
|
||||
//~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use`
|
8
tests/ui/impl-trait/precise-capturing/dyn-use.stderr
Normal file
8
tests/ui/impl-trait/precise-capturing/dyn-use.stderr
Normal file
@ -0,0 +1,8 @@
|
||||
error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use`
|
||||
--> $DIR/dyn-use.rs:3:26
|
||||
|
|
||||
LL | fn dyn() -> &'static dyn use<> { &() }
|
||||
| ^^^ expected one of `!`, `(`, `::`, `<`, `where`, or `{`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
@ -0,0 +1,11 @@
|
||||
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/illegal-positions.rs:5: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
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -0,0 +1,66 @@
|
||||
error: `use<...>` precise capturing syntax not allowed in supertrait bounds
|
||||
--> $DIR/illegal-positions.rs:9:12
|
||||
|
|
||||
LL | trait Foo: use<> {
|
||||
| ^^^^^
|
||||
|
||||
error: `use<...>` precise capturing syntax not allowed in bounds
|
||||
--> $DIR/illegal-positions.rs:11:33
|
||||
|
|
||||
LL | type Assoc: use<> where (): use<>;
|
||||
| ^^^^^
|
||||
|
||||
error: `use<...>` precise capturing syntax not allowed in bounds
|
||||
--> $DIR/illegal-positions.rs:11:17
|
||||
|
|
||||
LL | type Assoc: use<> where (): use<>;
|
||||
| ^^^^^
|
||||
|
||||
error: `use<...>` precise capturing syntax not allowed in bounds
|
||||
--> $DIR/illegal-positions.rs:17:11
|
||||
|
|
||||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
|
||||
| ^^^^^
|
||||
|
||||
error: `use<...>` precise capturing syntax not allowed in bounds
|
||||
--> $DIR/illegal-positions.rs:17:43
|
||||
|
|
||||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
|
||||
| ^^^^^
|
||||
|
||||
error: at least one trait must be specified
|
||||
--> $DIR/illegal-positions.rs:17:21
|
||||
|
|
||||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds
|
||||
--> $DIR/illegal-positions.rs:24:25
|
||||
|
|
||||
LL | fn dynamic() -> Box<dyn use<>> {}
|
||||
| ^^^^^
|
||||
|
||||
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/illegal-positions.rs:5: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/illegal-positions.rs:17:26
|
||||
|
|
||||
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
|
||||
| ^^^^^
|
||||
|
||||
error[E0224]: at least one trait is required for an object type
|
||||
--> $DIR/illegal-positions.rs:24:21
|
||||
|
|
||||
LL | fn dynamic() -> Box<dyn use<>> {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 9 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0224`.
|
28
tests/ui/impl-trait/precise-capturing/illegal-positions.rs
Normal file
28
tests/ui/impl-trait/precise-capturing/illegal-positions.rs
Normal file
@ -0,0 +1,28 @@
|
||||
//@ revisions: real pre_expansion
|
||||
//@[pre_expansion] check-pass
|
||||
//@ edition: 2021
|
||||
|
||||
#![feature(precise_capturing)]
|
||||
//~^ WARN the feature `precise_capturing` is incomplete
|
||||
|
||||
#[cfg(real)]
|
||||
trait Foo: use<> {
|
||||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed
|
||||
type Assoc: use<> where (): use<>;
|
||||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed
|
||||
//[real]~| ERROR `use<...>` precise capturing syntax not allowed
|
||||
}
|
||||
|
||||
#[cfg(real)]
|
||||
fn fun<T: use<>>(_: impl use<>) where (): use<> {}
|
||||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed
|
||||
//[real]~| ERROR `use<...>` precise capturing syntax not allowed
|
||||
//[real]~| ERROR `use<...>` precise capturing syntax not allowed
|
||||
//[real]~| ERROR at least one trait must be specified
|
||||
|
||||
#[cfg(real)]
|
||||
fn dynamic() -> Box<dyn use<>> {}
|
||||
//[real]~^ ERROR `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds
|
||||
//[real]~| ERROR at least one trait is required for an object type [E0224]
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user