Commit Graph

440 Commits

Author SHA1 Message Date
peizhe 44167e918d 告警与遗留问题文件补充
Signed-off-by: peizhe <zhaipeizhe@huawei.com>
2023-05-09 09:27:15 +08:00
Matt Brubeck 6dd747f2f8 Version 1.10.0 github.com/servo/rust-smallvec/refs/tags/v1.10.0 2022-10-02 14:53:46 -07:00
Matt Brubeck 16baed9c08 Skip tests on 1.36 2022-10-02 14:49:53 -07:00
Nikita Popov 3160cafccf Mark Array::size() as inline 2022-10-02 10:52:26 -07:00
Ridwan Abdilahi 2611410d8b Fix broken CI yaml script. Ensure a default value exists for the os matrix key. 2022-09-13 17:18:21 -07:00
Ridwan Abdilahi 2ea0b5e10d Add Natvis definitions and tests for SmallVec type with and without the union crate feature enabled.
Unify Natvis definitions into a single Natvis file.
2022-09-12 11:33:15 -07:00
Matt Brubeck 8dc91ec7da Version 1.9.0 2022-06-29 16:03:45 -07:00
Colin Rofls 4f9a3414e7 Add retain_mut method (as an alias to retain)
I was trying to use this crate as a drop-in replacement for std::Vec,
where I am using the retain_mut method.
2022-06-29 16:02:53 -07:00
Matt Brubeck 4a20516270 Version 1.8.1 2022-06-24 10:19:41 -07:00
Nicholas Nethercote ca0c0581dc Add a benchmark for the insert case where index == len. 2022-06-24 10:18:36 -07:00
Nicholas Nethercote 7c10787469 Optimize insert for the case where index == len.
By skipping the call to `copy` with a zero length. This makes it closer
to `push`. This speeds up rustc (which uses `SmallVec` extensively) by
2% on one benchmark.

