Skip to content

Extend Level API #121230

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 19, 2024
Merged

Extend Level API #121230

merged 1 commit into from
Feb 19, 2024

Conversation

GuillaumeGomez
Copy link
Member

I need this API for rust-lang/rust-clippy#12303: I have a nested cfg attribute (so a MetaItem) and I'd like to still be able to match against all possible kind of Levels.

@rustbot
Copy link
Collaborator

rustbot commented Feb 17, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 17, 2024
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Fixed format.

@petrochenkov
Copy link
Contributor

I'm on vacation.
r? compiler

@rustbot rustbot assigned Nadrieril and unassigned petrochenkov Feb 17, 2024
/// level as that would require a [`LintExpectationId`]
pub fn from_str(x: &str) -> Option<Level> {
/// level as that would require a [`LintExpectationId`].
pub fn from_str(x: &str) -> Option<Self> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn from_str(x: &str) -> Option<Self> {
pub fn from_str(x: &str) -> Option<Level> {

sym::warn => Some(Level::Warn),
sym::deny => Some(Level::Deny),
sym::forbid => Some(Level::Forbid),
pub fn from_attr(attr: &Attribute) -> Option<Self> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn from_attr(attr: &Attribute) -> Option<Self> {
pub fn from_attr(attr: &Attribute) -> Option<Level> {

Self::from_symbol(attr.name_or_empty(), Some(attr.id))
}

pub fn from_symbol(s: Symbol, id: Option<AttrId>) -> Option<Self> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn from_symbol(s: Symbol, id: Option<AttrId>) -> Option<Self> {
pub fn from_symbol(s: Symbol, id: Option<AttrId>) -> Option<Level> {

@Nadrieril
Copy link
Member

I have no opinion on Level vs Self. r=me with or without that change once CI is green

@Nadrieril
Copy link
Member

@bors rollup=always

@GuillaumeGomez
Copy link
Member Author

@bors r=Nadrieril

@bors
Copy link
Collaborator

bors commented Feb 18, 2024

📌 Commit c17539c has been approved by Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 18, 2024
…=Nadrieril

Extend Level API

I need this API for rust-lang/rust-clippy#12303: I have a nested `cfg` attribute (so a `MetaItem`) and I'd like to still be able to match against all possible kind of `Level`s.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2024
…llaumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#121067 (make "invalid fragment specifier" translatable)
 - rust-lang#121079 (distribute tool documentations and avoid file conflicts on `x install`)
 - rust-lang#121230 (Extend Level API)
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121247 (Add help to `hir_analysis_unrecognized_intrinsic_function`)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 19, 2024
…=Nadrieril

Extend Level API

I need this API for rust-lang/rust-clippy#12303: I have a nested `cfg` attribute (so a `MetaItem`) and I'd like to still be able to match against all possible kind of `Level`s.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#119808 (Store core::str::CharSearcher::utf8_size as u8)
 - rust-lang#121032 (Continue reporting remaining errors instead of silently dropping them)
 - rust-lang#121041 (Add `Future` and `IntoFuture` to the 2024 prelude)
 - rust-lang#121230 (Extend Level API)
 - rust-lang#121272 (Add diagnostic items for legacy numeric constants)
 - rust-lang#121275 (add test for panicking attribute macros)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ec07410 into rust-lang:master Feb 19, 2024
@rustbot rustbot added this to the 1.78.0 milestone Feb 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2024
Rollup merge of rust-lang#121230 - GuillaumeGomez:extend-level-api, r=Nadrieril

Extend Level API

I need this API for rust-lang/rust-clippy#12303: I have a nested `cfg` attribute (so a `MetaItem`) and I'd like to still be able to match against all possible kind of `Level`s.
@GuillaumeGomez GuillaumeGomez deleted the extend-level-api branch February 19, 2024 15:56
bors added a commit to rust-lang/rust-clippy that referenced this pull request Feb 28, 2024
Improve `is_lint_level` code

Since rust-lang/rust#121230 was merged, we can now rely on `Level` directly instead of keeping the list of symbols to check in clippy.

changelog: Improve `is_lint_level` code
bors added a commit to rust-lang/rust-clippy that referenced this pull request Feb 28, 2024
Improve `is_lint_level` code

Since rust-lang/rust#121230 was merged, we can now rely on `Level` directly instead of keeping the list of symbols to check in clippy.

changelog: Improve `is_lint_level` code
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants