-
Notifications
You must be signed in to change notification settings - Fork 497
*: enable borrow_interior_mutable_const clippy lint #31875
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
teskje
merged 2 commits into
MaterializeInc:main
from
teskje:clippy-borrow_interior_mutable_const
Mar 13, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -419,7 +419,7 @@ impl SessionVars { | |
| &WELCOME_MESSAGE, | ||
| ] | ||
| .into_iter() | ||
| .chain(SystemVars::SESSION_VARS.iter().map(|(_name, var)| *var)) | ||
| .chain(SESSION_SYSTEM_VARS.iter().map(|(_name, var)| *var)) | ||
| .map(|var| (var.name, SessionVar::new(var.clone()))) | ||
| .collect(); | ||
|
|
||
|
|
@@ -1070,37 +1070,6 @@ impl Default for SystemVars { | |
| } | ||
|
|
||
| impl SystemVars { | ||
| /// Set of [`SystemVar`]s that can also get set at a per-Session level. | ||
| /// | ||
| /// TODO(parkmycar): Instead of a separate list, make this a field on VarDefinition. | ||
| const SESSION_VARS: LazyLock<BTreeMap<&'static UncasedStr, &'static VarDefinition>> = | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to move this outside the |
||
| LazyLock::new(|| { | ||
| [ | ||
| &APPLICATION_NAME, | ||
| &CLIENT_ENCODING, | ||
| &CLIENT_MIN_MESSAGES, | ||
| &CLUSTER, | ||
| &CLUSTER_REPLICA, | ||
| &CURRENT_OBJECT_MISSING_WARNINGS, | ||
| &DATABASE, | ||
| &DATE_STYLE, | ||
| &EXTRA_FLOAT_DIGITS, | ||
| &INTEGER_DATETIMES, | ||
| &INTERVAL_STYLE, | ||
| &REAL_TIME_RECENCY_TIMEOUT, | ||
| &SEARCH_PATH, | ||
| &STANDARD_CONFORMING_STRINGS, | ||
| &STATEMENT_TIMEOUT, | ||
| &IDLE_IN_TRANSACTION_SESSION_TIMEOUT, | ||
| &TIMEZONE, | ||
| &TRANSACTION_ISOLATION, | ||
| &MAX_QUERY_RESULT_SIZE, | ||
| ] | ||
| .into_iter() | ||
| .map(|var| (UncasedStr::new(var.name()), var)) | ||
| .collect() | ||
| }); | ||
|
|
||
| pub fn new() -> Self { | ||
| let system_vars = vec![ | ||
| &MAX_KAFKA_CONNECTIONS, | ||
|
|
@@ -1273,7 +1242,7 @@ impl SystemVars { | |
| // Include all of our feature flags. | ||
| .chain(definitions::FEATURE_FLAGS.iter().copied()) | ||
| // Include the subset of Session variables we allow system defaults for. | ||
| .chain(Self::SESSION_VARS.values().copied()) | ||
| .chain(SESSION_SYSTEM_VARS.values().copied()) | ||
| .cloned() | ||
| // Include Persist configs. | ||
| .chain(dyncfg_vars) | ||
|
|
@@ -1341,7 +1310,7 @@ impl SystemVars { | |
| self.vars | ||
| .values() | ||
| .map(|v| v.as_var()) | ||
| .filter(|v| !Self::SESSION_VARS.contains_key(UncasedStr::new(v.name()))) | ||
| .filter(|v| !SESSION_SYSTEM_VARS.contains_key(UncasedStr::new(v.name()))) | ||
| } | ||
|
|
||
| /// Returns an iterator over the configuration parameters and their current | ||
|
|
@@ -1356,12 +1325,12 @@ impl SystemVars { | |
| self.vars | ||
| .values() | ||
| .map(|v| v.as_var()) | ||
| .filter(|v| Self::SESSION_VARS.contains_key(UncasedStr::new(v.name()))) | ||
| .filter(|v| SESSION_SYSTEM_VARS.contains_key(UncasedStr::new(v.name()))) | ||
| } | ||
|
|
||
| /// Returns whether or not this parameter can be modified by a superuser. | ||
| pub fn user_modifiable(&self, name: &str) -> bool { | ||
| Self::SESSION_VARS.contains_key(UncasedStr::new(name)) | ||
| SESSION_SYSTEM_VARS.contains_key(UncasedStr::new(name)) | ||
| || name == ENABLE_RBAC_CHECKS.name() | ||
| || name == NETWORK_POLICY.name() | ||
| } | ||
|
|
@@ -2332,6 +2301,37 @@ pub fn is_http_config_var(name: &str) -> bool { | |
| name == WEBHOOK_CONCURRENT_REQUEST_LIMIT.name() | ||
| } | ||
|
|
||
| /// Set of [`SystemVar`]s that can also get set at a per-Session level. | ||
| /// | ||
| /// TODO(parkmycar): Instead of a separate list, make this a field on VarDefinition. | ||
| static SESSION_SYSTEM_VARS: LazyLock<BTreeMap<&'static UncasedStr, &'static VarDefinition>> = | ||
| LazyLock::new(|| { | ||
| [ | ||
| &APPLICATION_NAME, | ||
| &CLIENT_ENCODING, | ||
| &CLIENT_MIN_MESSAGES, | ||
| &CLUSTER, | ||
| &CLUSTER_REPLICA, | ||
| &CURRENT_OBJECT_MISSING_WARNINGS, | ||
| &DATABASE, | ||
| &DATE_STYLE, | ||
| &EXTRA_FLOAT_DIGITS, | ||
| &INTEGER_DATETIMES, | ||
| &INTERVAL_STYLE, | ||
| &REAL_TIME_RECENCY_TIMEOUT, | ||
| &SEARCH_PATH, | ||
| &STANDARD_CONFORMING_STRINGS, | ||
| &STATEMENT_TIMEOUT, | ||
| &IDLE_IN_TRANSACTION_SESSION_TIMEOUT, | ||
| &TIMEZONE, | ||
| &TRANSACTION_ISOLATION, | ||
| &MAX_QUERY_RESULT_SIZE, | ||
| ] | ||
| .into_iter() | ||
| .map(|var| (UncasedStr::new(var.name()), var)) | ||
| .collect() | ||
| }); | ||
|
|
||
| // Provides a wrapper to express that a particular `ServerVar` is meant to be used as a feature | ||
| /// flag. | ||
| #[derive(Debug)] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk what the meaning of the two constants here ("timestamp interval" and "timestamp interval upper bound") is, but it seems like maybe it could be a single constant?