Skip to content

Watch out for modules privacy when proposing traits to associate with an item #95080

Open
@catenacyber

Description

@catenacyber

Working on suricata OISF/suricata#7150

The current output is:

error[E0599]: no associated item named `MAX` found for type parameter `T` in the current scope
   --> src/detect.rs:109:18
    |
109 |         x < <T>::MAX
    |                  ^^^ associated item not found in `T`
    |
    = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following traits define an item `MAX`, perhaps you need to restrict type parameter `T` with one of them:
    |
104 | fn detect_parse_uint_start_greater<T: lexical_core::util::num::Float + std::str::FromStr>(i: &str) -> IResult<&str, DetectUintData<T>> {
    |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104 | fn detect_parse_uint_start_greater<T: lexical_core::util::num::Integer + std::str::FromStr>(i: &str) -> IResult<&str, DetectUintData<T>> {

This proposal looks interesting but when It tried it, I was disappointed :

error[E0603]: module `util` is private --> src/detect.rs:41:51 | 41 | fn detect_parse_uint_start_equal<T: lexical_core::util::num::Integer>(i: &str) -> IResult<&str, DetectUintData<T>> { | ^^^^ private module | note: the module `util` is defined here --> /Users/catena/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.7.6/src/lib.rs:189:1


<!-- The following is not always necessary. -->
Ideally the output should look like:

"the following traits define an item MAX, you could restrict the type parameter, but it is private so you can't"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`A-visibilityArea: Visibility / privacyD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions