Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

ices/107409.rs: fixed with errors #1698

Merged
merged 1 commit into from
Nov 23, 2023
Merged

ices/107409.rs: fixed with errors #1698

merged 1 commit into from
Nov 23, 2023

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#107409

use std::marker::PhantomData as Boo;

struct Gc<'gc, T: 'gc>(Boo<fn(&'gc T) -> &'gc T>);

trait Rootable<'env> {
    type AsRoot<'r>: Rootable<'r> + 'r
    where
        'env: 'r;
}

impl<'env, T: Rootable<'env>> Rootable<'env> for Gc<'env, T> {
    type AsRoot<'r> = Gc<'r, T::AsRoot<'r>> where 'env: 'r;
}

impl<'env> Rootable<'env> for i32 {
    type AsRoot<'r> = i32 where 'env: 'r;
}

fn reroot<'gc, T: Rootable<'gc>>(_t: T, _f: for<'a> fn(T::AsRoot<'a>)) {}

fn test<'gc>(t: Gc<'gc, i32>) {
    reroot(t, |_| ());
}

fn main() {}
=== stdout ===
=== stderr ===
error[E0521]: borrowed data escapes outside of function
  --> /home/runner/work/glacier/glacier/ices/107409.rs:22:5
   |
21 | fn test<'gc>(t: Gc<'gc, i32>) {
   |         ---  - `t` is a reference that is only valid in the function body
   |         |
   |         lifetime `'gc` defined here
22 |     reroot(t, |_| ());
   |     ^^^^^^^^^^^^^^^^^
   |     |
   |     `t` escapes the function body here
   |     argument requires that `'gc` must outlive `'static`
   |
   = note: requirement occurs because of the type `Gc<'_, i32>`, which makes the generic argument `'_` invariant
   = note: the struct `Gc<'gc, T>` is invariant over the parameter `'gc`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error: aborting due to previous error

For more information about this error, try `rustc --explain E0521`.
==============

=== stdout ===
=== stderr ===
error[E0521]: borrowed data escapes outside of function
  --> /home/runner/work/glacier/glacier/ices/107409.rs:22:5
   |
21 | fn test<'gc>(t: Gc<'gc, i32>) {
   |         ---  - `t` is a reference that is only valid in the function body
   |         |
   |         lifetime `'gc` defined here
22 |     reroot(t, |_| ());
   |     ^^^^^^^^^^^^^^^^^
   |     |
   |     `t` escapes the function body here
   |     argument requires that `'gc` must outlive `'static`
   |
   = note: requirement occurs because of the type `Gc<'_, i32>`, which makes the generic argument `'_` invariant
   = note: the struct `Gc<'gc, T>` is invariant over the parameter `'gc`
   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error: aborting due to previous error

For more information about this error, try `rustc --explain E0521`.
==============
@JohnTitor JohnTitor merged commit 0a6c721 into master Nov 23, 2023
@JohnTitor JohnTitor deleted the autofix/ices/107409.rs branch November 23, 2023 08:08
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants