Repository navigation
Use reason specifier in allow - #179
Conversation
b722564 to
36d5d82
Compare
|
Ok. Still experimental. |
36d5d82 to
389bf05
Compare
|
still experimental |
389bf05 to
724aeda
Compare
WalkthroughThis pull request adds reason metadata to compiler allow attributes in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
1 similar comment
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
|
Still not available. |
724aeda to
13c367d
Compare
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
Signed-off-by: mulhern <amulhern@redhat.com>
13c367d to
f083558
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/devno.rs (1)
61-61: Version verification needed (same as major).The reason references libc 0.2.171 for
libc::minor, consistent with themajorfunction. Please verify this version number as part of the verification requested for line 53.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/devno.rs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-42-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-41-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-43-x86_64:copr_pull
- GitHub Check: rpm-build:fedora-rawhide-x86_64:copr_pull
🔇 Additional comments (1)
src/devno.rs (1)
47-47: Thereasonparameter inallowattributes is not an unstable feature and does not require a feature gate.The
lint_reasonsfeature was stabilized in Rust 1.81.0. Since this project requires Rust 1.82.0 or later (perrust-versionin Cargo.toml), thereasonparameter is fully supported without needing#![feature(lint_reasons)].The version references in the reasons (libc 0.2.133 and 0.2.171) are forward-looking documentation of when these unsafe blocks may become unnecessary as the libc crate evolves. The project currently uses libc 0.2.121, so these annotations serve as a record for future dependency upgrades.
| /// Get the major number. | ||
| pub fn major(&self) -> maj_t { | ||
| #[allow(unused_unsafe)] | ||
| #[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.171")] |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
libc crate changelog major minor functions safe version history
💡 Result:
Summary — what libc is and its version history
- libc is the Rust crate providing raw, platform-specific FFI bindings (types, constants, extern "C" function signatures). It is intentionally a thin, unsafe binding layer — callers are responsible for safe usage. [1][2]
- The crate moved from 0.1 → 0.2 (RFC 1291) with API/typedef changes (e.g., top-level exports, size_t/ssize_t defined as usize/isize on main platforms). The project maintains a long 0.2.x series while preparing a planned 1.0 (roadmap on the repo). [3][4]
- Current published releases (many 0.2.x releases; recently active: 0.2.17x…/0.2.174 etc. and 1.0.0-alpha releases on the registry). See the releases list for precise version history. [2]
About “major / minor / functions / safe”
- Semantic versioning: libc has stayed at 0.2.* for a long time (breaking changes were made when moving from 0.1 → 0.2). A future 1.0 is planned and may introduce breaking changes; maintainers have discussed migration strategy. [3][4]
- Function safety: libc exposes raw C APIs (extern "C" fn signatures) and thus their use is generally unsafe in Rust — the crate itself does not generally provide safe wrappers. In other words, calling most libc functions requires unsafe or a safe wrapper in a higher-level crate. The README and design rationale describe libc as raw FFI bindings. [1][2]
- Changes making things “safe”: there is no broad history of libc converting C functions into safe Rust APIs inside the crate — safe, ergonomic wrappers are normally provided by other crates (or by application code). libc’s scope is to match platform APIs faithfully rather than to wrap them in safe abstractions. [1][3]
Where to get the authoritative changelog / releases
- GitHub repo (source, CHANGELOG, issues, roadmap, v1.0 branch): rust-lang/libc. Use the Releases/tags and commits for specific change details. [1]
- Crate/release listing (crates.io / lib.rs) shows published versions and dates (0.2.x history and recent alpha 1.0 pre-releases). Check the crate page for exact release timestamps. [2]
If you want, I can:
- fetch the precise 5 most important changelog entries (with dates) from the GitHub Releases/CHANGELOG, or
- list which 0.2.x releases contain specific changes (e.g., 0.2.169 matching rustc c_char changes). Which would you prefer?
🏁 Script executed:
#!/bin/bash
# Check the crate registry info for libc version history
curl -s "https://crates.io/api/v1/crates/libc" | jq '.versions[] | select(.num | test("0.2.17[01]")) | {num: .num, created_at: .created_at}' | head -20Repository: stratis-storage/libblkid-rs
Length of output: 210
🏁 Script executed:
#!/bin/bash
# Try to fetch libc changelog from crates.io or check the GitHub release info
curl -s "https://api.github.com/repos/rust-lang/libc/releases" | jq '.[] | select(.tag_name | test("0.2.171")) | {tag_name: .tag_name, body: .body}' | head -50Repository: stratis-storage/libblkid-rs
Length of output: 3976
Remove or correct the reason attribute — major/minor are still unsafe.
In libc 0.2.171, major, minor, and makedev became const fn (#4208), not safe functions. The #[allow(unused_unsafe)] reason is inaccurate: these functions remain unsafe to call. Either remove the reason or update it to reflect why the unsafe block is genuinely needed.
There was a problem hiding this comment.
⚠️ Potential issue | 🟡 Minor
🧩 Analysis chainRemove or correct the reason attribute —
major/minorare still unsafe.In libc 0.2.171,
major,minor, andmakedevbecameconst fn(#4208), not safe functions. The#[allow(unused_unsafe)]reason is inaccurate: these functions remain unsafe to call. Either remove the reason or update it to reflect why theunsafeblock is genuinely needed.
Developers disagree w/ you and agree w/ me: bdrung/3cpio@52827a6 .
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Fetch the commit that the user referenced
curl -s "https://api.github.com/repos/bdrung/3cpio/commits/52827a6e8136453a19805dd6e1e27fd932d24bfd" | jq -r '.commit.message, .files[].patch' | head -100
Length of output: 987
🏁 Script executed:
#!/bin/bash
# Check libc changelog for makedev/major/minor becoming safe
curl -s "https://raw.githubusercontent.com/rust-lang/libc/main/CHANGELOG.md" | grep -A 5 -B 5 -i "makedev\|major\|minor" | grep -A 5 -B 5 "0.2.1[37]"
Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check the libc PR that made these const fn to see if they also became safe
curl -s "https://api.github.com/repos/rust-lang/libc/pulls/4208" | jq -r '.title, .body'
Length of output: 1443
@mulkieran, you're absolutely right, and I apologize for the incorrect analysis.
The evidence from the commit you linked and the libc PR #4208 clearly shows that makedev, major, and minor were changed to safe const fn in those versions, not just const fn. As the PR description states: "makedev, major and minor are macros on most Unixes, there is no need for them to be unsafe."
Your reason attributes are accurate:
- These functions are no longer unsafe to call
- The
#[allow(unused_unsafe)]is the correct way to handle the now-unnecessaryunsafeblocks - The version information in your reasons is correct
Thank you for the correction and the reference!
🐰💭
/_/
( o.o )
^ <
(thinking...)
🧬 Code Graph Analysis Results
[src/devno.rs] lines (approximate extraction)
- from_device_numbers
"""
pub fn from_device_numbers(major: maj_t, minor: min_t) -> Self {
#[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.133")]
BlkidDevno(unsafe { libc::makedev(major, minor) })
}
"""
- Description: Creates a BlkidDevno from major and minor numbers using libc::makedev. Note the allow attribute with a specific libc version reason.
- major()
"""
pub fn major(&self) -> maj_t {
#[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.171")]
unsafe {
libc::major(self.0)
}
}
"""
- Description: Retrieves the major number from the device number. Uses unsafe block with a libc version-based reason.
- minor()
"""
pub fn minor(&self) -> min_t {
#[allow(unused_unsafe, reason = "No longer unsafe in libc 0.2.171")]
unsafe {
libc::minor(self.0)
}
}
"""
- Description: Retrieves the minor number from the device number. Uses unsafe block with a libc version-based reason.
Related stratis-storage/project#713
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.