Commit Graph

207914 Commits

Author SHA1 Message Date
Michael Howell
46169e6658 rustdoc: merge identical CSS selectors 2022-10-11 15:05:22 -07:00
Michael Howell
87060c42ff rustdoc: remove unused CSS nav.sum
This was added in 4fd061c426, but never
actually used.
2022-10-11 14:46:49 -07:00
Weihang Lo
1ff4f521c7
Update cargo
9 commits in 3cdf1ab25dc4fe56f890e8c7330d53a23ad905d3..b8f30cb23c4e5f20854a4f683325782b7cff9837
2022-10-07 17:34:03 +0000 to 2022-10-10 19:16:06 +0000

- Add more doc comments for three modules (rust-lang/cargo#11207)
- docs: fix (rust-lang/cargo#11208)
- Add completions for `cargo remove` (rust-lang/cargo#11204)
- Config file loaded via CLI takes priority over env vars (rust-lang/cargo#11077)
- Use `#[default]` when possible (rust-lang/cargo#11197)
- Implement RFC 3289: source replacement ambiguity (rust-lang/cargo#10907)
- Use correct version of cargo in test (rust-lang/cargo#11193)
- Check empty input for login (rust-lang/cargo#11145)
- Add retry support to sparse registries (rust-lang/cargo#11069)
2022-10-11 21:58:26 +01:00
Ralf Jung
38c78a9ac1 reorder panicking.rs to put main entry points at the top 2022-10-11 22:47:31 +02:00
Ralf Jung
b61e742a39 use panic_fmt_nounwind for assert_unsafe_precondition 2022-10-11 22:47:31 +02:00
Ralf Jung
66282cb47d add panic_fmt_nounwind for panicing without unwinding, and use it for panic_no_unwind 2022-10-11 22:47:31 +02:00
Ralf Jung
2b50cd1877 rename rustc_allocator_nounwind to rustc_nounwind 2022-10-11 22:47:31 +02:00
bors
a0ab61fb6c Auto merge of #13358 - btwotwo:feature/env-vars-autocompletion, r=Veykril
feat: Autocomplete Cargo-defined env vars in `env!` and `option_env!` (#12448)

Closes #12448

Important to know:

- Variables are taken from https://doc.rust-lang.org/cargo/reference/environment-variables.html and hardcoded as a const array.
- For the sake of simplicity I didn't include the autocompletion of `CARGO_BIN_EXE_<name>` and `OUT_DIR` since it would require information about build.rs and binary name. If somebody knows an easy way of obtaining them I can add those vars as well :)
2022-10-11 18:45:31 +00:00
Andrew Brown
95b0b2d349 fix: return type of single-threaded dummy lock must be droppable 2022-10-11 11:42:44 -07:00
btwotwo
2b2b9f8c73
Formatting 2022-10-11 19:53:22 +02:00
Michael Goulet
f9d3c83526 Fix let removal suggestion in struct 2022-10-11 17:35:50 +00:00
btwotwo
b5e87ac111
Fix formatting for cargo vars list 2022-10-11 19:29:09 +02:00
btwotwo
a807cc3afb
Rename get_outer_macro to macro_call_for_string_token 2022-10-11 19:28:42 +02:00
btwotwo
3c39668ca4
Remove extra parameter, access Db through semantics 2022-10-11 19:23:41 +02:00
bors
db0597f561 Auto merge of #102926 - matthiaskrgr:rollup-oe2cdzj, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #100387 (Check uniqueness of impl items by trait item when applicable.)
 - #101727 (Stabilize map_first_last)
 - #101774 (Warn about safety of `fetch_update`)
 - #102227 (fs::get_path solarish version.)
 - #102445 (Add `is_empty()` method to `core::ffi::CStr`.)
 - #102612 (Migrate `codegen_ssa` to diagnostics structs - [Part 1])
 - #102685 (Interpret EH actions properly)
 - #102869 (Add basename and dirname aliases)
 - #102889 (rustc_hir: Less error-prone methods for accessing `PartialRes` resolution)
 - #102893 (Fix ICE #102878)
 - #102912 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-11 17:20:48 +00:00
Matthias Krüger
3e01d072f7
Rollup merge of #102912 - lnicola:rust-analyzer-2022-10-11, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-10-11 18:59:51 +02:00
Matthias Krüger
a13c7da23e
Rollup merge of #102893 - TaKO8Ki:fix-102878, r=davidtwco
Fix ICE #102878

Fixes #102878
2022-10-11 18:59:50 +02:00
Matthias Krüger
cb67283392
Rollup merge of #102889 - petrochenkov:partres, r=cjgillot
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution
2022-10-11 18:59:50 +02:00
Matthias Krüger
ccde95f489
Rollup merge of #102869 - azdavis:master, r=joshtriplett
Add basename and dirname aliases

Users might be used to the POSIX names of these functions. In fact, here's a [blog post][1] about this very thing.

[1]: https://boinkor.net/2019/07/basename-and-dirname-in-rust/
2022-10-11 18:59:49 +02:00
Matthias Krüger
1b1223df9f
Rollup merge of #102685 - nbdd0121:unwind, r=m-ou-se
Interpret EH actions properly

The EH actions stored in the LSDA follows the format of GCC except table (even for LLVM-generated code). An missing action in the table is the encoding for `Terminate`, see https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/eh_personality.cc#L522-L526.

The currently code interprets it as `None`, as a workaround for #35011, an issue that seems to occur in LLVM 3.7 and not after 3.9. These are very old versions of LLVM and we don't support them anymore, so remove this workaround and interpret them properly.

Note that LLVM currently does not emit any `Terminate` actions, but GCC does. Although GCC backend currently doesn't do unwinding, removing it preemptively would prevent future developers from wasting time to figure out what's wrong.

``@rustbot`` label: +T-compiler
2022-10-11 18:59:49 +02:00
Matthias Krüger
24722e8d5b
Rollup merge of #102612 - JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs, r=davidtwco
Migrate `codegen_ssa` to diagnostics structs - [Part 1]

Initial migration of `codegen_ssa`. Going to split this crate migration in at least two PRs in order to avoid a huge PR and to quick off some questions around:

1. Translating messages from "external" crates.
2. Interfacing with OS messages.
3. Adding UI tests while migrating diagnostics.

_See comments below._
2022-10-11 18:59:48 +02:00
Matthias Krüger
d10b47ef69
Rollup merge of #102445 - jmillikin:cstr-is-empty, r=Mark-Simulacrum
Add `is_empty()` method to `core::ffi::CStr`.

ACP: https://github.com/rust-lang/libs-team/issues/106

Tracking issue: https://github.com/rust-lang/rust/issues/102444
2022-10-11 18:59:48 +02:00
Matthias Krüger
51320b3a16
Rollup merge of #102227 - devnexen:solarish_get_path, r=m-ou-se
fs::get_path solarish version.

similar to linux, albeit there is no /proc/self notion on solaris
 based system thus flattening the difference for simplification sake.
2022-10-11 18:59:47 +02:00
Matthias Krüger
d13f7aef70
Rollup merge of #101774 - Riolku:atomic-update-aba, r=m-ou-se
Warn about safety of `fetch_update`

Specifically as it relates to the ABA problem.

`fetch_update` is a useful function, and one that isn't provided by, say, C++. However, this does not mean the function is magic. It is implemented in terms of `compare_exchange_weak`, and in particular, suffers from the ABA problem. See the following code, which is a naive implementation of `pop` in a lock-free queue:

```rust
fn pop(&self) -> Option<i32> {
    self.front.fetch_update(Ordering::Relaxed, Ordering::Acquire, |front| {
        if front == ptr::null_mut() {
            None
        }
        else {
            Some(unsafe { (*front).next })
        }
    }.ok()
}
```

This code is unsound if called from multiple threads because of the ABA problem. Specifically, suppose nodes are allocated with `Box`. Suppose the following sequence happens:

```
Initial: Queue is X -> Y.

Thread A: Starts popping, is pre-empted.
Thread B: Pops successfully, twice, leaving the queue empty.
Thread C: Pushes, and `Box` returns X (very common for allocators)
Thread A: Wakes up, sees the head is still X, and stores Y as the new head.
```

But `Y` is deallocated. This is undefined behaviour.

Adding a note about this problem to `fetch_update` should hopefully prevent users from being misled, and also, a link to this common problem is, in my opinion, an improvement to our docs on atomics.
2022-10-11 18:59:46 +02:00
Matthias Krüger
cadb37a8c7
Rollup merge of #101727 - est31:stabilize_map_first_last, r=m-ou-se
Stabilize map_first_last

Stabilizes the following functions:

```Rust
impl<T> BTreeSet<T> {
    pub fn first(&self) -> Option<&T> where T: Ord;
    pub fn last(&self) -> Option<&T> where T: Ord;
    pub fn pop_first(&mut self) -> Option<T> where T: Ord;
    pub fn pop_last(&mut self) -> Option<T> where T: Ord;
}

impl<K, V> BTreeMap<K, V> {
    pub fn first_key_value(&self) -> Option<(&K, &V)> where K: Ord;
    pub fn last_key_value(&self) -> Option<(&K, &V)> where K: Ord;
    pub fn first_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord;
    pub fn last_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord;
    pub fn pop_first(&mut self) -> Option<(K, V)> where K: Ord;
    pub fn pop_last(&mut self) -> Option<(K, V)> where K: Ord;
}
```

Closes #62924

~~Blocked on the [FCP](https://github.com/rust-lang/rust/issues/62924#issuecomment-1179489929) finishing.~~ Edit: It finished!
2022-10-11 18:59:46 +02:00
Matthias Krüger
6d58ff7fe6
Rollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkov
Check uniqueness of impl items by trait item when applicable.

When checking uniqueness of item names in impl blocks, we currently use the same definition of hygiene as for toplevel items.  This means that a plain item and one generated by a macro 2.0 do not collide.

This hygiene rule does not match with how impl items resolve to associated trait items. As a consequence, we misdiagnose the trait impls.

This PR proposes to consider that trait impl items are uses of the corresponding trait items during resolution, instead of checking for duplicates later. An error is emitted when a trait impl item is used twice.

There should be no stable breakage, since macros 2.0 are still unstable.

r? ``@petrochenkov``
cc ``@RalfJung``

Fixes https://github.com/rust-lang/rust/issues/71614.
2022-10-11 18:59:45 +02:00
Michael Howell
062284af6e rustdoc: remove unneeded .content selector from link colors
Since 98f05a0282 and
b5963f07e6 removed color classes from sidebar
items, there's no need for the selectors to be so specific any more.

This commit does have to change `h1.fqn a` to just be `h1 a`, so that the
header link color selector is less specific than the typed link at the end.
Since #89506 made docblocks start at `h2`, the main page link header should
be the only h1 in the page now.
2022-10-11 09:22:40 -07:00
Michael Howell
b5963f07e6 rustdoc: remove unused classes from sidebar
Since 98f05a0282 removed separate colors
from the currently-selected item, there's no need to have item classes on
sidebar links.
2022-10-11 08:50:41 -07:00
bors
cde693cf96 Auto merge of #102894 - RalfJung:compiler_builtins, r=Amanieu
update compiler_builtins

r? `@Amanieu`
2022-10-11 14:04:59 +00:00
bors
d08f1c3dff Auto merge of #13382 - lowr:fix/reorder-dyn-bounds-on-render, r=lowr
fix: reorder dyn bounds on render

Fixes #13368

#13192 changed the order of dyn bounds, violating the [contract](3a69435af7/crates/hir-ty/src/display.rs (L896-L901)) with `write_bounds_like_dyn_trait()` on render. The projection bounds are expected to come right after the trait bound they are accompanied with.

Although the reordering procedure can be made a bit more efficient, I opted for relying only on the [invariants](3a69435af7/crates/hir-ty/src/lower.rs (L995-L998)) currently documented in `lower_dyn_trait()`. It's not the hottest path and dyn bounds tend to be short so I believe it shouldn't hurt performance noticeably.
2022-10-11 11:44:32 +00:00
zyctree
34977996c3
Update docs/dev/syntax.md
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2022-10-11 19:37:49 +08:00
Ryo Yoshida
5e43ea96aa
fix: reorder dyn bounds on render 2022-10-11 20:26:11 +09:00
bors
bb93450ec4 Auto merge of #102915 - JohnTitor:rollup-5ht99y1, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #102258 (Remove unused variable in float formatting.)
 - #102277 (Consistently write `RwLock`)
 - #102412 (Never panic in `thread::park` and `thread::park_timeout`)
 - #102589 (scoped threads: pass closure through MaybeUninit to avoid invalid dangling references)
 - #102625 (fix backtrace small typo)
 - #102859 (Move lifetime resolution module to rustc_hir_analysis.)
 - #102898 (rustdoc: remove unneeded `<div>` wrapper from sidebar DOM)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-11 11:03:12 +00:00
Yuki Okushi
3011538b80
Rollup merge of #102898 - notriddle:notriddle/sidebar-block, r=GuillaumeGomez
rustdoc: remove unneeded `<div>` wrapper from sidebar DOM

When this was added, the sidebar had a bit more complex style. It can be removed, now.

Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-block/std/index.html
2022-10-11 18:37:55 +09:00
Yuki Okushi
98764c0c72
Rollup merge of #102859 - cjgillot:collect-lifetimes, r=oli-obk
Move lifetime resolution module to rustc_hir_analysis.

Now that lifetime resolution has been removed from it, this file has nothing to do in `rustc_resolve`.  It's purpose is to compute Debruijn indices for lifetimes, so let's put it in type collection.
2022-10-11 18:37:55 +09:00
Yuki Okushi
b380518691
Rollup merge of #102625 - Rageking8:fix-backtrace-small-typo, r=m-ou-se
fix backtrace small typo
2022-10-11 18:37:54 +09:00
Yuki Okushi
919d6bf446
Rollup merge of #102589 - RalfJung:scoped-threads-dangling, r=m-ou-se
scoped threads: pass closure through MaybeUninit to avoid invalid dangling references

The `main` function defined here looks roughly like this, if it were written as a more explicit stand-alone function:
```rust
// Not showing all the `'lifetime` tracking, the point is that
// this closure might live shorter than `thread`.
fn thread(control: ..., closure: impl FnOnce() + 'lifetime) {
    closure();
    control.signal_done();
    // A lot of time can pass here.
}
```
Note that `thread` continues to run even after `signal_done`! Now consider what happens if the `closure` captures a reference of lifetime `'lifetime`:
- The type of `closure` is a struct (the implicit unnameable closure type) with a `&'lifetime mut T` field. References passed to a function are marked with `dereferenceable`, which is LLVM speak for *this reference will remain live for the entire duration of this function*.
- The closure runs, `signal_done` runs. Then -- potentially -- this thread gets scheduled away and the main thread runs, seeing the signal and returning to the user. Now `'lifetime` ends and the memory the reference points to might be deallocated.
- Now we have UB! The reference that as passed to `thread` with the promise of remaining live for the entire duration of the function, actually got deallocated while the function still runs. Oops.

Long-term I think we should be able to use `ManuallyDrop` to fix this without `unsafe`, or maybe a new `MaybeDangling` type. I am working on an RFC for that. But in the mean time it'd be nice to fix this so that Miri with `-Zmiri-retag-fields` (which is needed for "full enforcement" of all the LLVM flags we generate) stops erroring on scoped threads.

Fixes https://github.com/rust-lang/rust/issues/101983
r? `@m-ou-se`
2022-10-11 18:37:54 +09:00
Yuki Okushi
e0954cadc8
Rollup merge of #102412 - joboet:dont_panic, r=m-ou-se
Never panic in `thread::park` and `thread::park_timeout`

fixes #102398

`@rustbot` label +T-libs +T-libs-api
2022-10-11 18:37:53 +09:00
Yuki Okushi
387df55f26
Rollup merge of #102277 - mgeisler:rwlock, r=m-ou-se
Consistently write `RwLock`

Before the documentation sometimes referred to an "rwlock" and sometimes to "`RwLock`".
2022-10-11 18:37:52 +09:00
Yuki Okushi
ff903bbb71
Rollup merge of #102258 - cjgillot:core-kappa, r=m-ou-se
Remove unused variable in float formatting.
2022-10-11 18:37:52 +09:00
Guillaume Gomez
bca1005d6a Add GUI test for source code pages highlighting 2022-10-11 11:34:29 +02:00
Guillaume Gomez
202ccc50dd Migrate highlight style to CSS variables 2022-10-11 11:34:29 +02:00
bors
1e926f0652 Auto merge of #102755 - pcc:data-local-tmp, r=Mark-Simulacrum
tools/remote-test-{server,client}: Use /data/local/tmp on Android

The /data/tmp directory does not exist, at least not on recent versions of Android, which currently leads to test failures on that platform. I checked a virtual device running AOSP master and a Nexus 5 running Android Marshmallow and on both devices the /data/tmp directory does not exist and /data/local/tmp does, so let's switch to /data/local/tmp.
2022-10-11 08:09:41 +00:00
Laurențiu Nicola
c867288d1b ⬆️ rust-analyzer 2022-10-11 10:37:35 +03:00
woppopo
a53e3acca9 Change tracking issue from #76156 to #102911 2022-10-11 06:40:37 +00:00
Camille GILLOT
152cd63226 Report duplicate definitions in trait impls during resolution. 2022-10-11 06:24:51 +00:00
zyctree
11a335d5e8
fix link in syntax.md 2022-10-11 14:05:04 +08:00
Vadim Petrochenkov
1a8f177772 rustc_hir: Less error-prone methods for accessing PartialRes resolution 2022-10-11 09:04:52 +04:00
bors
365578445c Auto merge of #102724 - pcc:scs-fix-test, r=Mark-Simulacrum
Fix the sanitizer_scs_attr_check.rs test

The test is failing when targeting aarch64 Android. The intent appears to have been to look for a function attributes comment (or the absence of one) on the line preceding the function declaration. But this isn't quite possible with FileCheck and the test as written was looking for a line with `no_scs` after a line with `scs`, which doesn't appear in the output. Instead, match on the function attributes comment on the line following the demangled function name comment.
2022-10-11 04:27:13 +00:00
Michael Howell
44f466cb08
Remove outdated comment 2022-10-10 17:53:27 -07:00