Open mkatychev opened 1 week ago
- Handle
PartialOrd
warning: https://github.com/pchampin/mownstr/pull/7/files#r1700986647
done in b1f4078 (part of #8)
- Handle warnings here: https://github.com/pchampin/mownstr/issues/5#issuecomment-2342290884
which links to
I would like to follow up with the clippy lints for the naming schema in a breaking:
MownStr::from_str
andMownStr::borrowed
are too similar to stdlib methods and made debugging a crate that borrows from strings quite confusing.
I see how MownStr::from_str
clashes with FromStr::from_str
and how this can cause confusing compiler errors. Ok to change it. Suggestion for a better name?
For MownStr::borrowed
, I don't see where the issue is comming from. The std lib does not seem to have a method with that name.
- Add
#[expect(clippy::mutable_key_type)]
for genericK
eys that need to beHash
such as inHashMap<MownStr, V>
I don't really get what the issue is here. Could you please open a separate issue for this, with an example of code that causes the issue with clippy?
- Add
#[expect(clippy::mutable_key_type)]
for genericK
eys that need to beHash
such as inHashMap<MownStr, V>
I don't really get what the issue is here. Could you please open a separate issue for this, with an example of code that causes the issue with clippy?
The issue is the same as https://github.com/rust-lang/rust-clippy/issues/5812 When I tried holding a BTreeMap<MownStr, T>
.
I managed to address the issue on my side by having a .clippy.toml
file in my workspace:
# https://github.com/ruma/ruma/blob/main/.clippy.toml
ignore-interior-mutability = ["mownstr::MownStr"]
I imagine others that use MownStr
or sophia_iri::IriRef<MownStr>
as a key in a map might run into the same issue so it would not hurt to document it.
The only reason bytes::Bytes
does not trip this flag is because it is part of the default ignore-interior-mutability
config in clippy for example.
I see how
MownStr::from_str
clashes withFromStr::from_str
and how this can cause confusing compiler errors. Ok to change it. Suggestion for a better name?
Perhaps ::from_slice
or ::from_ref
?
When I tried holding a
BTreeMap<MownStr, T>
.
I tried to put this in a test (with a HashMap rather than a BTreeMap, but I imagine the problem should be the same), and I didn't get any clippy warning... Are you using specific clippy options to encounter the problem? Can you maybe make a PR that exhibits the issue?
For such cases (checking that something compiles and does not raise linter warnings), I create a function in the test module, not annotated as test
(no need to run it), but annotated as allow(dead_code)
.
I see how
MownStr::from_str
clashes withFromStr::from_str
and how this can cause confusing compiler errors. Ok to change it. Suggestion for a better name?Perhaps
::from_slice
or::from_ref
?
done in f9b8667
When I tried holding a
BTreeMap<MownStr, T>
.I tried to put this in a test (with a HashMap rather than a BTreeMap, but I imagine the problem should be the same), and I didn't get any clippy warning... Are you using specific clippy options to encounter the problem? Can you maybe make a PR that exhibits the issue?
For such cases (checking that something compiles and does not raise linter warnings), I create a function in the test module, not annotated as
test
(no need to run it), but annotated asallow(dead_code)
.
This was my fault, it seems that this issue only came up in https://github.com/pchampin/mownstr/pull/7
Once https://github.com/pchampin/mownstr/pull/11 is reviewed, this can be closed.
PartialOrd
warning: https://github.com/pchampin/mownstr/pull/7/files#r1700986647