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

Fix an LLVM assertion when matching against static strings #14752

Merged
merged 2 commits into from Jun 10, 2014
Merged

Fix an LLVM assertion when matching against static strings #14752

merged 2 commits into from Jun 10, 2014

Conversation

ghost
Copy link

@ghost ghost commented Jun 8, 2014

Fixes #8315
Fixes #11940

@@ -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)])
Copy link
Member

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?

Copy link
Author

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!

@ghost
Copy link
Author

ghost commented Jun 8, 2014

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.

bors added a commit that referenced this pull request Jun 10, 2014
@bors bors closed this Jun 10, 2014
@bors bors merged commit f8b4e82 into rust-lang:master Jun 10, 2014
@ghost ghost deleted the issue-11940 branch July 2, 2014 23:42
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants