Commit Graph

166356 Commits

Author SHA1 Message Date
Ralf Jung
161b0bfe1c update Miri 2022-04-09 10:15:41 -04:00
Mark Lodato
9cf35a6c06 Rework String UTF-8 Documentation
**This Commit**
Adds some clarity around indexing into Strings and the constraints
driving various decisions there.

**Why?**
The [`String` documentation][0] mentions how `String`s can't be indexed
but `Range` has an implementation for `SliceIndex<str>`. This can be
confusing. There are also several statements to explain the lack of
`String` indexing:

- the inability to index into a `String` is an implication of UTF-8
  encoding
- indexing into a `String` could not be constant-time with UTF-8
  encoding
- indexing into a `String` does not have an obvious return type

This last statement made sense but the first two seemed contradictory to
the documentation around [`SliceIndex<str>`][1] which mention:

- one can index into a `String` with a `Range` (also called substring
  slicing but it uses the same syntax and the method name is `index`)
- `Range` indexing into a `String` is constant-time

To resolve this seeming contradiction the documentation is reworked to
more clearly explain what factors drive the decision to disallow
indexing into a `String` with a single number.

[0]: https://doc.rust-lang.org/stable/std/string/struct.String.html#utf-8
[1]: https://doc.rust-lang.org/stable/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E
2022-04-09 09:27:32 -04:00
bors
8c1fb2eb23 Auto merge of #95697 - klensy:no-strings, r=petrochenkov
refactor: simplify few string related interactions

Few small optimizations:

check_doc_keyword: don't alloc string for emptiness check
check_doc_alias_value: get argument as Symbol to prevent needless string convertions
check_doc_attrs: don't alloc vec, iterate over slice.
replace as_str() check with symbol check
get_single_str_from_tts: don't prealloc string
trivial string to str replace
LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String>
AssertModuleSource use FxHashSet<Symbol> instead of BTreeSet<String>
CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-09 13:15:26 +00:00
Vadim Petrochenkov
379ae12a1d expand: Remove ParseSess::missing_fragment_specifiers
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-09 15:44:19 +03:00
bors
fbdb10f9fa Auto merge of #95840 - Dylan-DPC:rollup-erz5u6w, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #95308 (Reduce the amount of unstable features used in libproc_macro)
 - #95676 (Update RLS)
 - #95769 (Hide cross-crate `#[doc(hidden)]` associated items in trait impls)
 - #95785 (interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal)
 - #95802 (fix unused constant warning on some Windows targets)
 - #95810 (Use `format-args-capture` and remove unnecessary nested blocks)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-09 11:05:30 +00:00
Dylan DPC
ece6b97f19
Rollup merge of #95810 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesting-in-rustc-borrowck, r=davidtwco
Use `format-args-capture` and remove unnecessary nested blocks
2022-04-09 12:52:07 +02:00
Dylan DPC
af895b0715
Rollup merge of #95802 - RalfJung:unused-win, r=Dylan-DPC
fix unused constant warning on some Windows targets

When none of those `cfg_if!` apply (and on Miri), the constant remains unused.
2022-04-09 12:52:06 +02:00
Dylan DPC
dfb4194e3b
Rollup merge of #95785 - RalfJung:interpret-size-mismatch, r=oli-obk
interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal

We did this a while ago already for `to_i32()` and friends, but missed this one. That became quite annoying when I was debugging an ICE caused by `read_pointer` in a Miri shim where the code was passing an argument at the wrong type.

Having `scalar_to_ptr` be fallible is consistent with all the other `Scalar::to_*` methods being fallible. I added `unwrap` only in code outside the interpreter, which is no worse off than before now in terms of panics.

r? ````@oli-obk````
2022-04-09 12:52:05 +02:00
Dylan DPC
24fa80dbb2
Rollup merge of #95769 - fmease:fix-issue-95717, r=GuillaumeGomez
Hide cross-crate `#[doc(hidden)]` associated items in trait impls

Fixes #95717.

r? ```@GuillaumeGomez```
This is the bug I ran into in #95316.

```@rustbot``` label T-rustdoc A-cross-crate-reexports
2022-04-09 12:52:04 +02:00
Dylan DPC
0aaeb4dd1b
Rollup merge of #95676 - pietroalbini:pa-bump-rls, r=pietroalbini
Update RLS

This PR updates RLS to include the following PRs:

