Skip to content

Commit 323712a

Browse files
Rollup merge of #163228 - lsunsi:issue163206, r=ShoyuVanilla
Add regression test for trait predicate with escaping bounds Closes #163206 new test: - fails against f938186 (last commit before fix) - passes against be3d26d (commit with fix) - passes against current tip.
2 parents 6d098b2 + e5b8447 commit 323712a

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/163206>.
2+
//@ check-fail
3+
4+
struct StatSeries {}
5+
6+
impl StatSeries {
7+
fn new<H>(headers: [H; N]) -> () //~ ERROR: cannot find value `N` in this scope [E0425]
8+
where
9+
String: for<'a> From<&'a H>,
10+
{
11+
}
12+
}
13+
14+
fn main() {
15+
let series = StatSeries::new([""]); //~ ERROR: the trait bound `for<'a> String: From<&'a &str>` is not satisfied [E0277]
16+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0425]: cannot find value `N` in this scope
2+
--> $DIR/trait-predicate-with-escaping-bounds.rs:7:28
3+
|
4+
LL | fn new<H>(headers: [H; N]) -> ()
5+
| ^ not found in this scope
6+
7+
error[E0277]: the trait bound `for<'a> String: From<&'a &str>` is not satisfied
8+
--> $DIR/trait-predicate-with-escaping-bounds.rs:15:34
9+
|
10+
LL | let series = StatSeries::new([""]);
11+
| --------------- ^^^^ the trait `for<'a> From<&'a &str>` is not implemented for `String`
12+
| |
13+
| required by a bound introduced by this call
14+
|
15+
= help: `String` implements trait `From<T>`:
16+
From<&String>
17+
From<&mut str>
18+
From<&str>
19+
From<Box<str>>
20+
From<Cow<'_, str>>
21+
From<char>
22+
note: required by a bound in `StatSeries::new`
23+
--> $DIR/trait-predicate-with-escaping-bounds.rs:9:17
24+
|
25+
LL | impl StatSeries {
26+
LL | fn new<H>(headers: [H; N]) -> ()
27+
LL | where
28+
LL | String: for<'a> From<&'a H>,
29+
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `StatSeries::new`
30+
31+
error: aborting due to 2 previous errors
32+
33+
Some errors have detailed explanations: E0277, E0425.
34+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)