Skip to content

Constant variable improvements. #260

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

Merged
merged 9 commits into from
Nov 16, 2016
Merged

Conversation

emilio
Copy link
Contributor

@emilio emilio commented Nov 15, 2016

Fixes #256.

r? @fitzgen

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@emilio emilio changed the title Generate macro string constants. Constant variable improvements. Nov 15, 2016
@fitzgen
Copy link
Member

fitzgen commented Nov 15, 2016

@emilio CI is failing, going to hold off on reviewing this until you fix it. Ping me when its ready :)

@emilio
Copy link
Contributor Author

emilio commented Nov 15, 2016

@fitzgen CI is failing due to the functions not present in llvm3.8. I didn't want to bring back the python infra having #204 so close, so I'm waiting for that :)

@bors-servo
Copy link

☔ The latest upstream changes (presumably #263) made this pull request unmergeable. Please resolve the merge conflicts.

@bors-servo
Copy link

☔ The latest upstream changes (presumably #261) made this pull request unmergeable. Please resolve the merge conflicts.

@emilio emilio force-pushed the macro-str branch 2 times, most recently from dfc1141 to fe26aea Compare November 15, 2016 20:05
@emilio
Copy link
Contributor Author

emilio commented Nov 15, 2016

This should be ready for review @fitzgen

@emilio emilio force-pushed the macro-str branch 5 times, most recently from ea35be8 to 1536cf7 Compare November 15, 2016 21:28
@bors-servo
Copy link

☔ The latest upstream changes (presumably #266) made this pull request unmergeable. Please resolve the merge conflicts.

@emilio
Copy link
Contributor Author

emilio commented Nov 16, 2016

Ok, CI is green after removing nightly builds.

@emilio
Copy link
Contributor Author

emilio commented Nov 16, 2016

This includes the fix for #271, given without the changes in this PR to the test suite adding new tests correctly is a pain.

…o USR.

Apparently MSVC isn't that good at giving us USRs...

Fixes rust-lang#271
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for breaking this up into nice little commits :)

let _ = writeln!(dst, "test_header!(header_{}, {:?});",
func, entry.path());
writeln!(dst, "test_header!(header_{}, {:?});",
func, entry.path()).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Did you rustfmt this? I'd think it would put each parameter on its own line if they are too long to fit on one line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't because cargo fmt doesn't detect the build.rs file apparently. Probably worth making it recognise it as a followup.

/// Create a dummy EvalResult.
pub fn new(_: Cursor) -> Self {
EvalResult {
x: ::std::ptr::null_mut(),
Copy link
Member

Choose a reason for hiding this comment

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

use std::ptr at the top?

}
Err(..) => {
const_item
.build(helpers::ast_ty::byte_array_expr(bytes))
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should always make C strings a byte array...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just because the bytestring reads better, but should be effectively equivalent.

Choose a reason for hiding this comment

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

@emilio

It's just because the bytestring reads better, but should be effectively equivalent

actually bindgen generates i8 byte arrays for literal strings in processor definitions. u8 arrays would IMHO be a more useful resp. *const c_char compatible representation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you file an issue with a test-case? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you file an issue with a test-case? Thanks!

Copy link

@mash-graz mash-graz Sep 26, 2018

Choose a reason for hiding this comment

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

i wrote an issue ticket in the meanwhile: #1401

but i think it's more an issue, which rather needs contemplation than any example, where it leads to unpleasant results.

@@ -123,6 +123,14 @@ impl Type {
Self::new(Some(name), None, kind, false)
}

/// Is this an floating point type?
Copy link
Member

Choose a reason for hiding this comment

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

"an" -> "a"

c_str.to_string_lossy().into_owned()
let ret = c_str.to_string_lossy().into_owned();
clang_disposeString(self);
ret
Copy link
Member

Choose a reason for hiding this comment

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

... lol ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a big deal because they're refcounted, but still...

@emilio
Copy link
Contributor Author

emilio commented Nov 16, 2016

@bors-servo r=fitzgen

Thanks for the review Nick, and sorry for this patch pile :/

@bors-servo
Copy link

📌 Commit 19d36d4 has been approved by fitzgen

@bors-servo
Copy link

⌛ Testing commit 19d36d4 with merge e74acce...

bors-servo pushed a commit that referenced this pull request Nov 16, 2016
Constant variable improvements.

Fixes #256.

r? @fitzgen
@bors-servo
Copy link

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 19d36d4 into rust-lang:master Nov 16, 2016
@emilio emilio deleted the macro-str branch November 16, 2016 21:29
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.

5 participants