-
Notifications
You must be signed in to change notification settings - Fork 13.3k
segmentation fault: moved value not detected due to trait usage #14061
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
Comments
A workaround is to define the built-in bound on the trait instead of the implementation: trait Gettable<T:Copy>{
fn get(&self) -> T;
} Then the "not fulfill Pod" error is caught as expected. This could be a backward compatibility hazard. Nominate? |
So a fix might be for the compiler to notice that if an |
cc me |
assigning P-high, Milestone 1. |
this looks related to #5527 etc |
Nominating for closing as a dupe of #2687. If this is not a dupe, then it must be P-backcompat-lang. |
I am not sure this is a dup of #2687 -- that is specific to bounds on methods. |
1.0, backcompat-lang. |
This can break code that looked like: struct S<T> { val: T, } trait Gettable<T> { ... } impl<T: Copy> Gettable<T> for S<T> { ... } let t: Box<S<String>> = box S { val: "one".to_string(), }; let a = t as Box<Gettable<String>>; // ^ note no `Copy` bound Change this code to: impl<T> Gettable<T> for S<T> { // ^ remove `Copy` bound ... } Closes rust-lang#14061. [breaking-change]
Make tt generic over the span data This also fixes up our delimiter representation in tt, it is no longer optional (we use invisible delims in the same way as before, that is still incorrectly) and we now store two spans instead of one. These changes should help with adjusting our token map. Though this will probably break proc-macros in some ways, will need to test that for now.
fix rust-lang#14034 The currect implementation of `obfuscated_if_else` sometimes makes incorrect suggestions when the original code have side effects (see the example in the above issue). I think this can be fixed by changing the applicability depending on whether it can have side effects or not. changelog: [`obfuscated_if_else`]: change applicability when the original code can have side effects
With a little bit of hacking, I found a memory safety violation:
Note: what's the best way to "get" a value via a trait? Copy and restrict to POD types? Reference, even if most of the values accessed are just ints? Or use clone − and risk issues on complex types?
The text was updated successfully, but these errors were encountered: