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

Lint fns that take immutable refs and return mutables #1507

Closed
llogiq opened this issue Feb 3, 2017 · 4 comments · Fixed by #1528
Closed

Lint fns that take immutable refs and return mutables #1507

llogiq opened this issue Feb 3, 2017 · 4 comments · Fixed by #1528
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group T-AST Type: Requires working with the AST

Comments

@llogiq
Copy link
Contributor

llogiq commented Feb 3, 2017

The recent 1.15.0 release had an error where a newly stabilized API function returned a mutable ref from &self. We should lint such functions (and probably allow them around UnsafeCell).

@oli-obk
Copy link
Contributor

oli-obk commented Feb 3, 2017

can you link to that function?

@llogiq
Copy link
Contributor Author

llogiq commented Feb 3, 2017

rust-lang/rust#39465 has the goods

@Manishearth
Copy link
Member

Even unsafecell doesn't do this, it returns mutable raw pointers. And cell/refcell do their own thing.

It's basically very rarely a good idea.

@mcarton mcarton added L-correctness Lint: Belongs in the correctness lint group good-first-issue These issues are a good way to get started with Clippy A-lint Area: New lints T-AST Type: Requires working with the AST labels Feb 3, 2017
@llogiq
Copy link
Contributor Author

llogiq commented Feb 3, 2017

Even better to lint against it.

llogiq added a commit that referenced this issue Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group T-AST Type: Requires working with the AST
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants