Skip to content

subst of region var for region param not happening on iface #3010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nikomatsakis opened this issue Jul 24, 2012 · 1 comment
Closed

subst of region var for region param not happening on iface #3010

nikomatsakis opened this issue Jul 24, 2012 · 1 comment
Labels
A-lifetimes Area: Lifetimes / regions

Comments

@nikomatsakis
Copy link
Contributor

Compiling this code gives you an error message, but not the right one. I get

reference is not valid outside of its lifetime, &self

which suggests that some substitution is not occuring, as I would expect &self to be replaced with the free & region defined in the callback. Maybe the same bug as @catamorphism diagnosed regarding the replacement of ty params with tyvars in the vtable code.

iface deref {
    fn get() -> int;
}

impl of deref for &int {
    fn get() -> int {
        *self
    }
}

fn with<R: deref>(f: fn(x: &int) -> R) -> int {
    f(&3).get()
}

fn return_it() -> int {
    with(|o| o)
}

fn main() {
    let x = return_it();
    #debug["foo=%d", x];
}
@nikomatsakis
Copy link
Contributor Author

never mind, this turned out to be related to #3011 and is now fixed

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
Refactor the corner case of handling long function
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 6, 2023
add test checking that overlapping assignments work
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
This change adds "unused_mut" to the list of suppressed lints for
wrappers generated by the contracts macros. This will get rid of
spurious errors caused by mutable parameters to functions.

This fixes the example from
model-checking/kani#3010 .

It can be tested by adding the example from the issues to
tests/expected/test_macros/gcd.rs, creating a file
tests/expected/test_macros/gcd.expected, then running
```bash
cargo build-dev
RUST_BACKTRACE=1 cargo run -p compiletest -- --logfile logfile.txt --suite expected --mode expected --ignored --no-fail-fast --src-base tests/expected/test_macros
 ```
 
 RESOLVES rust-lang#3010 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: Jacob Salzberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

1 participant