* https://github.com/rust-lang/rls/pull/1766
* https://github.com/rust-lang/rls/pull/1767
* https://github.com/rust-lang/rls/pull/1771
* https://github.com/rust-lang/rls/pull/1772

It also updates racer to fix RLS compilation with the parallel compiler enabled.
2022-04-09 12:52:03 +02:00
Dylan DPC
e232cb42e6
Rollup merge of #95308 - bjorn3:more_stable_proc_macro, r=Mark-Simulacrum
Reduce the amount of unstable features used in libproc_macro

This makes it easier to adapt the source for stable when copying it into rust-analyzer to load rustc compiled proc macros.
2022-04-09 12:52:02 +02:00
Camille GILLOT
672ce1509b Bless tests. 2022-04-09 12:31:20 +02:00
Camille GILLOT
f89d64d7aa Use def_key in tcx.item_name when possible. 2022-04-09 10:54:43 +02:00
bors
399dd8049d Auto merge of #95724 - Kobzol:ci-update-rustc-perf, r=nnethercote
CI: update `rustc-perf` version used in CI and also the corresponding PGO benchmarks

The old version was from May 2021. The `rustc-perf` benchmarks have seen a significant overhaul recently, so let's see if the new benchmarks can improve PGO performance.
2022-04-09 07:53:34 +00:00
bors
4bb685e471 Auto merge of #95835 - Dylan-DPC:rollup-l5mf2ad, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #90066 (Add new ThinBox type for 1 stack pointer wide heap allocated trait objects)
 - #95374 (assert_uninit_valid: ensure we detect at least arrays of uninhabited types)
 - #95599 (Strict provenance lints)
 - #95751 (Don't report numeric inference ambiguity when we have previous errors)
 - #95764 ([macro_metavar_expr] Add tests to ensure the feature requirement)
 - #95787 (reword panic vs result section to remove recoverable vs unrecoverable framing)
 - #95797 (Remove explicit delimiter token trees from `Delimited`.)
 - #95804 (rustdoc: Fix empty doc comment with backline ICE)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-09 04:53:34 +00:00
Dylan DPC
8f4680e37c
Rollup merge of #95804 - GuillaumeGomez:empty-doc-comment-with-backline, r=notriddle
rustdoc: Fix empty doc comment with backline ICE

Fixes #95800.

r? ```@notriddle```
2022-04-09 05:58:46 +02:00
Dylan DPC
747bd16214
Rollup merge of #95797 - nnethercote:rm-Delimited-all_tts, r=petrochenkov
Remove explicit delimiter token trees from `Delimited`.

They were introduced by the final commit in #95159 and gave a
performance win. But since the introduction of `MatcherLoc` they are no
longer needed. This commit reverts that change, making the code a bit
simpler.

r? `@petrochenkov`
2022-04-09 05:58:45 +02:00
Dylan DPC
8d7392232c
Rollup merge of #95787 - yaahc:panic-doc-update-v2, r=dtolnay
reword panic vs result section to remove recoverable vs unrecoverable framing

Based on feedback from the Error Handling FAQ: https://github.com/rust-lang/project-error-handling/issues/50#issuecomment-1090876982

r? ````@dtolnay````
2022-04-09 05:58:44 +02:00
Dylan DPC
0051301b8a
Rollup merge of #95764 - c410-f3r:metavar-test, r=petrochenkov
[macro_metavar_expr] Add tests to ensure the feature requirement

These tests should have been added in the initial implementation they were unintentionally forgotten

cc #83527
r? ````@petrochenkov````
2022-04-09 05:58:43 +02:00
Dylan DPC
d4e0ddf7c8
Rollup merge of #95751 - compiler-errors:ambig-int, r=jackh726
Don't report numeric inference ambiguity when we have previous errors

Fixes #95648
2022-04-09 05:58:42 +02:00
Dylan DPC
525438b6a9
Rollup merge of #95599 - niluxv:strict-provenance-lint, r=michaelwoerister
Strict provenance lints

See #95488.
This PR introduces two unstable (allow by default) lints to which lint on int2ptr and ptr2int casts, as the former is not possible in the strict provenance model and the latter can be written nicer using the `.addr()` API.
Based on an initial version of the lint by ```@Gankra``` in #95199.
2022-04-09 05:58:42 +02:00
Dylan DPC
9010879c0a
Rollup merge of #95374 - RalfJung:assert_uninit_valid, r=Mark-Simulacrum
assert_uninit_valid: ensure we detect at least arrays of uninhabited types

