Skip to content

Commit 36cdd0b

Browse files
Add tests for illegal use bound syntax
1 parent 996e8cb commit 36cdd0b

File tree

9 files changed

+87
-5
lines changed

9 files changed

+87
-5
lines changed

compiler/rustc_ast_lowering/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ ast_lowering_never_pattern_with_guard =
128128
a guard on a never pattern will never be run
129129
.suggestion = remove this guard
130130
131-
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed on argument-position `impl Trait`
131+
ast_lowering_no_precise_captures_on_apit = `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
132132
133133
ast_lowering_previously_used_here = previously used here
134134

compiler/rustc_ast_passes/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ast_passes_assoc_type_without_body =
1414
associated type in `impl` without body
1515
.suggestion = provide a definition for the type
1616
17-
ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax is not allowed in {$loc}
17+
ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax not allowed in {$loc}
1818
1919
ast_passes_at_least_one_trait = at least one trait must be specified
2020

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13841384
self.dcx().emit_err(errors::PreciseCapturingNotAllowedHere {
13851385
loc: ctxt.descr(),
13861386
span: *span,
1387-
})
1387+
});
13881388
}
13891389
},
13901390
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
//~^ WARN the feature `precise_capturing` is incomplete
33

44
fn hello(_: impl Sized + use<>) {}
5-
//~^ ERROR `use<...>` precise capturing syntax not allowed on argument-position `impl Trait`
5+
//~^ ERROR `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
66

77
fn main() {}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | #![feature(precise_capturing)]
77
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
88
= note: `#[warn(incomplete_features)]` on by default
99

10-
error: `use<...>` precise capturing syntax not allowed on argument-position `impl Trait`
10+
error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
1111
--> $DIR/apit.rs:4:26
1212
|
1313
LL | fn hello(_: impl Sized + use<>) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![feature(precise_capturing)]
2+
3+
fn dyn() -> &'static dyn use<> { &() }
4+
//~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use`
2+
--> $DIR/dyn-use.rs:3:26
3+
|
4+
LL | fn dyn() -> &'static dyn use<> { &() }
5+
| ^^^ expected one of `!`, `(`, `::`, `<`, `where`, or `{`
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(precise_capturing)]
2+
//~^ WARN the feature `precise_capturing` is incomplete
3+
4+
trait Foo: use<> {
5+
//~^ ERROR `use<...>` precise capturing syntax not allowed
6+
type Assoc: use<> where (): use<>;
7+
//~^ ERROR `use<...>` precise capturing syntax not allowed
8+
//~| ERROR `use<...>` precise capturing syntax not allowed
9+
}
10+
11+
fn fun<T: use<>>(_: impl use<>) where (): use<> {}
12+
//~^ ERROR `use<...>` precise capturing syntax not allowed
13+
//~| ERROR `use<...>` precise capturing syntax not allowed
14+
//~| ERROR `use<...>` precise capturing syntax not allowed
15+
//~| ERROR at least one trait must be specified
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error: `use<...>` precise capturing syntax not allowed in supertrait bounds
2+
--> $DIR/illegal-positions.rs:4:12
3+
|
4+
LL | trait Foo: use<> {
5+
| ^^^^^
6+
7+
error: `use<...>` precise capturing syntax not allowed in bounds
8+
--> $DIR/illegal-positions.rs:6:29
9+
|
10+
LL | type Assoc: use<> where (): use<>;
11+
| ^^^^^
12+
13+
error: `use<...>` precise capturing syntax not allowed in bounds
14+
--> $DIR/illegal-positions.rs:6:13
15+
|
16+
LL | type Assoc: use<> where (): use<>;
17+
| ^^^^^
18+
19+
error: `use<...>` precise capturing syntax not allowed in bounds
20+
--> $DIR/illegal-positions.rs:11:11
21+
|
22+
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
23+
| ^^^^^
24+
25+
error: `use<...>` precise capturing syntax not allowed in bounds
26+
--> $DIR/illegal-positions.rs:11:43
27+
|
28+
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
29+
| ^^^^^
30+
31+
error: at least one trait must be specified
32+
--> $DIR/illegal-positions.rs:11:21
33+
|
34+
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
35+
| ^^^^^^^^^^
36+
37+
warning: the feature `precise_capturing` is incomplete and may not be safe to use and/or cause compiler crashes
38+
--> $DIR/illegal-positions.rs:1:12
39+
|
40+
LL | #![feature(precise_capturing)]
41+
| ^^^^^^^^^^^^^^^^^
42+
|
43+
= note: see issue #123432 <https://github.com/rust-lang/rust/issues/123432> for more information
44+
= note: `#[warn(incomplete_features)]` on by default
45+
46+
error: `use<...>` precise capturing syntax not allowed in argument-position `impl Trait`
47+
--> $DIR/illegal-positions.rs:11:26
48+
|
49+
LL | fn fun<T: use<>>(_: impl use<>) where (): use<> {}
50+
| ^^^^^
51+
52+
error: aborting due to 7 previous errors; 1 warning emitted
53+

0 commit comments

Comments
 (0)