-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Do not ignore lifetime bounds in Copy impls #47877
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
substs: tcx.mk_substs_trait(place_ty.to_ty(tcx), &[]), | ||
}; | ||
|
||
self.cx.prove_trait_ref(trait_ref, location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment here:
In order to have a Copy
operand, the type T
of the value must be Copy
. Note that we prove that T: Copy
, rather than using the type_moves_by_default
test. This is important because type_moves_by_default
ignores the resulting region obligations and assumes they pass. This can result in bounds from Copy
impls being unsoundly ignored (e.g., #29149). Note that we decide to use Copy
before knowing whether the bounds fully apply: in effect, the rule is that if a value of some type could implement Copy
, then it must.
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(nll)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment that mentions #29149 ? You could basically copy and paste the comment I described above.
59d11b0
to
dbe7bda
Compare
@nikomatsakis Comments added! |
@bors r+ |
📌 Commit dbe7bda has been approved by |
dbe7bda
to
b9f7564
Compare
@bors r+ |
📌 Commit b9f7564 has been approved by |
… r=nikomatsakis Do not ignore lifetime bounds in Copy impls cc rust-lang#29149 r? @nikomatsakis
… r=nikomatsakis Do not ignore lifetime bounds in Copy impls cc rust-lang#29149 r? @nikomatsakis
… r=nikomatsakis Do not ignore lifetime bounds in Copy impls cc rust-lang#29149 r? @nikomatsakis
cc #29149
r? @nikomatsakis