We can't easily extend this check to *all* arrays (Cc https://github.com/rust-lang/rust/pull/87041), but it turns out the existing check already catches arrays of uninhabited types. So let's make sure it stays that way by adding them to the test.
2022-04-09 05:58:41 +02:00
Dylan DPC
ee8cea8ac4
Rollup merge of #90066 - yaahc:thinbox, r=joshtriplett
Add new ThinBox type for 1 stack pointer wide heap allocated trait objects

**Zulip Thread**: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/ThinBox

Based on b58d1d3cba/examples/thin.rs

Tracking Issue: https://github.com/rust-lang/rust/issues/92791

Usage Trial: https://github.com/yaahc/pgx/pull/1/files

## TODO

- [x] make sure to test with #[repr(align(1024))] structs etc
2022-04-09 05:58:40 +02:00
Ben Kimock
dec73f58d8 Remove ptr-int transmute in std::sync::mpsc
Since https://github.com/rust-lang/rust/pull/95340 landed, Miri with
-Zmiri-check-number-validity produces an error on the test suites of
some crates which implement concurrency tools, because it seems like
such crates tend to use std::sync::mpsc in their tests. This fixes the
problem by storing pointer bytes in a pointer.
2022-04-08 23:28:31 -04:00
Scott McMurray
fe0c08a4f2 Make non-power-of-two alignments a validity error in Layout
Inspired by the zulip conversation about how `Layout` should better enforce `size < isize::MAX as usize`, this uses an N-variant enum on N-bit platforms to require at the validity level that the existing invariant of "must be a power of two" is upheld.

This was MIRI can catch it, and means there's a more-specific type for `Layout` to store than just `NonZeroUsize`.
2022-04-08 20:17:38 -07:00
bors
e980c62955 Auto merge of #95524 - oli-obk:cached_stable_hash_cleanups, r=nnethercote
Cached stable hash cleanups

r? `@nnethercote`

Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time.

Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
2022-04-09 02:31:24 +00:00
Redzic
1e6365d075 Use bitwise XOR in to_ascii_uppercase
This saves an instruction compared to the previous approach, which
was to unset the fifth bit with bitwise OR.
2022-04-08 20:06:54 -05:00
Nicholas Nethercote
7450c4e3e8 Remove explicit delimiter token trees from Delimited.
They were introduced by the final commit in #95159 and gave a
performance win. But since the introduction of `MatcherLoc` they are no
longer needed. This commit reverts that change, making the code a bit
simpler.
2022-04-09 10:11:40 +10:00
bors
340f6491be Auto merge of #95815 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/95627
r? `@ghost` Cc `@rust-lang/miri`
2022-04-08 23:41:26 +00:00
bors
f4a7ce997a Auto merge of #95519 - oli-obk:tait_ub2, r=compiler-errors
Enforce well formedness for type alias impl trait's hidden type

fixes #84657

This was not an issue with return-position-impl-trait because the generic bounds of the function are the same as those of the opaque type, and the hidden type must already be well formed within the function.

With type-alias-impl-trait the hidden type could be defined in a function that has *more* lifetime bounds than the type alias. This is fine, but the hidden type must still be well formed without those additional bounds.
2022-04-08 20:45:16 +00:00
Pietro Albini
d7b867b7e5
bump rls and racer 2022-04-08 22:02:08 +02:00
Jack O'Connor
c1023e9e5f hide another #[allow] directive from a docs example
This is a repeat for Rc of e0e64a8930,
which cleaned up the same thing for Arc.
2022-04-08 10:29:50 -07:00
Ralf Jung
083be9cc9c update Miri 2022-04-08 12:02:05 -04:00
Jane Lusby
a87a0d089e Add ThinBox type for 1 stack pointer sized heap allocated trait objects
Relevant commit messages from squashed history in order:

Add initial version of ThinBox

update test to actually capture failure

swap to middle ptr impl based on matthieu-m's design

Fix stack overflow in debug impl

The previous version would take a `&ThinBox<T>` and deref it once, which
resulted in a no-op and the same type, which it would then print causing
an endless recursion. I've switched to calling `deref` by name to let
method resolution handle deref the correct number of times.

I've also updated the Drop impl for good measure since it seemed like it
could be falling prey to the same bug, and I'll be adding some tests to
verify that the drop is happening correctly.

