Skip to content

Fix #6031 #8906

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

Closed
wants to merge 2 commits into from
Closed

Fix #6031 #8906

wants to merge 2 commits into from

Conversation

novalis
Copy link
Contributor

@novalis novalis commented Aug 31, 2013

This is a patch to fix #6031. I didn't see any tests for the C++ library code, so I didn't write a test for my changes. Did I miss something, or are there really no tests?

@alexcrichton
Copy link
Member

Thanks for fixing this! I think that this may want to wait until #8880 is merged, though, because rust_log.cpp is on its way out.

You're right, though, in that there are currently no tests for the C++ code, but once that pull request is merged you can write this in rust and test it as well!

@@ -34,9 +34,11 @@ struct log_directive {
const size_t max_log_level = 255;
const size_t default_log_level = log_err;

const char* log_levels [] = {"err", "warn", "info", "debug", 0 };
Copy link
Member

Choose a reason for hiding this comment

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

Could err be error?

@alexcrichton
Copy link
Member

Now that the other half has landed, this should be good to go for a rebase now.

@novalis
Copy link
Contributor Author

novalis commented Sep 7, 2013

(this is now ready for review)

];
unsafe {
do "crate1::mod1".to_c_str().with_ref |ptr| {
let entry= &ModEntry {name: ptr, log_level: &mut 0};
Copy link
Member

Choose a reason for hiding this comment

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

These tests are actually pretty unsafe. You're creating &mut 0 but there's no guarantee about the lifetime of the 0. Could you move the 0 into an outer variable to ensure that a pointer to it outlasts the construction of ModEntry?

Copy link
Member

Choose a reason for hiding this comment

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

I also just noticed that this may be a problem in the surrounding tests as well, would you mind updating those as well?

Copy link
Member

Choose a reason for hiding this comment

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

Surely this is a huge bug in rust's type system if the 0 is allowed here and the lifetime is incorrect. I.e. it either lasts long enough or the compiler will complain?

@alexcrichton
Copy link
Member

Everything looks good to me! Just style nits here and there and one safety issue in the tests. otherwise r+

@novalis
Copy link
Contributor Author

novalis commented Sep 7, 2013

OK, I think I've addressed all the comments. Thanks for working with me on this pull request.

bors added a commit that referenced this pull request Sep 7, 2013
This is a patch to fix #6031.  I didn't see any tests for the C++ library code, so I didn't write a test for my changes.  Did I miss something, or are there really no tests?
@bors bors closed this Sep 7, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 4, 2022
…Jarcho

remove `large_enum_variant` suggestion for `Copy` types

Replaces the (erroneous) suggestion on `large_enum_variant` for `Copy` types by a note. This fixes rust-lang#8894.

---

changelog: none
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.

Symbolic log levels, not just numbers
4 participants