Commit Graph

187 Commits

Author SHA1 Message Date
Ding Xiang Fei
297b618944
reduce false positives of tail-expr-drop-order from consumed values
take 2

open up coroutines

tweak the wordings

the lint works up until 2021

We were missing one case, for ADTs, which was
causing `Result` to yield incorrect results.

only include field spans with significant types

deduplicate and eliminate field spans

switch to emit spans to impl Drops

Co-authored-by: Niko Matsakis <nikomat@amazon.com>

collect drops instead of taking liveness diff

apply some suggestions and add explantory notes

small fix on the cache

let the query recurse through coroutine

new suggestion format with extracted variable name

fine-tune the drop span and messages

bugfix on runtime borrows

tweak message wording

filter out ecosystem types earlier

apply suggestions

clippy

check lint level at session level

further restrict applicability of the lint

translate bid into nop for stable mir

detect cycle in type structure
2024-11-20 20:53:11 +08:00
Matthias Krüger
6d41be2700
Rollup merge of #130625 - heiseish:issue-124028-fix, r=jieyouxu
Fix a few relative paths in rustc doc

## Changes

- Don't inline the doc for re-exporting some structs that have relative paths in doc.

## Context

See #124028.

- Most of the relative links in rustdoc are there because of circular import (so syntax like `[MyType]: rustc_foo::bar` is difficult to achieve when we cannot import `rustc_xxx` due to circular import)
- Here, I disable new links for re-exports. I think it's fine for re-exported items in `hir::*`.
- There is a few more relative links in other `rustc` crates, however they are not addressed in this PR, as they are not re-exported and/so the relative paths are working.

Closes #124028.

r​? `@fmease`

Let me know if I miss anything or there's any other way to address this issue.
2024-10-10 12:49:18 +02:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Giang Dao
ff86fa50fb no_inline for index vec 2024-09-20 23:30:31 +08:00
Lukas Markeffsky
3db930a463 assert that unexpectedly unsized fields are sized in the param env 2024-09-17 00:06:56 +02:00
Ralf Jung
11bd99de8c IntervalSet: add comment about representation 2024-09-08 16:54:28 +02:00
bors
6d05f12170 Auto merge of #129346 - nnethercote:fix-double-handling-in-collect_tokens, r=petrochenkov
Fix double handling in `collect_tokens`

Double handling of AST nodes can occur in `collect_tokens`. This is when an inner call to `collect_tokens` produces an AST node, and then an outer call to `collect_tokens` produces the same AST node. This can happen in a few places, e.g. expression statements where the statement delegates `HasTokens` and `HasAttrs` to the expression. It will also happen more after #124141.

This PR fixes some double handling cases that cause problems, including #129166.

r? `@petrochenkov`
2024-09-08 05:35:23 +00:00
The 8472
5bf8eeb9f3 disable size asserts in the compiler when randomizing layouts 2024-08-31 23:56:45 +02:00
Jubilee
9d5f794312
Rollup merge of #129401 - workingjubilee:partial-initialization-of-stabilization, r=dtolnay,joboet
Partially stabilize `feature(new_uninit)`

Finished comment period: https://github.com/rust-lang/rust/issues/63291#issuecomment-2183022955

The following API has been stabilized from https://github.com/rust-lang/rust/issues/63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: https://github.com/rust-lang/rust/issues/129396
- `box_uninit_write`: https://github.com/rust-lang/rust/issues/129397

All relevant code is thus either stabilized or split out of that issue, so this closes #63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
2024-08-28 19:12:52 -07:00
Jubilee Young
2535a0f776 compiler: Remove feature(new_uninit) 2024-08-27 10:17:05 -07:00
Nicholas Nethercote
46fe09f3f3 Add warn(unreachable_pub) to rustc_index. 2024-08-27 14:33:24 +10:00
Jubilee Young
9ccd7abefe library: Move unstable API of new_uninit to new features
- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as
it was decided to only stabilize `uninit*` and `assume_init`.
2024-08-23 20:52:02 -07:00
Nicholas Nethercote
1fdabfbebb Avoid double-handling of attributes in collect_tokens.
By keeping track of attributes that have been previously processed.

