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

fix: nightly warning in server macro for lifetime #1580

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

markcatley
Copy link
Contributor

On the latest lifetime we're getting the following warning in the server macro:
warning: & without an explicit lifetime name cannot be used here
--> src/login.rs:19:1
|
19 | #[server(Login, "/api")]
| ^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #115010 rust-lang/rust#115010
= note: this warning originates in the attribute macro server (in Nightly builds, run with -Z macro-backtrace for more info)

On the latest lifetime we're getting the following warning in the server
macro:
 warning: `&` without an explicit lifetime name cannot be used here
   --> src/login.rs:19:1
    |
 19 | #[server(Login, "/api")]
    | ^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #115010 <rust-lang/rust#115010>
    = note: this warning originates in the attribute macro `server` (in Nightly builds, run with -Z macro-backtrace for more info)
@gbj
Copy link
Collaborator

gbj commented Aug 24, 2023

Personally, in our case I think this compiler warning is extremely silly. But we will do what we need to please rustc 🙂

As in, the compiler is claiming that this

const PREFIX: &str = "/api";

needs to be this

const PREFIX: &'static str = "/api";

because the lifetime of associated constants has never been formally defined as 'static. Fair enough, but... it's a string literal.

@gbj gbj merged commit 533fccd into leptos-rs:main Aug 24, 2023
@gbj
Copy link
Collaborator

gbj commented Aug 24, 2023

Rereading the issue after a cup of coffee I see that they are actually talking about exactly this situation — apparently an associated string literal currently desugars to

struct Foo;
impl<'a> Foo {
    const STR: &'a str = "hello, world";
}

That makes no sense to me at all, but whatever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants