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

Immutable statics should only allow types which are Freeze #12432

Closed
alexcrichton opened this issue Feb 21, 2014 · 4 comments
Closed

Immutable statics should only allow types which are Freeze #12432

alexcrichton opened this issue Feb 21, 2014 · 4 comments
Milestone

Comments

@alexcrichton
Copy link
Member

All statics are placed in rodata by LLVM (we mark them as constant), so any attempt at mutation will not succeed (it will segfault).

See #11583 (comment) and #11583 (comment). I wanted to make an official issue out of those comments.

Despite the discussion in #10577 to work on values of immutable statics, I think that this Freeze bound should apply to the type of the static instead.

Nominating.

@emberian
Copy link
Member

Makes sense, kinda weird that we aren't doing it already.

@flaper87
Copy link
Contributor

Makes sense to me as well! Working on it!

@flaper87 flaper87 self-assigned this Feb 21, 2014
@flaper87
Copy link
Contributor

Just as for the other restrictions, I think Freeze should be evaluated on the value of the static item rather than the type. I'd dare to say that generally speaking rules on immutable static items should always be applied to the value because of enum variants. I'm pretty sure there are some exceptions to this rule, though.

The above is based on recent discussions we had on IRC with @nikomatsakis and his last comments here

@pnkfelix
Copy link
Member

Assigning 1.0, P-backcompat-lang.

@pnkfelix pnkfelix added this to the 1.0 milestone Feb 27, 2014
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2024
[`unused_enumerate_index`]: trigger on method calls

The lint used to check for patterns looking like:
```rs
for (_, x) in some_iter.enumerate() {
    // Index is ignored
}
```

This commit further checks for chained method calls constructs where we
can detect that the index is unused. Currently, this checks only for the
following patterns:
```rs
some_iter.enumerate().map_function(|(_, x)| ..)
let x = some_iter.enumerate();
x.map_function(|(_, x)| ..)
```
where `map_function` is one of `all`, `any`, `filter_map`, `find_map`,
`flat_map`, `for_each` or `map`.

Fixes rust-lang#12411.

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`unused_enumerate_index`]: add detection for method chains such as `iter.enumerate().map(|(_, x)| x)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants