Commit Graph

55 Commits

Author SHA1 Message Date
Nilstrieb
968be98756 Allow clippy::from_mut_ref
This pattern is fine for arena allocators.
2023-04-09 22:29:56 +02:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Maybe Waffle
a603635670 rustc_arena: remove a couple of ref patterns 2022-11-22 18:49:29 +00:00
Maybe Waffle
53565b23ac Make use of [wrapping_]byte_{add,sub}
...replacing `.cast().wrapping_offset().cast()` & similar code.
2022-08-23 19:32:37 +04:00
Matthias Krüger
a45f69f27d
Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm
Replace most uses of `pointer::offset` with `add` and `sub`

As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts.

This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things.

r? ````@scottmcm````

_split off from #100746_
2022-08-21 16:54:07 +02:00
Maybe Waffle
e4720e1cf2 Replace most uses of pointer::offset with add and sub 2022-08-21 02:21:41 +04:00
5225225
09ea9f0a87 Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
Martin Habovstiak
2a3ce7890c Stabilize ptr_const_cast
This stabilizes `ptr_const_cast` feature as was decided in a recent
[FCP](https://github.com/rust-lang/rust/issues/92675#issuecomment-1190660233)

Closes #92675
2022-08-10 17:22:58 +02:00
Dylan DPC
d63c713947
Rollup merge of #97711 - Nilstrieb:rustc-arena-ub, r=wesleywiser
Improve soundness of rustc_arena

Make it runnable in miri by changing the loop iteration count for some tests in miri. Also fix a stacked borrows issue with box.
2022-07-07 18:06:49 +05:30
Nilstrieb
211fb66810 Fix stacked borrows violation in rustc_arena
There was a problem with storing a `Box<T>` in a struct, where
the current rules would invalidate the value. this makes it store
a raw pointer instead, circumventing the aliasing problems.
2022-07-06 20:02:45 +02:00
Nicholas Nethercote
7c40661ddb Update smallvec to 1.8.1.
This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.
2022-06-27 08:48:55 +10:00
Nilstrieb
907ea55841 Adapt tests to be able to run in miri
Decrease the Ns of bug loops to a smaller N, which
makes them a lot faster in miri.
2022-06-03 22:46:01 +02:00
Aria Beingessner
28576e9c51 mark FIXMES for all the places found that are probably offset_from 2022-03-29 20:18:28 -04:00
Aria Beingessner
68643603ad Make some rustc code conform to strict provenance.
There's some really bad stuff around `ty` and pointer tagging stuff that
was too much work to handle here.
2022-03-29 20:18:27 -04:00
est31
3cb7618f58 Remove unused dep from rustc_arena 2022-02-02 17:37:14 +01:00
Nicholas Nethercote
6035487715 Clarify ArenaAllocatable's second parameter.
It's simply a binary thing to allow different behaviour for `Copy` vs
`!Copy` types. The new code makes this much clearer; I was scratching my
head over the old code for some time.
2022-01-28 07:37:10 +11:00
Nicholas Nethercote
9065c7ced6 Add some comments. 2022-01-28 07:37:07 +11:00
Nicholas Nethercote
0c17893d49 Rename TypedArenaChunk as ArenaChunk.
Because it's used within both `TypedArena` and `DroplessArena`.

The commit also makes `<u8>` the default parameter.
2022-01-26 01:35:52 +11:00
Nicholas Nethercote
0a89598dbd Add some comments.
Also use `Default::default()` in one `TypedArena::default()`, for
consistency with `DroplessArena::default()`.
2021-11-19 07:52:59 +11:00
Nicholas Nethercote
552073701f Remove unnecessary lifetime argument from arena macros.
Because it's always `'tcx`. In fact, some of them use a mixture of
passed-in `$tcx` and hard-coded `'tcx`, so no other lifetime would even
work.

This makes the code easier to read.
2021-11-17 09:38:30 +11:00
Nicholas Nethercote
fb80c73fb3 Remove DropArena.
Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a
few infrequently used ones share a `DropArena`. This sharing adds complexity
but doesn't help performance or memory usage. Perhaps it was more effective in
the past prior to some other improvements to arenas.

This commit removes `DropArena` and the sharing of arenas via the `few`
attribute of the `arena_types` macro. This change removes over 100 lines of
code and nine uses of `unsafe` (one of which affects the parallel compiler) and
makes the remaining code easier to read.
2021-11-15 18:33:43 +11:00
Mark Rousskov
c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
bjorn3
1a2fe87b09 Remove unused arena macro args 2021-08-30 13:09:38 +02:00
bors
5eacec9ec7 Auto merge of #85690 - bstrie:m2_arena, r=jackh726,nagisa
Macros 2.0-ify rustc_arena

For the purpose of battle-testing macros 2.0 I'm looking to dogfood it in rustc, one crate at a time.

(Note that there are only 12 changed lines if you ignore whitespace.)
2021-08-28 20:58:12 +00:00
Jade
3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
bstrie
71db7cc0b4 rustc_arena: macros 2.0 2021-05-25 13:57:02 -04:00
Joshua Nelson
441dc3640a Remove (lots of) dead code
Found with https://github.com/est31/warnalyzer.

Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
  x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
  wants to use it in the future?
- Don't change rustc_serialize

  I plan to scrap most of the json module in the near future (see
  https://github.com/rust-lang/compiler-team/issues/418) and fixing the
  tests needed more work than I expected.

TODO: check if any of the comments on the deleted code should be kept.
2021-03-27 22:16:33 -04:00
Dylan DPC
37b7031078
Rollup merge of #83197 - jyn514:cfg-test-dead-code, r=joshtriplett
Move some test-only code to test files

Split out from https://github.com/rust-lang/rust/pull/83185.
2021-03-19 15:03:24 +01:00
Joshua Nelson
620ecc01a2 Move some test-only code to test files
This also relaxes the bounds on some structs and moves them to the impl
block instead.
2021-03-17 10:31:30 -04:00
Josh Stone
f7e75a2124 Update to rustc-rayon 0.3.1
This pulls in rust-lang/rustc-rayon#8 to fix #81425. (h/t @ammaraskar)

That revealed weak constraints on `rustc_arena::DropArena`, because its
`DropType` was holding type-erased raw pointers to generic `T`. We can
implement `Send` for `DropType` (under `cfg(parallel_compiler)`) by
requiring all `T: Send` before they're type-erased.
2021-03-10 17:53:35 -08:00
Joshua Nelson
3733275854 Update the bootstrap compiler
Note this does not change `core::derive` since it was merged after the
beta bump.
2021-02-20 17:19:30 -05:00
Jonas Schievink
493c6c9f25
Rollup merge of #82077 - pierwill:edit-droparena, r=lcnr
Edit `rustc_arena::DropArena` docs

- Add a "Safety" section, edit formatting for clarity
- Add missing punctuation in code comments
2021-02-15 16:07:00 +01:00
klensy
93c8ebe022 bumped smallvec deps 2021-02-14 18:03:11 +03:00
pierwill
1c3841ebf2 Edit rustc_arena::DropArena docs
- Add a "Safety" section, edit formatting for clarity
- Add missing punctuation in code comments
2021-02-13 16:04:18 -08:00
Jonas Schievink
1e99f26894
Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-se
Stabilize by-value `[T; N]` iterator `core::array::IntoIter`

Tracking issue: https://github.com/rust-lang/rust/issues/65798

This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135.

This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method.

`new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2021-01-31 01:47:25 +01:00
Henry Boisdequin
c2c2e8dde1 fn cold_path doesn't need to be pub 2021-01-29 14:03:01 +05:30
Simon Sapin
61c49d4042 Stabilize by-value [T; N] iterator core::array::IntoIter
Tracking issue: https://github.com/rust-lang/rust/issues/65798

This is unblocked now that `min_const_generics` has been stabilized
in https://github.com/rust-lang/rust/pull/79135.

This PR does *not* include the corresponding `IntoIterator` impl,
which is https://github.com/rust-lang/rust/pull/65819.
Instead, an iterator can be constructed through the `new` method.

`new` would become unnecessary when `IntoIterator` is implemented
and might be deprecated then, although it will stay stable.
2020-12-29 09:16:46 +01:00
Bastian Kauschke
06cc9c26da stabilize min_const_generics 2020-12-26 18:24:10 +01:00
Dániel Buga
e93a4637c0 Use specialization to avoid copying 2020-11-20 21:02:09 +01:00
Joshua Nelson
57c6ed0c07 Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
Dániel Buga
99320b9404 Fix typos in arena comments 2020-10-27 18:14:21 +01:00
Dániel Buga
2705caed8a Track element count only for types that need drop 2020-10-20 17:01:51 +02:00
Dániel Buga
396561bdb7 Make sure arenas don't allocate bigger than HUGE_PAGE 2020-10-17 23:33:53 +02:00
Dániel Buga
52ff31a7eb Arena: Copy cold_path and remove rustc_data_structures dependency 2020-10-15 10:56:33 +02:00
est31
12187b7f86 Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
bors
5bfeee5fe0 Auto merge of #77172 - jonas-schievink:rollup-a041rou, r=jonas-schievink
Rollup of 15 pull requests

Successful merges:

 - #75438 (Use adaptive SVG favicon for rustdoc like other rust sites)
 - #76304 (Make delegation methods of `std::net::IpAddr` unstably const)
 - #76724 (Allow a unique name to be assigned to dataflow graphviz output)
 - #76978 (Documented From impls in std/sync/mpsc/mod.rs)
 - #77044 (Liballoc bench vec use mem take not replace)
 - #77050 (Typo fix: "satsify" -> "satisfy")
 - #77074 (add array::from_ref)
 - #77078 (Don't use an if guard to check equality with a constant)
 - #77079 (Use `Self` in docs when possible)
 - #77081 (Merge two almost identical match arms)
 - #77121 (Updated html_root_url for compiler crates)
 - #77136 (Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn`)
 - #77160 (Suggest `const_fn_transmute`, not `const_fn`)
 - #77164 (Remove workaround for deref issue that no longer exists.)
 - #77165 (Followup to #76673)

Failed merges:

r? `@ghost`
2020-09-25 01:56:06 +00:00
Erik Hofmayer
138a2e5eaa /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
Erik Hofmayer
dd66ea2d3d Updated html_root_url for compiler crates 2020-09-23 21:14:43 +02:00
Tomasz Miąsko
c7e887c64a DroplessArena: Allocate objects from the end of memory chunk
Allocating from the end of memory chunk simplifies the alignment code
and reduces the number of checked arithmetic operations.
2020-09-21 15:36:45 +02:00
Ralf Jung
4322e1b92d
Rollup merge of #76821 - est31:remove_redundant_nightly_features, r=oli-obk,Mark-Simulacrum
Remove redundant nightly features

Removes a bunch of redundant/outdated nightly features. The first commit removes a `core_intrinsics` use for which a stable wrapper has been provided since. The second commit replaces the `const_generics` feature with `min_const_generics` which might get stabilized this year. The third commit is the result of a trial/error run of removing every single feature and then adding it back if compile failed. A bunch of unused features are the result that the third commit removes.
2020-09-20 12:08:22 +02:00