add test to verify drop is behaving

add doc examples and remove unnecessary Pointee bounds

ThinBox: use NonNull

ThinBox: tests for size

Apply suggestions from code review

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>

use handle_alloc_error and fix drop signature

update niche and size tests

add cfg for allocating APIs

check null before calculating offset

add test for zst and trial usage

prevent optimizer induced ub in drop and cleanup metadata gathering

account for arbitrary size and alignment metadata

Thank you nika and thomcc!

Update library/alloc/src/boxed/thin.rs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>

Update library/alloc/src/boxed/thin.rs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-04-08 09:00:16 -07:00
Oli Scherer
25d6f8e0f6 Avoid looking at the internals of Interned directly 2022-04-08 15:57:44 +00:00
niluxv
98a4834237 Split fuzzy_provenance_casts into lossy and fuzzy, feature gate and test it
* split `fuzzy_provenance_casts` into a ptr2int and a int2ptr lint
* feature gate both lints
* update documentation to be more realistic short term
* add tests for these lints
2022-04-08 17:41:28 +02:00
Aria Beingessner
1040cab53b WIP PROOF-OF-CONCEPT: Make the compiler complain about all int<->ptr casts.
ALL

OF

THEM
2022-04-08 17:40:33 +02:00
Takayuki Maeda
470b4fca0e use format-args-capture and remove unnecessary nested blocks 2022-04-09 00:01:40 +09:00
Takayuki Maeda
71fea61bc9 suggest adding a local for vector to fix borrowck errors 2022-04-08 23:17:57 +09:00
Mara Bos
307aa588f4
Fix typo in futex rwlock.
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-04-08 16:07:07 +02:00
Guillaume Gomez
5e8bd9bbaa Add test for empty doc comments with a backline 2022-04-08 15:30:53 +02:00
Guillaume Gomez
43d0497824 Fix invalid array access in beautify_doc_string 2022-04-08 15:30:37 +02:00
Caio
e946aa3a74 Left overs of #95761 2022-04-08 10:30:24 -03:00
bors
2d5a21f63c Auto merge of #95772 - flip1995:clippyup, r=Manishearth,flip1995
Update Clippy

r? `@Manishearth`
2022-04-08 13:22:07 +00:00
Ralf Jung
9c977530b5 fix some unused constant warning on some Windows targets 2022-04-08 08:36:56 -04:00
Mara Bos
6cb463cb11 Add futex-based RwLock on Linux. 2022-04-08 13:49:18 +02:00
bors
e4f5b15b88 Auto merge of #95798 - Dylan-DPC:rollup-51hx1wl, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #95102 (Add known-bug for #95034)
 - #95579 (Add `<[[T; N]]>::flatten{_mut}`)
 - #95634 (Mailmap update)
 - #95705 (Promote x86_64-unknown-none target to Tier 2 and distribute build artifacts)
 - #95761 (Kickstart the inner usage of `macro_metavar_expr`)
 - #95782 (Windows: Increase a pipe's buffer capacity to 64kb)
 - #95791 (hide an #[allow] directive from the Arc::new_cyclic doc example)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-08 10:41:10 +00:00
Dylan DPC
7b285d09e9
Rollup merge of #95791 - oconnor663:doc_comment, r=thomcc
hide an #[allow] directive from the Arc::new_cyclic doc example

A minor docs cleanup.
2022-04-08 11:48:26 +02:00
Dylan DPC
fdfdb336e2
Rollup merge of #95782 - ChrisDenton:pipe-buffer-size, r=thomcc
Windows: Increase a pipe's buffer capacity to 64kb

This brings it inline with typical Linux defaults: https://www.man7.org/linux/man-pages/man7/pipe.7.html

> Since Linux 2.6.11, the pipe capacity is 16 pages (i.e., 65,536 bytes in a system with a page size of 4096 bytes).

This may also help with #45572 and #95759 but does not fix either issue. It simply makes them much less likely to be encountered.
2022-04-08 11:48:25 +02:00
Dylan DPC
1f80881a94
Rollup merge of #95761 - c410-f3r:meta-var-stuff, r=petrochenkov
Kickstart the inner usage of `macro_metavar_expr`

There can be more use-cases but I am out of ideas.

cc #83527
r? ``@petrochenkov``
2022-04-08 11:48:24 +02:00