-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As pointed out, FieldSlot must be invariant
- Loading branch information
1 parent
56c3a26
commit c56be69
Showing
11 changed files
with
311 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use merde_core::FieldSlot; | ||
|
||
fn main() { | ||
let mut option: Option<i32> = None; | ||
let slot = FieldSlot::new(&mut option); | ||
|
||
#[allow(clippy::needless_lifetimes)] | ||
fn take_static_fieldslot<'s>(_f: FieldSlot<'s, 'static>) {} | ||
|
||
take_static_fieldslot(slot); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0597]: `option` does not live long enough | ||
--> tests/ui/static-borrow-lifetime.rs:5:31 | ||
| | ||
4 | let mut option: Option<i32> = None; | ||
| ---------- binding `option` declared here | ||
5 | let slot = FieldSlot::new(&mut option); | ||
| ---------------^^^^^^^^^^^- | ||
| | | | ||
| | borrowed value does not live long enough | ||
| argument requires that `option` is borrowed for `'static` | ||
... | ||
11 | } | ||
| - `option` dropped here while still borrowed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use merde_core::FieldSlot; | ||
|
||
fn main() { | ||
let mut option: Option<i32> = None; | ||
let slot = FieldSlot::new(&mut option); | ||
|
||
#[allow(clippy::needless_lifetimes)] | ||
fn take_static_fieldslot<'borrow>(_f: FieldSlot<'static, 'borrow>) {} | ||
|
||
take_static_fieldslot(slot); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0597]: `option` does not live long enough | ||
--> tests/ui/static-s-lifetime.rs:5:31 | ||
| | ||
4 | let mut option: Option<i32> = None; | ||
| ---------- binding `option` declared here | ||
5 | let slot = FieldSlot::new(&mut option); | ||
| ---------------^^^^^^^^^^^- | ||
| | | | ||
| | borrowed value does not live long enough | ||
| argument requires that `option` is borrowed for `'static` | ||
... | ||
11 | } | ||
| - `option` dropped here while still borrowed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use merde_core::FieldSlot; | ||
|
||
fn main() { | ||
let mut option: Option<i32> = None; | ||
let slot = FieldSlot::new(&mut option); | ||
|
||
fn prove_invariance<'long, 'short: 'long>( | ||
long: FieldSlot<'long, 'long>, | ||
) -> FieldSlot<'short, 'short> { | ||
long // Error: mismatched types | ||
} | ||
|
||
assert!(option.is_none()); | ||
} |
Oops, something went wrong.