Skip to content

Commit 8b76518

Browse files
committed
add non-regression test for issue 116657
1 parent c104861 commit 8b76518

3 files changed

+105
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0046]: not all trait items implemented, missing: `call`
2+
--> $DIR/location-insensitive-scopes-issue-116657.rs:18:1
3+
|
4+
LL | fn call(x: Self) -> Self::Output;
5+
| --------------------------------- `call` from trait
6+
...
7+
LL | impl<T: PlusOne> Callable for T {
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation
9+
10+
error: unconstrained opaque type
11+
--> $DIR/location-insensitive-scopes-issue-116657.rs:22:19
12+
|
13+
LL | type Output = impl PlusOne;
14+
| ^^^^^^^^^^^^
15+
|
16+
= note: `Output` must be used in combination with a concrete type within the same impl
17+
18+
error[E0700]: hidden type for `impl PlusOne` captures lifetime that does not appear in bounds
19+
--> $DIR/location-insensitive-scopes-issue-116657.rs:28:5
20+
|
21+
LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne {
22+
| -- ------------ opaque type defined here
23+
| |
24+
| hidden type `<&'a mut i32 as Callable>::Output` captures the lifetime `'a` as defined here
25+
LL | <&mut i32 as Callable>::call(y)
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
|
28+
help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound
29+
|
30+
LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a {
31+
| ++++
32+
33+
error: aborting due to 3 previous errors
34+
35+
Some errors have detailed explanations: E0046, E0700.
36+
For more information about an error, try `rustc --explain E0046`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0046]: not all trait items implemented, missing: `call`
2+
--> $DIR/location-insensitive-scopes-issue-116657.rs:18:1
3+
|
4+
LL | fn call(x: Self) -> Self::Output;
5+
| --------------------------------- `call` from trait
6+
...
7+
LL | impl<T: PlusOne> Callable for T {
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation
9+
10+
error: unconstrained opaque type
11+
--> $DIR/location-insensitive-scopes-issue-116657.rs:22:19
12+
|
13+
LL | type Output = impl PlusOne;
14+
| ^^^^^^^^^^^^
15+
|
16+
= note: `Output` must be used in combination with a concrete type within the same impl
17+
18+
error[E0700]: hidden type for `impl PlusOne` captures lifetime that does not appear in bounds
19+
--> $DIR/location-insensitive-scopes-issue-116657.rs:28:5
20+
|
21+
LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne {
22+
| -- ------------ opaque type defined here
23+
| |
24+
| hidden type `<&'a mut i32 as Callable>::Output` captures the lifetime `'a` as defined here
25+
LL | <&mut i32 as Callable>::call(y)
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
|
28+
help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound
29+
|
30+
LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a {
31+
| ++++
32+
33+
error: aborting due to 3 previous errors
34+
35+
Some errors have detailed explanations: E0046, E0700.
36+
For more information about an error, try `rustc --explain E0046`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// This is a non-regression test for issue #116657, where NLL and `-Zpolonius=next` computed
2+
// different loan scopes when a member constraint was not ultimately applied.
3+
4+
// revisions: nll polonius
5+
// [polonius] compile-flags: -Zpolonius=next
6+
7+
#![feature(impl_trait_in_assoc_type)]
8+
9+
trait Callable {
10+
type Output;
11+
fn call(x: Self) -> Self::Output;
12+
}
13+
14+
trait PlusOne {}
15+
16+
impl<'a> PlusOne for &'a mut i32 {}
17+
18+
impl<T: PlusOne> Callable for T {
19+
//[nll]~^ ERROR not all trait items implemented
20+
//[polonius]~^^ ERROR not all trait items implemented
21+
22+
type Output = impl PlusOne;
23+
//[nll]~^ ERROR unconstrained opaque type
24+
//[polonius]~^^ ERROR unconstrained opaque type
25+
}
26+
27+
fn test<'a>(y: &'a mut i32) -> impl PlusOne {
28+
<&mut i32 as Callable>::call(y)
29+
//[nll]~^ ERROR hidden type for `impl PlusOne` captures lifetime
30+
//[polonius]~^^ ERROR hidden type for `impl PlusOne` captures lifetime
31+
}
32+
33+
fn main() {}

0 commit comments

Comments
 (0)