Skip to content
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

returning an unconstrained, bound region should be an error #2478

Closed
nikomatsakis opened this issue Jun 1, 2012 · 8 comments
Closed

returning an unconstrained, bound region should be an error #2478

nikomatsakis opened this issue Jun 1, 2012 · 8 comments
Labels
A-lifetimes Area: Lifetimes / regions A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@nikomatsakis
Copy link
Contributor

If you have a function like this:

fn foo() -> &a.int

we should report an error. The only thing you could legally do in that case is fail or return a static item, so you miight as well write:

fn foo() -> &static.int

This sounds like a good lint warning/error.

@bblum
Copy link
Contributor

bblum commented Sep 27, 2012

My vote is warning rather than error. If you're right that it's always the wrong thing to do, then you shouldn't be able to write non-unsafe code that does this that doesn't error somewhere else.

And maybe you want to try doing it just while hacking / experimenting with the language.

@catamorphism
Copy link
Contributor

Reproduced with d2ad028

fn foo() -> &a/int {
    return &x;
}
const x: int = 5;
fn main() {}

This compiles successfully.

@nikomatsakis
Copy link
Contributor Author

Not critical for 0.6; removing milestone

@catamorphism
Copy link
Contributor

Reproduced with 64963d6

fn foo<'a>() -> &'a int {  //~ ERROR unconstrained region
    return &x;
}
static x: int = 5;
fn main() {}

Still compiles successfully.

@catamorphism
Copy link
Contributor

Nominating for milestone 5, production-ready

catamorphism added a commit to catamorphism/rust that referenced this issue May 21, 2013
@graydon
Copy link
Contributor

graydon commented Jun 6, 2013

just a bug, removing milestone/nomination.

@pnkfelix
Copy link
Member

Visiting for triage email 2013-07-22

reproduced with 8a7b636

@bstrie
Copy link
Contributor

bstrie commented Jul 21, 2014

As of lifetime elision (#15767) we now indeed require a 'static bound in that position. Closing.

@bstrie bstrie closed this as completed Jul 21, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
The per-reachability analysis can have a overhead on the compilation time when assessing a project that has lots of tests. Disable it for now when analyzing tests.

Despite that improvement, assessing the firecracker still takes a long time, even with --only-codegen, due to the number of calls done to goto-cc. Thus, don't use assess here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

6 participants