This fixes the `macro-rules-derive-cfg.stdout` test, and is necessary
for #124141 which removes nonterminals.

Also shrink the `SmallVec` inline size used in `IntervalSet`. 2 gives
slightly better perf than 4 now that there's an `IntervalSet` in
`Parser`, which is cloned reasonably often.
2024-08-24 06:57:47 +10:00
Josh Stone
0a34ce49ce Add and use IndexVec::append 2024-08-13 13:40:05 -07:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Michael Goulet
324d2e51ee Fix feature gating on rustc_index to not use implicit features 2024-07-15 12:44:24 -04:00
Michael Goulet
247ad3385c Use dep: for crate dependencies 2024-07-15 12:40:10 -04:00
bors
9f877c9cd2 Auto merge of #127170 - bjorn3:no_specialize_index_borrowck, r=michaelwoerister
Stop using specialization in rustc_index and rustc_borrowck

For rustc_borrowck the version with specialization isn't much more readable anyway IMO. For rustc_index it probably doesn't affect perf in any noticeable way anyway.
2024-07-04 14:24:43 +00:00
Liu Dingming
a9194f30eb Use IndexVec for coroutine local mapping 2024-07-04 05:09:23 +08:00
bjorn3
f23c1fdaeb Remove usage of specialization from newtype_index! 2024-06-30 16:42:53 +00:00
Nicholas Nethercote
75b164d836 Use tidy to sort crate attributes for all compiler crates.
We already do this for a number of crates, e.g. `rustc_middle`,
`rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`.

For the ones we don't, in many cases the attributes are a mess.
- There is no consistency about order of attribute kinds (e.g.
  `allow`/`deny`/`feature`).
- Within attribute kind groups (e.g. the `feature` attributes),
  sometimes the order is alphabetical, and sometimes there is no
  particular order.
- Sometimes the attributes of a particular kind aren't even grouped
  all together, e.g. there might be a `feature`, then an `allow`, then
  another `feature`.

This commit extends the existing sorting to all compiler crates,
increasing consistency. If any new attribute line is added there is now
only one place it can go -- no need for arbitrary decisions.

Exceptions:
- `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`,
  because they have no crate attributes.
