Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
unboxed-closures and type-alias-impl-trait nll revisions
  • Loading branch information
jackh726 committed Apr 5, 2022
commit f881bf7c0a2c1020e36fd5f35be5ecb5af278966
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: at least one trait must be specified
--> $DIR/generic_type_does_not_live_long_enough.rs:10:24
--> $DIR/generic_type_does_not_live_long_enough.rs:14:24
|
LL | type WrongGeneric<T> = impl 'static;
| ^^^^^^^^^^^^

error: non-defining opaque type use in defining scope
--> $DIR/generic_type_does_not_live_long_enough.rs:6:18
--> $DIR/generic_type_does_not_live_long_enough.rs:10:18
|
LL | let z: i32 = x;
| ^
|
note: used non-generic type `&'static i32` for generic parameter
--> $DIR/generic_type_does_not_live_long_enough.rs:10:19
--> $DIR/generic_type_does_not_live_long_enough.rs:14:19
|
LL | type WrongGeneric<T> = impl 'static;
| ^

error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:14:5
--> $DIR/generic_type_does_not_live_long_enough.rs:18:5
|
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
| - help: consider adding an explicit lifetime bound...: `T: 'static`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: at least one trait must be specified
--> $DIR/generic_type_does_not_live_long_enough.rs:10:24
--> $DIR/generic_type_does_not_live_long_enough.rs:14:24
|
LL | type WrongGeneric<T> = impl 'static;
| ^^^^^^^^^^^^

error: non-defining opaque type use in defining scope
--> $DIR/generic_type_does_not_live_long_enough.rs:6:18
--> $DIR/generic_type_does_not_live_long_enough.rs:10:18
|
LL | let z: i32 = x;
| ^
|
note: used non-generic type `&'static i32` for generic parameter
--> $DIR/generic_type_does_not_live_long_enough.rs:10:19
--> $DIR/generic_type_does_not_live_long_enough.rs:14:19
|
LL | type WrongGeneric<T> = impl 'static;
| ^

error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:14:5
--> $DIR/generic_type_does_not_live_long_enough.rs:18:5
|
LL | t
| ^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#![feature(type_alias_impl_trait)]

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn main() {
let y = 42;
let x = wrong_generic(&y);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^ implementation of `FnOnce` is not general enough
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error[E0308]: mismatched types
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^ one type is more general than the other
|
= note: expected type `for<'r> Fn<(&'r X,)>`
found type `Fn<(&X,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^

error: implementation of `FnOnce` is not general enough
--> $DIR/issue-57611-trait-alias.rs:20:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^ implementation of `FnOnce` is not general enough
Expand Down
6 changes: 5 additions & 1 deletion src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Regression test for issue #57611
// Ensures that we don't ICE
// FIXME: This should compile, but it currently doesn't
// known-bug

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

#![feature(trait_alias)]
#![feature(type_alias_impl_trait)]
Expand All @@ -18,7 +23,6 @@ impl Foo for X {

fn bar(&self) -> Self::Bar {
|x| x
//~^ ERROR implementation of `FnOnce` is not general enough
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-30906.rs:18:5
--> $DIR/issue-30906.rs:22:5
|
LL | test(Compose(f, |_| {}));
| ^^^^ implementation of `FnOnce` is not general enough
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/unboxed-closures/issue-30906.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-30906.rs:18:5
--> $DIR/issue-30906.rs:22:5
|
LL | test(Compose(f, |_| {}));
| ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/unboxed-closures/issue-30906.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#![feature(fn_traits, unboxed_closures)]

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {}

struct Compose<F, G>(F, G);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:17:15
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:21:15
|
LL | x.set(y);
| ^
|
note: ...the reference is valid for the anonymous lifetime #2 defined here...
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:16:14
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:20:14
|
LL | doit(0, &|x, y| {
| ______________^
LL | | x.set(y);
LL | |
LL | |
LL | | });
| |_____^
note: ...but the borrowed content is only valid for the anonymous lifetime #3 defined here
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:16:14
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:20:14
|
LL | doit(0, &|x, y| {
| ______________^
LL | | x.set(y);
LL | |
LL | |
LL | | });
| |_____^

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:17:9
--> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:21:9
|
LL | doit(0, &|x, y| {
| - - has type `&'1 i32`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// That a closure whose expected argument types include two distinct
// bound regions.

// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

use std::cell::Cell;

fn doit<T,F>(val: T, f: &F)
Expand All @@ -14,6 +18,8 @@ fn doit<T,F>(val: T, f: &F)

pub fn main() {
doit(0, &|x, y| {
x.set(y); //~ ERROR E0312
x.set(y);
//[base]~^ ERROR E0312
//[nll]~^^ lifetime may not live long enough
});
}