Skip to content
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

String slices as the keys of sendable maps bring about pain #3284

Closed
pcwalton opened this issue Aug 26, 2012 · 4 comments
Closed

String slices as the keys of sendable maps bring about pain #3284

pcwalton opened this issue Aug 26, 2012 · 4 comments
Labels
A-lifetimes Area: Lifetimes / regions

Comments

@pcwalton
Copy link
Contributor

As far as I can see it, the region and slice systems make it impossible to use a send_map<&str,V>, unless you're only comparing static strings. The problem, as far as I can see it, is that find() wants to take its argument by reference, so the region checker requires invariance somehow and borrow check errors happen.

@nikomatsakis, thoughts? Maybe we need a separate StringMap type.

@pcwalton
Copy link
Contributor Author

The other possibility is that we could have a ComparableTo<K> trait and a method find_related<Q:ComparableTo<K>>(&const self, +k: &Q), which gets rid of the need for a StringMap. That signature makes me very sad though.

The basic problem is that the query string isn't the same type as the strings inside the map...

@nikomatsakis
Copy link
Contributor

Currently all type parameters are invariant. I have considered that a distinct StringMap could be useful. However, we could also apply the region variance inference to type parameters without big changes, which would be cool.

@emberian
Copy link
Member

@pcwalton as mentioned in #6095, find_equiv and Equiv present a solution to this.

Can be closed?

@thestinger
Copy link
Contributor

@cmr: I think so, the problem is solved for HashMap since it uses equality

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 11, 2018
Changes:

Remove now-useless `allow(unknown_lints)`
Stabilize tool lints
Use `impl Iterator` in arg position in clippy_dev
Fix fn_to_numeric_cast_with_truncation suppression
Limit commutative assign op lint to primitive types
Clarify code
Fix rust-lang#2937
Fix cast_possible_wrap and cast_sign_loss warnings
Fix cast_possible_truncation warnings
Fixes rust-lang#2925 cmp_owned false positive
if_let_redundant_pattern_matching: use Span.to() instead of Span.with_hi() to fix crash.
Improve diagnostics in case of lifetime elision (closes rust-lang#3284)
Fix items_after_statements for `const`s
Fix items_after_statements for sub-functions
Fix items_after_statements for `use` statements
Don't suggest cloned() for map Box deref
Fix excessive_precision false positive
Fix FP in `fn_to_numeric_cast_with_truncation`
new_without_default should not warn about unsafe new
fix command to manually test an example
Add license to README
Adding more detail to filter_map lint documentation.
additional people
Add license header to other files
Add license header to Rust files
Relicense clippy
Document relicensing process
Fix util/export.py to include lints from methods
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 13, 2018
Changes:

Remove now-useless `allow(unknown_lints)`
Stabilize tool lints
Use `impl Iterator` in arg position in clippy_dev
Fix fn_to_numeric_cast_with_truncation suppression
Limit commutative assign op lint to primitive types
Clarify code
Fix rust-lang#2937
Fix cast_possible_wrap and cast_sign_loss warnings
Fix cast_possible_truncation warnings
Fixes rust-lang#2925 cmp_owned false positive
if_let_redundant_pattern_matching: use Span.to() instead of Span.with_hi() to fix crash.
Improve diagnostics in case of lifetime elision (closes rust-lang#3284)
Fix items_after_statements for `const`s
Fix items_after_statements for sub-functions
Fix items_after_statements for `use` statements
Don't suggest cloned() for map Box deref
Fix excessive_precision false positive
Fix FP in `fn_to_numeric_cast_with_truncation`
new_without_default should not warn about unsafe new
fix command to manually test an example
Add license to README
Adding more detail to filter_map lint documentation.
additional people
Add license header to other files
Add license header to Rust files
Relicense clippy
Document relicensing process
Fix util/export.py to include lints from methods
bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
recognize strings inside comments in order to avoid indenting them
RalfJung pushed a commit to RalfJung/rust that referenced this issue Feb 25, 2024
…Jung

enable from_bitmask_vector test on little-endian targets

Blocked on rust-lang/portable-simd#380 propagating to the rustc repo
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
Replace test used in workflow since we have deleted the function test. I
also made this action mandatory for our PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

4 participants