Skip to content

Drop 'static for pub const strings #2099

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

Merged
merged 1 commit into from
Nov 26, 2021
Merged

Drop 'static for pub const strings #2099

merged 1 commit into from
Nov 26, 2021

Conversation

aplanas
Copy link
Contributor

@aplanas aplanas commented Sep 17, 2021

Constant and static declaration have a 'static live time by default,
that is already elided since 1.17.

Clippy complains on this kind of strings that are present in the
generated code.

This patch remove the 'static live time for those strings.

Fix #1612

Signed-off-by: Alberto Planas [email protected]

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good (sorry for the lag) but it probably needs a little more work. In particular, we claim to support 1.0-compatible code (see src/features.rs).

At this point, we might get away with breaking that and supporting 1.19+ only, but it might also be worth just adding a RustTarget::Stable_1_17 and check for it.

@aplanas aplanas force-pushed the master branch 2 times, most recently from 73b31dd to 43d31f8 Compare November 8, 2021 12:35
@aplanas
Copy link
Contributor Author

aplanas commented Nov 8, 2021

@emilio Oh I see! Instead of removing RustTarget::Stable_1_0 I removed RustTarget::Stable_1_1 (as seems empty feature-wise) and added RustTarget::Stable_1_17 and a test to cover the old 1.0 behavior where &'static lifetime was added.

Of course, another change is that mod.rs now checks for the static_lifetime_elision feature.

Constant and static declaration have a 'static live time by default,
that is already elided since 1.17.

Clippy complains on this kind of strings that are present in the
generated code.

This patch remove the 'static live time for those strings when rustc >
1.17 via a new added RustFeature.

Fix rust-lang#1612

Signed-off-by: Alberto Planas <[email protected]>
@aplanas
Copy link
Contributor Author

aplanas commented Nov 17, 2021

@emilio Do you see any missing bits in the PR? Maybe you prefer to drop Rust 1.0 support, or improve the tests?

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, sorry, I've just been busy with work and it always takes some mental space to page stuff back in. Looks great, thanks!

@emilio emilio merged commit 04f5c07 into rust-lang:master Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clippy and const and &'static references
3 participants