-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 issue12118: Return value/use extra::test::black_box in benchmarks that are optimised to nothing #12212
Conversation
x: 1, | ||
y: 2, | ||
z: 3, | ||
}) | ||
})); |
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.
This shouldn't need black_box
because it can just return it from the closure (and bh.iter
will black_box
it)
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.
This one was already fixed :)
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.
By "already fixed" I mean, there's no need to add the black_box
call or change it in any way (the arena.alloc
function is very fast): the lack of a trailing semicolon meant that it was returned by the closure.
Thanks! |
thank you both of you. |
@@ -269,6 +269,7 @@ mod tests { | |||
mod bench { | |||
|
|||
use extra::test::BenchHarness; | |||
use extra::test::black_box; |
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.
This import isn't needed anymore
Thank you |
@@ -4464,13 +4465,14 @@ mod bench { | |||
ptr::set_memory(vp, 0, 1024); | |||
v.set_len(1024); | |||
} | |||
&v |
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.
You can just return v
instead of &v
.
(The test failures are because v
is defined inside the closure, and so returning a reference would be creating a dangling pointer.)
Thank you. |
Fix a typo in the `inlayHints.renderColons` option description The description said the same thing twice: "trailing colons for parameter hints, and trailing colons for parameter hints". I'm assuming one of those is supposed to be about the leading colon for type hints. Also, I wasn't sure how to regenerate the generated file(s?) so I just manually updated them. Hopefully that isn't a problem. If how to do that is in the documentation somewhere I'd love to know.
…s-fix, r=Jarcho Fix false positive in `redundant_type_annotations` lint This PR changes the `redundant_type_annotations` lint to allow slice type annotations (i.e., `&[u8]`) for byte string literals. It will still consider _array_ type annotations (i.e., `&[u8; 4]`) as redundant. The reasoning behind this is that the type of byte string literals is by default a reference to an array, but, by using a type annotation, you can force it to be a slice. For example: ```rust let a: &[u8; 4] = b"test"; let b: &[u8] = b"test"; ``` Now, the type annotation for `a` will still be linted (as it is still redundant), but the type annotation for `b` will not. Fixes rust-lang#12212. changelog: [`redundant_type_annotations`]: Fix false positive with byte string literals
A try to fix #12118.
@huonw Could you please review that.