Also clarify the panic condition.
2022-06-24 10:18:36 -07:00
Alex Touchet 627cb0c344 Use SPDX license format (#278) 2022-02-28 10:05:41 -08:00
bors-servo e0aeb1366a Auto merge of #277 - saethlin:fix-aliasing, r=mbrubeck
Fix all problems encounted with Miri -Ztag-raw-pointers

I poked at this crate with `-Zmiri-tag-raw-pointers` before, and I was unable to fix what I found (I just added a test case that ruled out one of my wrong ideas https://github.com/servo/rust-smallvec/pull/271). I tried again just now and I guess I just understand better this time.

This PR fixes 3 separate pointer invalidation problems, which are detected by running `MIRIFLAGS=-Zmiri-tag-raw-pointers cargo miri test`.

Depending on how you squint, 2 or 3 of these are https://github.com/rust-lang/unsafe-code-guidelines/issues/133. The last one is _probably_ still present even with late invalidation, because `set_len` does a write through a `&mut`.

It's unclear to me if any of these things that Miri complains about are potentially a miscompilation in rustc due to the use of LLVM `noalias`. But perhaps given how subtle this codebase is overall, it would be best to run the tools on their pickiest settings, even if there are a few things more like a false positive than a real problem.
2022-02-07 15:40:30 -05:00
Ben Kimock 0a283cc17a 2022-02-07 12:42:28 -05:00
Ben Kimock 45736d30e9 Fix Miri complaints with -Zmiri-tag-raw-pointers
Miri does not check all of Stacked Borrows (the prototype aliasing model
for Rust) without -Zmiri-tag-raw-pointers. This enables the check in CI,
and makes a few adjustments to fix places where pointers were
invalidated by construction or use of a mutable reference.
2022-02-01 18:29:18 -05:00
Matt Brubeck a70033101f Version 1.8.0
* Add optional support for the `arbitrary` crate (#275).
2022-01-13 16:11:27 -08:00
bors-servo d61005924c Auto merge of #275 - as-com:arbitrary-support, r=mbrubeck
Add support for arbitrary

This PR adds optional support for [Arbitrary](https://github.com/rust-fuzz/arbitrary/), which is helpful in fuzz testing. The implementation is nearly identical to Arbitrary's existing Vec implementation.
2022-01-13 19:05:20 -05:00
Andrew Sun 0d8b2e7b4b Add support for arbitrary 2022-01-13 01:42:22 -05:00
bors-servo 83c3ef273b Auto merge of #271 - saethlin:drain-aliasing-test, r=jdm
Test for drains that shift the tail, when inline

Previously, the test suite only had one trip through the tail-shifting
code in Drain::drop, and that is in the heap state.
In the current implementation, a tail-shifting drain while in the inline
state produces potentially dangerous aliasing which is currently
accepted by default Miri and rejected with -Ztrack-raw-pointers.

Adding this test case ensures that if this ever becomes an actual
problem it will be easy to find.
2022-01-02 23:54:40 -05:00
Ben Kimock f96cdfd269 Test for drains that shift the tail, when inline
Previously, the test suite only had one trip through the tail-shifting
code in Drain::drop, and that is in the heap state.
In the current implementation, a tail-shifting drain while in the inline
state produces potentially dangerous aliasing which is currently
accepted by default Miri and rejected with -Ztrack-raw-pointers.

Adding this test case ensures that if this ever becomes an actual
problem it will be easy to find.
2022-01-02 23:15:56 -05:00
Josh Matthews 82719fb11d Merge pull request #270 from servo/github-actions
Replace TravisCI with Github Actions.
2021-11-21 14:08:20 -05:00
Josh Matthews d01fa06412 Replace TravisCI with Github Actions. 2021-11-21 13:57:30 -05:00
Ben Kimock 1403de85a2 Include the cost of shifts in insert/remove benchmarks (#268)
Thanks!
2021-10-09 17:08:35 -07:00
Matt Brubeck 9af24f97df Version 1.7.0 2021-09-28 10:46:32 -07:00
Tim Lundqvist 1afe49373c Added feature const_new which enables SmallVec::new_const() (#265) 2021-09-28 10:44:16 -07:00
mgr-inz-rafal 5f24029b5f Fix typo 2021-08-28 17:05:10 +02:00
bors-servo b06fce929f Auto merge of #262 - Yamakaky:clone_from, r=mbrubeck
Add specialized `clone_from` implementation
2021-05-23 13:21:58 -04:00
Mikaël Fourrier 79607b6f24 Add specialized clone_from implementation 2021-05-23 18:05:39 +02:00
bors-servo 326780d9f8 Auto merge of #261 - mbrubeck:docs, r=jdm
Update docs for const_generics feature

This feature is stable in Rust 1.51.
2021-03-29 00:26:58 -04:00
Matt Brubeck 3926236712 Update docs for const_generics feature
This feature is stable in Rust 1.51.
2021-03-23 16:31:58 -07:00
bors-servo 1abefb46dc Auto merge of #259 - mbrubeck:overflow, r=emilio
Panic on arithmetic overflow in drain

Fixes #258.
2021-03-23 12:32:32 -04:00
Matt Brubeck 3085177aeb Panic on arithmetic overflow in drain
Fixes #258.
2021-03-23 09:31:58 -07:00
bors-servo 1dad48dece Auto merge of #254 - mbrubeck:overflow, r=emilio
Fix potential buffer overflow in `insert_many`

Fixes #252.
2021-01-08 12:20:39 -05:00
Matt Brubeck 529a214762 Fix potential buffer overflow in insert_many
Fixes #252.
2021-01-08 09:19:37 -08:00
bors-servo fae1f5ffcb Auto merge of #249 - mbrubeck:bump, r=jdm
Version 1.6.0

Release notes:

* The `union` feature is now compatible with stable Rust 1.49 (#248, #247).
* Fixed warnings when compiling with Rust 1.51 nightly (#242, #246).
2020-12-31 14:17:04 -05:00
Matt Brubeck c27ce0178e Version 1.6.0
Release notes:

* The `union` feature is now compatible with stable Rust 1.49 (#248).
* Fixed warnings when compiling with Rust 1.51 nightly (#242, #246).
2020-12-30 17:26:34 -08:00
bors-servo 5f045899b0 Auto merge of #248 - saethlin:master, r=mbrubeck
Wrap with ManuallyDrop so that the union feature works on 1.50

Per https://github.com/servo/rust-smallvec/issues/247#issuecomment-752794872

The unrelated diff was produced by rustfmt, which my editor runs automatically. I'm a bit surprised, usually when this produces a diff it's a big one. Do you want me to revert those lines?
2020-12-30 19:57:46 -05:00
Ben Kimock 9baac4efb5 make union feature work on 1.50 2020-12-30 19:48:06 -05:00
bors-servo 0f0a969948 Auto merge of #246 - mbrubeck:warnings, r=jdm
Silence warnings about deprecated LayoutErr

This is renamed to LayoutError in Rust 1.51 and later, but we need to continue using the old name to support older versions of Rust.
2020-12-30 10:09:59 -05:00
Matt Brubeck 535a4de0de Silence warnings about deprecated LayoutErr 2020-12-29 20:32:28 -08:00
bors-servo e1eb1ec274 Auto merge of #242 - c410-f3r:patch-2, r=mbrubeck
Remove `min_const_generics` feature

Depends on https://github.com/rust-lang/rust/pull/79135.

If #240 is already under development and will be available before the 1.50 release, then feel free to close this PR. Otherwise, the feature removal will benefit upstream projects in the meanwhile.
2020-12-28 17:27:44 -05:00
bors-servo 50f5c2b976 Auto merge of #244 - mbrubeck:bump, r=jdm
Version 1.5.1

Release notes:

* Improve performance of `push` (#241).
2020-12-04 17:12:47 -05:00
Matt Brubeck 5d64a860e2 Version 1.5.1
Release notes:

* Improve performance of `push` (#241).
2020-12-04 13:39:49 -08:00
Caio 10fb570fb6 Remove min_const_generics feature 2020-12-02 14:34:27 -03:00
bors-servo ded260001d Auto merge of #241 - mpdn:master, r=mbrubeck
Remove extraneous branch from push

`push` does two branches on the "smallness" of the `smallvec`: one before the reserve check and one after. LLVM doesn't seem to optimize the second branch away for the (very common) non-growing case. In addition, in the growing branch we know the memory will be on the heap, so no need to branch here.

On my machine, this improves `bench_push` from approx 300ns to 263ns (+/- 5 on both).
2020-11-30 13:54:49 -05:00
Mike Pedersen c50a800c63 Remove extraneous branch from push 2020-11-30 19:23:26 +01:00
bors-servo 305ada1bdc Auto merge of #239 - mbrubeck:bump, r=jdm
Version 1.5.0

Change log:

* Add the `append` method (#237).
* Add support for more array sizes between 17 and 31 (#234).
* Don't panic on deserialization errors (#238).
2020-11-16 20:39:46 -05:00
Matt Brubeck 26f0d922a6 Version 1.5.0
Change log:

* Add the `append` method (#237).
* Add support for more array sizes between 17 and 31 (#234).
* Don't panic on deserialization errors (#238).
2020-11-16 10:25:41 -08:00
bors-servo 2abcb42939 Auto merge of #238 - epilys:master, r=mbrubeck
Return allocation error in deserialize instead of panicking

There's no way to catch allocation errors since out of memory errors
cause an abort. Fail gracefully by returning the error instead of
panicking.

I happened upon this error when deserializing untrusted data with bincode. Bincode provides a byte limit bound but for sequences it's not possible to enforce this through serde since collection types like smallvec handle their own allocation.
2020-11-08 18:59:27 -05:00
Manos Pitsidianakis 29941ba95c Return allocation error in deserialize instead of panicking
There's no way to catch allocation errors since out of memory errors
cause an abort. Fail gracefully by returning the error instead of
panicking.
2020-11-08 20:10:44 +02:00