This script used to be used to extract the grammar sections from the
reference, but there is now a separate src/doc/grammar.md where the
grammar sections that used to be in the reference live, so there is
no longer a need to extract the grammar from the reference.
Since the hashmap and its hasher are implemented in different crates, we
currently can't benefit from inlining, which means that especially for
small, fixed size keys, there is a huge overhead in hash calculations,
because the compiler can't apply optimizations that only apply for these
keys.
Fixes the brainfuck benchmark in #24014.
E.g. if `foo.rs` looks like
#![feature(test)]
extern crate test;
#[bench]
fn bar(b: &mut test::Bencher) {
b.iter(|| {
1
})
}
#[test]
fn baz() {}
#[bench]
fn qux(b: &mut test::Bencher) {
b.iter(|| {
panic!()
})
}
Then
$ rustc --test foo.rs
$ ./foo
running 3 tests
test baz ... ok
test qux ... FAILED
test bar ... ok
failures:
---- qux stdout ----
thread 'qux' panicked at 'explicit panic', bench.rs:17
failures:
qux
test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured
$ ./foo --bench ba
running 2 tests
test baz ... ignored
test bar ... bench: 97 ns/iter (+/- 74)
test result: ok. 0 passed; 0 failed; 1 ignored; 1 measured
In particular, the two benchmark are being run as tests in the default
mode.
This helps for the main distribution, since benchmarks are only run with
`PLEASE_BENCH=1`, which is rarely set (and never set on the test bots),
and helps for code-coverage tools: benchmarks are run and so don't count
as dead code.
Fixes#15842.
Since the hashmap and its hasher are implemented in different crates, we
currently can't benefit from inlining, which means that especially for
small, fixed size keys, there is a huge overhead in hash calculations,
because the compiler can't apply optimizations that only apply for these
keys.
Fixes the brainfuck benchmark in #24014.
- `FIle::open` is for opening a file in read-only mode
- `FIle::create` is for opening a file in write-only mode, which is what we want instead for this example to make sense
Without the inline annotation this:
str::from_utf8_unchecked( slice::from_raw_parts( ptr, len ) )
doesn't get inlined which can be pretty brutal performance-wise
when used in an inner loop of a low level string manipulation method.
typeck: Make sure casts from other types to fat pointers are illegal
Fixes ICEs where non-fat pointers and scalars are cast to fat pointers,
Fixes#21397Fixes#22955Fixes#23237Fixes#24100
- I found n error in the book, before contributing the patch to fix it, I had to find where they were hosted
- It took me quite look to find where within the rust-lang *organisation* it was!
Adds an `attrs` field to `FieldInfo` which lets one check the attributes on
a field whilst expanding.
This lets deriving plugins be more robust, for example providing the ability to
"ignore" a field for the purpose of deriving, or perhaps handle the field a
different way.
r? @huonw
E.g. if `foo.rs` looks like
#![feature(test)]
extern crate test;
#[bench]
fn bar(b: &mut test::Bencher) {
b.iter(|| {
1
})
}
#[test]
fn baz() {}
#[bench]
fn qux(b: &mut test::Bencher) {
b.iter(|| {
panic!()
})
}
Then
$ rustc --test foo.rs
$ ./foo
running 3 tests
test baz ... ok
test qux ... FAILED
test bar ... ok
failures:
---- qux stdout ----
thread 'qux' panicked at 'explicit panic', bench.rs:17
failures:
qux
test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured
$ ./foo --bench ba
running 2 tests
test baz ... ignored
test bar ... bench: 97 ns/iter (+/- 74)
test result: ok. 0 passed; 0 failed; 1 ignored; 1 measured
In particular, the two benchmark are being run as tests in the default
mode.
This helps for the main distribution, since benchmarks are only run with
`PLEASE_BENCH=1`, which is rarely set (and never set on the test bots),
and helps for code-coverage tools: benchmarks are run and so don't count
as dead code.
Fixes#15842.
collections: Implement String::drain(range) according to RFC 574
`.drain(range)` is unstable and under feature(collections_drain).
This adds a safe way to remove any range of a String as efficiently as
possible.
As noted in the code, this drain iterator has none of the memory safety
issues of the vector version.
RFC tracking issue is #23055
Apparently implementations are allowed to return EDEADLK instead of blocking
forever, in which case this can lead to unsafety in the `RwLock` primitive
exposed by the standard library. A debug-build of the standard library would
have caught this error (due to the debug assert), but we don't ship debug
builds right now.
This commit adds explicit checks for the EDEADLK error code and triggers a panic
to ensure the call does not succeed.
Closes#25012