- `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's
  ignored in `rustfmt.toml`).
2024-06-12 15:49:10 +10:00
Nicholas Nethercote
0d97669a17 Simplify static_assert_sizes.
We want to run them on all 64-bit platforms.
2024-04-18 15:36:25 +10:00
Zalathar
2d47cd77ac Check x86_64 size assertions on aarch64, too
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to
notice when these assertions have been violated.
2024-04-03 16:53:03 +11:00
orion GONZALEZ (contractor)
6600c972e6 doc: Add better explanation 2024-03-06 16:54:42 +01:00
Nicholas Nethercote
0ac1195ee0 Invert diagnostic lints.
That is, change `diagnostic_outside_of_impl` and
`untranslatable_diagnostic` from `allow` to `deny`, because more than
half of the compiler has be converted to use translated diagnostics.

This commit removes more `deny` attributes than it adds `allow`
attributes, which proves that this change is warranted.
2024-02-06 13:12:33 +11:00
bors
6351247048 Auto merge of #120024 - Mark-Simulacrum:fast-union-merge, r=cjgillot
Merge into larger interval set

This reduces the work done while merging rows. In at least one case (#50450), we have thousands of union([range], [20,000 ranges]), which previously inserted each of the 20,000 ranges one by one. Now we only insert one range into the right hand set after copying the set over.

This cuts the runtime of the test case in #50450 from ~26 seconds to ~6 seconds locally, though it doesn't change the memory usage peak (~9.5GB).
2024-01-27 22:26:37 +00:00
Matthias Krüger
b31bf24908
Rollup merge of #119800 - dev-ardi:tmp, r=wesleywiser
Document `rustc_index::vec::IndexVec`

Document a few of the methods.

Part of https://github.com/rust-lang/rust/issues/93792.
2024-01-26 23:15:50 +01:00
Ardi
00ada8e30c
Update compiler/rustc_index/src/vec.rs
Co-authored-by: Wesley Wiser <wwiser@gmail.com>
2024-01-26 08:37:37 +01:00
clubby789
fd29f74ff8 Remove unused features 2024-01-25 14:01:33 +00:00
Camille GILLOT
7e64de431e Remove uses of HybridBitSet. 2024-01-22 22:53:20 +00:00
Mark Rousskov
1696148a89 Merge into larger interval set
This reduces the work done while merging rows. In at least one case
(issue 50450), we have thousands of union([range], [20,000 ranges]),
which previously inserted each of the 20,000 ranges one by one. Now we
only insert one range into the right hand set after copying the set
over.
2024-01-16 10:21:55 -05:00
ardi
ee8510e4e1 Fix some mistakes + new doc 2024-01-10 18:28:42 +01:00
ardi
1bf3aee381 Oh well 2024-01-10 12:41:29 +01:00
ardi
281ceb2bd2 Document the struct and a few methods 2024-01-10 10:26:18 +01:00
bors
efb3f11087 Auto merge of #119499 - cjgillot:dtm-opt, r=nnethercote
Two small bitset optimisations
2024-01-06 11:54:15 +00:00
Camille GILLOT
0adfe207d7 Reuse bitwise in BitMatrix. 2024-01-02 21:20:04 +00:00
bjorn3
6ed37bdc42 Avoid specialization for the Span Encodable and Decodable impls 2023-12-31 20:42:17 +00:00
Nadrieril
f6af7478ba Mention the relevant tracking issue next to my bit_set hack 2023-12-23 00:04:20 +01:00
Nadrieril
f30c5956f5 Make rustc_index::bit_set available on stable 2023-12-15 16:58:38 +01:00
Nicholas Nethercote
7060fc8327 Replace no_ord_impl with orderable.
Similar to the previous commit, this replaces `newtype_index`'s opt-out
`no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22 18:38:17 +11:00
Michael Goulet
4506681e2f Begin nightly-ifying rustc_type_ir 2023-11-18 00:20:00 +00:00
Nicholas Nethercote
82e396a4ba Remove unnecessary annotation. 2023-11-13 17:09:26 +11:00
Nicholas Nethercote
2433542b41 Remove IndexSlice::convert_index_type. 2023-11-13 17:00:48 +11:00
Nicholas Nethercote
8b18c16ecb Remove impl FiniteBitSetTy for {u64,u128}.
Only the impl for `u32` is used. These can be reinstated easily if
needed in the future.
2023-11-13 16:44:20 +11:00
Nicholas Nethercote
b7cf697a6d Remove BitSet::to_hybrid. 2023-11-13 16:26:26 +11:00
Nicholas Nethercote
06faf589ac Remove BitSet::words. 2023-11-13 16:24:16 +11:00
Nicholas Nethercote
8ff624a9f2 Clean up rustc_*/Cargo.toml.
- Sort dependencies and features sections.
- Add `tidy` markers to the sorted sections so they stay sorted.
- Remove empty `[lib`] sections.
- Remove "See more keys..." comments.

Excluded files:
- rustc_codegen_{cranelift,gcc}, because they're external.
- rustc_lexer, because it has external use.
- stable_mir, because it has external use.
2023-10-30 08:46:02 +11:00
Camille GILLOT
27d6a57e58 Preserve DebugInfo in DeadStoreElimination. 2023-10-06 15:46:11 +00:00
bors
8a6b67f988 Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonur
Update bootstrap compiler to 1.73.0 beta
2023-08-24 11:10:52 +00:00
Mark Rousskov
0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00