-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix an LLVM assertion when matching against static strings #14752
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
Conversation
@@ -599,7 +599,7 @@ pub fn C_str_slice(cx: &CrateContext, s: InternedString) -> ValueRef { | |||
let len = s.get().len(); | |||
let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s, false), | |||
Type::i8p(cx).to_ref()); | |||
C_struct(cx, [cs, C_uint(cx, len)], false) | |||
C_named_struct(cx.tn.find_type("str_slice").unwrap(), [cs, C_uint(cx, len)]) |
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.
Oh interesting! With this change, could you see if the bitcast here could be removed?
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.
I was actually looking at this just now and yes, it should be doable!
Not entirely convinced this is the right way to fix it so I'd love to hear from someone who knows this stuff. But it boils down to the fact that const strings evaluate to a { i8_, i64 } struct which then cannot be Stored in a %str_slice_ pointer, even though it's a type alias (tripped on another LLVM assertion after I added the auto ref handling). An alternative, having a bit cast/pointer cast just for string slices in the matching code, seemed like a hack to me. |
…entation, r=Veykril fix: assists no longer break indentation Fixes rust-lang/rust-analyzer#14674 These are _ad hoc_ patches for a number of assists that can produce incorrectly indented code, namely: - generate_derive - add_missing_impl_members - add_missing_default_members Some general solution is required in future, as the same problem arises in many other assists, e.g. - replace_derive_with... - generate_default_from_enum... - generate_default_from_new - generate_delegate_methods (the list is incomplete)
changelog: [`type_repetition_in_bounds`]: include all generic bounds in suggestion, clearer message which now includes the repeated type name Fixes rust-lang/rust-clippy#14744
Fixes #8315
Fixes #11940