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

syntax: remove obsolete mutability from ExprVec and ExprRepeat. #13308

Closed
wants to merge 1 commit into from

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Apr 4, 2014

No description provided.

@@ -3039,7 +3039,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
fcx.write_bot(id);
}
else {
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: mutbl},
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a mt now, or can it do with just a t?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been wanting to do this for a while, actually.
Mutability of vstore_slice and RegionTraitStore should be stored in the variants themselves, not in ty_vec or ty_trait.

@bors bors closed this in 4cf8d8c Apr 5, 2014
@eddyb eddyb deleted the expr-vec-mut branch April 5, 2014 09:18
@eddyb eddyb restored the expr-vec-mut branch March 8, 2017 19:04
@eddyb eddyb deleted the expr-vec-mut branch March 8, 2017 19:33
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 24, 2024
Look at adjusted types instead of fn signature types in `ptr_arg`

This simplifies the implementation of the `ptr_arg` lint a bit and:
Fixes rust-lang#13308
Fixes rust-lang#10612

Currently, the lint checks if e.g. a `&String` parameter is only used in contexts where a `&str` could work. Part of it worked by looking for path exprs to that parameter in function call position specifically, looking at the callee signature and checking if that parameter type without refs is `String` (or one of a bunch of other special cases).

This simplified version removes the special casing of function calls and looking at the parameter type and instead just looks at the **adjusted type**, regardless of the expression it's in. This naturally also covers what the previous version was doing (if the expression is in a function call argument position expecting a `&str`, then it will have that adjustment. If it requires a `&String` then it won't have that adjustment and we won't lint).

The linked issue was a FP that happened because the previous implementation simply didn't consider projection types in the signature type, but with this simplification we don't really need to consider that (because we aren't looking at function signatures at all anymore -- the `&mut Self::Owned` parameter type of `clone_into` is the already-instantiated and normalized type `&mut String`).

changelog: none
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

Successfully merging this pull request may close these issues.

3 participants