]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #96701 - kraktus:alloc_example_2018_edition, r=Mark-Simulacrum
Michael Goulet [Sat, 7 May 2022 03:49:31 +0000 (20:49 -0700)]
Rollup merge of #96701 - kraktus:alloc_example_2018_edition, r=Mark-Simulacrum

update `jemallocator` example to use 2018 edition import syntax

2 years agoRollup merge of #96660 - jyn514:better-missing-path-error, r=Mark-Simulacrum
Michael Goulet [Sat, 7 May 2022 03:49:30 +0000 (20:49 -0700)]
Rollup merge of #96660 - jyn514:better-missing-path-error, r=Mark-Simulacrum

[bootstrap] Give a better error when trying to run a path with no registered step

Before:
```
thread 'main' panicked at 'error: no rules matched invalid', src/bootstrap/builder.rs:287:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

After:
```
error: no `check` rules matched 'invalid'
help: run `x.py check --help --verbose` to show a list of available paths
note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`
```

2 years agoAuto merge of #96458 - Aaron1011:no-cycle-caching, r=jackh726,cjgillot
bors [Fri, 6 May 2022 22:41:16 +0000 (22:41 +0000)]
Auto merge of #96458 - Aaron1011:no-cycle-caching, r=jackh726,cjgillot

Don't cache results of coinductive cycle

2 years agoAuto merge of #96785 - GuillaumeGomez:rollup-rgiwa57, r=GuillaumeGomez
bors [Fri, 6 May 2022 20:14:01 +0000 (20:14 +0000)]
Auto merge of #96785 - GuillaumeGomez:rollup-rgiwa57, r=GuillaumeGomez

Rollup of 10 pull requests

Successful merges:

 - #96557 (Allow inline consts to reference generic params)
 - #96590 (rustdoc: when running a function-signature search, tweak the tab bar)
 - #96650 (Collect function instance used in `global_asm!` sym operand)
 - #96733 (turn `append_place_to_string` from recursion into iteration)
 - #96748 (Fixes reexports in search)
 - #96752 (Put the incompatible_closure_captures lint messages in alphabetical order)
 - #96754 (rustdoc: ensure HTML/JS side implementors don't have dups)
 - #96772 (Suggest fully qualified path with appropriate params)
 - #96776 (Fix two minor issues in hir.rs)
 - #96782 (a small `mirror_expr` cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #96782 - lcnr:mirror-expr, r=compiler-errors
Guillaume Gomez [Fri, 6 May 2022 18:05:45 +0000 (20:05 +0200)]
Rollup merge of #96782 - lcnr:mirror-expr, r=compiler-errors

a small `mirror_expr` cleanup

2 years agoRollup merge of #96776 - liuw:hir, r=oli-obk
Guillaume Gomez [Fri, 6 May 2022 18:05:45 +0000 (20:05 +0200)]
Rollup merge of #96776 - liuw:hir, r=oli-obk

Fix two minor issues in hir.rs

I found these two places in hir.rs which could use a bit of improvements while going through the code.

No functional change.

2 years agoRollup merge of #96772 - TaKO8Ki:suggest-fully-qualified-path-with-appropriate-params...
Guillaume Gomez [Fri, 6 May 2022 18:05:44 +0000 (20:05 +0200)]
Rollup merge of #96772 - TaKO8Ki:suggest-fully-qualified-path-with-appropriate-params, r=compiler-errors

Suggest fully qualified path with appropriate params

closes #96291

2 years agoRollup merge of #96754 - notriddle:notriddle/impl-dups, r=GuillaumeGomez
Guillaume Gomez [Fri, 6 May 2022 18:05:43 +0000 (20:05 +0200)]
Rollup merge of #96754 - notriddle:notriddle/impl-dups, r=GuillaumeGomez

rustdoc: ensure HTML/JS side implementors don't have dups

Fixes #94641

Rendered:

- https://notriddle.com/notriddle-rustdoc-test/impl-dups/std/iter/trait.Iterator.html
- https://notriddle.com/notriddle-rustdoc-test/impl-dups/core/iter/trait.Iterator.html

2 years agoRollup merge of #96752 - scottmcm:error-sorting, r=compiler-errors
Guillaume Gomez [Fri, 6 May 2022 18:05:42 +0000 (20:05 +0200)]
Rollup merge of #96752 - scottmcm:error-sorting, r=compiler-errors

Put the incompatible_closure_captures lint messages in alphabetical order

Looks like they were in hash order before, which was causing me trouble in #94598, so this PR sorts the errors by trait name.

2 years agoRollup merge of #96748 - GuillaumeGomez:reexports-in-search, r=notriddle
Guillaume Gomez [Fri, 6 May 2022 18:05:41 +0000 (20:05 +0200)]
Rollup merge of #96748 - GuillaumeGomez:reexports-in-search, r=notriddle

Fixes reexports in search

Fixes #96681.

At some point we stopped reexporting items in search so this PR fixes it.

It also adds a regression test.

r? ```@notriddle```

2 years agoRollup merge of #96733 - SparrowLii:place_to_string, r=davidtwco
Guillaume Gomez [Fri, 6 May 2022 18:05:40 +0000 (20:05 +0200)]
Rollup merge of #96733 - SparrowLii:place_to_string, r=davidtwco

turn `append_place_to_string` from recursion into iteration

This PR fixes the FIXME in the impl of `append_place_to_string` which turns `append_place_to_string` from recursion into iteration, meanwhile simplifying the code relatively.

2 years agoRollup merge of #96650 - tmiasko:global-asm-sym-fn, r=Amanieu
Guillaume Gomez [Fri, 6 May 2022 18:05:39 +0000 (20:05 +0200)]
Rollup merge of #96650 - tmiasko:global-asm-sym-fn, r=Amanieu

Collect function instance used in `global_asm!` sym operand

The constants used in SymFn operands have FnDef type,
so the type of the constant identifies the function.

Fixes #96623.

2 years agoRollup merge of #96590 - notriddle:notriddle/tab-bar-fn-search, r=GuillaumeGomez...
Guillaume Gomez [Fri, 6 May 2022 18:05:38 +0000 (20:05 +0200)]
Rollup merge of #96590 - notriddle:notriddle/tab-bar-fn-search, r=GuillaumeGomez,jsha

rustdoc: when running a function-signature search, tweak the tab bar

# Before

![In Names (7) / In Parameters (0) / In Return types (0)](https://user-images.githubusercontent.com/1593513/166122875-ffdeafe6-8d4d-4e61-84a6-f5986b50ac35.png)

# After

![In Function Signature (7)](https://user-images.githubusercontent.com/1593513/166122883-9a3d7515-3235-4ee3-8c4b-5401d109e099.png)

2 years agoRollup merge of #96557 - nbdd0121:const, r=oli-obk
Guillaume Gomez [Fri, 6 May 2022 18:05:37 +0000 (20:05 +0200)]
Rollup merge of #96557 - nbdd0121:const, r=oli-obk

Allow inline consts to reference generic params

Tracking issue: #76001

The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well.

However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have:
```rust
fn foo<T>() {
    let x = [4i32; std::mem::size_of::<T>()];   // NOT ALLOWED (for now)
    let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR!
    let x = [4i32; const { std::mem::size_of::<T>() }];   // NOT ALLOWED (for now)
}
```

This would make inline consts super useful for compile-time checks and assertions:
```rust
fn assert_zst<T>() {
    const { assert!(std::mem::size_of::<T>() == 0) };
}
```

This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do:
```rust
fn assert_zst<T>() {
    struct F<T>(T);
    impl<T> F<T> {
        const V: () = assert!(std::mem::size_of::<T>() == 0);
    }
    let _ = F::<T>::V;
}
```

It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either:
```rust
fn foo<T>() -> usize {
    let (_, size): (PhantomData<T>, usize) = const {
        const fn my_size_of<T>() -> (PhantomData<T>, usize) {
            (PhantomData, std::mem::size_of::<T>())
        }
        my_size_of()
    };
    size
}
```

```@rustbot``` label: F-inline_const

2 years agoAuto merge of #95454 - randomicon00:fix95444, r=wesleywiser
bors [Fri, 6 May 2022 17:52:47 +0000 (17:52 +0000)]
Auto merge of #95454 - randomicon00:fix95444, r=wesleywiser

Fixing #95444 by only displaying passes that take more than 5 millise…

As discussed in #95444, I have added the code to test and only display prints that are greater than 5 milliseconds.

r? `@jyn514`

2 years ago`mirror_expr` cleanup
lcnr [Fri, 6 May 2022 17:00:37 +0000 (19:00 +0200)]
`mirror_expr` cleanup

2 years agoUse matches! for YieldSource::is_await
Wei Liu [Fri, 6 May 2022 15:00:48 +0000 (15:00 +0000)]
Use matches! for YieldSource::is_await

2 years agoFix comment for async closure variant
Wei Liu [Fri, 6 May 2022 14:59:40 +0000 (14:59 +0000)]
Fix comment for async closure variant

2 years agoAuto merge of #95183 - ibraheemdev:arc-count-acquire, r=Amanieu
bors [Fri, 6 May 2022 14:53:24 +0000 (14:53 +0000)]
Auto merge of #95183 - ibraheemdev:arc-count-acquire, r=Amanieu

Weaken needlessly restrictive orderings on `Arc::*_count`

There is no apparent reason for these to be `SeqCst`. For reference, [the Boost C++ implementation relies on acquire semantics](https://github.com/boostorg/smart_ptr/blob/f2cc84a23c64b8a73c9b72b34799d0854d7e0787/include/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp#L137-L140).

2 years agosuggest fully qualified path with appropriate params
Takayuki Maeda [Fri, 6 May 2022 14:14:11 +0000 (23:14 +0900)]
suggest fully qualified path with appropriate params

2 years agoAuto merge of #96268 - jackh726:remove-mutable_borrow_reservation_conflict-lint,...
bors [Fri, 6 May 2022 12:32:44 +0000 (12:32 +0000)]
Auto merge of #96268 - jackh726:remove-mutable_borrow_reservation_conflict-lint, r=nikomatsakis

Remove mutable_borrow_reservation_conflict lint and allow the code pattern

This was the only breaking issue with the NLL stabilization PR. Lang team decided to go ahead and allow this.

r? `@nikomatsakis`
Closes #59159
Closes #56254

2 years agoAdd missing newline
Michael Howell [Fri, 6 May 2022 12:18:32 +0000 (05:18 -0700)]
Add missing newline

2 years agoAdd GUI test for search reexports
Guillaume Gomez [Thu, 5 May 2022 19:56:40 +0000 (21:56 +0200)]
Add GUI test for search reexports

2 years agoFix reexports missing from the search index
Guillaume Gomez [Thu, 5 May 2022 19:56:03 +0000 (21:56 +0200)]
Fix reexports missing from the search index

2 years agoAuto merge of #94598 - scottmcm:prefix-free-hasher-methods, r=Amanieu
bors [Fri, 6 May 2022 09:43:57 +0000 (09:43 +0000)]
Auto merge of #94598 - scottmcm:prefix-free-hasher-methods, r=Amanieu

Add a dedicated length-prefixing method to `Hasher`

This accomplishes two main goals:
- Make it clear who is responsible for prefix-freedom, including how they should do it
- Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths

This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.

Fixes #94026

r? rust-lang/libs

---

The core of this change is the following two new methods on `Hasher`:

```rust
pub trait Hasher {
    /// Writes a length prefix into this hasher, as part of being prefix-free.
    ///
    /// If you're implementing [`Hash`] for a custom collection, call this before
    /// writing its contents to this `Hasher`.  That way
    /// `(collection![1, 2, 3], collection![4, 5])` and
    /// `(collection![1, 2], collection![3, 4, 5])` will provide different
    /// sequences of values to the `Hasher`
    ///
    /// The `impl<T> Hash for [T]` includes a call to this method, so if you're
    /// hashing a slice (or array or vector) via its `Hash::hash` method,
    /// you should **not** call this yourself.
    ///
    /// This method is only for providing domain separation.  If you want to
    /// hash a `usize` that represents part of the *data*, then it's important
    /// that you pass it to [`Hasher::write_usize`] instead of to this method.
    ///
    /// # Examples
    ///
    /// ```
    /// #![feature(hasher_prefixfree_extras)]
    /// # // Stubs to make the `impl` below pass the compiler
    /// # struct MyCollection<T>(Option<T>);
    /// # impl<T> MyCollection<T> {
    /// #     fn len(&self) -> usize { todo!() }
    /// # }
    /// # impl<'a, T> IntoIterator for &'a MyCollection<T> {
    /// #     type Item = T;
    /// #     type IntoIter = std::iter::Empty<T>;
    /// #     fn into_iter(self) -> Self::IntoIter { todo!() }
    /// # }
    ///
    /// use std::hash::{Hash, Hasher};
    /// impl<T: Hash> Hash for MyCollection<T> {
    ///     fn hash<H: Hasher>(&self, state: &mut H) {
    ///         state.write_length_prefix(self.len());
    ///         for elt in self {
    ///             elt.hash(state);
    ///         }
    ///     }
    /// }
    /// ```
    ///
    /// # Note to Implementers
    ///
    /// If you've decided that your `Hasher` is willing to be susceptible to
    /// Hash-DoS attacks, then you might consider skipping hashing some or all
    /// of the `len` provided in the name of increased performance.
    #[inline]
    #[unstable(feature = "hasher_prefixfree_extras", issue = "88888888")]
    fn write_length_prefix(&mut self, len: usize) {
        self.write_usize(len);
    }

    /// Writes a single `str` into this hasher.
    ///
    /// If you're implementing [`Hash`], you generally do not need to call this,
    /// as the `impl Hash for str` does, so you can just use that.
    ///
    /// This includes the domain separator for prefix-freedom, so you should
    /// **not** call `Self::write_length_prefix` before calling this.
    ///
    /// # Note to Implementers
    ///
    /// The default implementation of this method includes a call to
    /// [`Self::write_length_prefix`], so if your implementation of `Hasher`
    /// doesn't care about prefix-freedom and you've thus overridden
    /// that method to do nothing, there's no need to override this one.
    ///
    /// This method is available to be overridden separately from the others
    /// as `str` being UTF-8 means that it never contains `0xFF` bytes, which
    /// can be used to provide prefix-freedom cheaper than hashing a length.
    ///
    /// For example, if your `Hasher` works byte-by-byte (perhaps by accumulating
    /// them into a buffer), then you can hash the bytes of the `str` followed
    /// by a single `0xFF` byte.
    ///
    /// If your `Hasher` works in chunks, you can also do this by being careful
    /// about how you pad partial chunks.  If the chunks are padded with `0x00`
    /// bytes then just hashing an extra `0xFF` byte doesn't necessarily
    /// provide prefix-freedom, as `"ab"` and `"ab\u{0}"` would likely hash
    /// the same sequence of chunks.  But if you pad with `0xFF` bytes instead,
    /// ensuring at least one padding byte, then it can often provide
    /// prefix-freedom cheaper than hashing the length would.
    #[inline]
    #[unstable(feature = "hasher_prefixfree_extras", issue = "88888888")]
    fn write_str(&mut self, s: &str) {
        self.write_length_prefix(s.len());
        self.write(s.as_bytes());
    }
}
```

With updates to the `Hash` implementations for slices and containers to call `write_length_prefix` instead of `write_usize`.

`write_str` defaults to using `write_length_prefix` since, as was pointed out in the issue, the `write_u8(0xFF)` approach is insufficient for hashers that work in chunks, as those would hash `"a\u{0}"` and `"a"` to the same thing.  But since `SipHash` works byte-wise (there's an internal buffer to accumulate bytes until a full chunk is available) it overrides `write_str` to continue to use the add-non-UTF-8-byte approach.

---

Compatibility:

Because the default implementation of `write_length_prefix` calls `write_usize`, the changed hash implementation for slices will do the same thing the old one did on existing `Hasher`s.

2 years agoAuto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu
bors [Fri, 6 May 2022 07:20:04 +0000 (07:20 +0000)]
Auto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu

Use futex-based locks and thread parker on {Free, Open, DragonFly}BSD.

This switches *BSD to our futex-based locks and thread parker.

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

This is a draft, because this still needs a new version of the `libc` crate to be published that includes https://github.com/rust-lang/libc/pull/2770.

r? `@Amanieu`

2 years agoFor now, don't change the details of hashing a `str`
Scott McMurray [Fri, 6 May 2022 06:18:11 +0000 (23:18 -0700)]
For now, don't change the details of hashing a `str`

We might want to change the default before stabilizing (or maybe even after), but for getting in the new unstable methods, leave it as-is for now.  That way it won't break cargo and such.

2 years agoAdd a dedicated length-prefixing method to `Hasher`
Scott McMurray [Fri, 4 Mar 2022 08:17:26 +0000 (00:17 -0800)]
Add a dedicated length-prefixing method to `Hasher`

This accomplishes two main goals:
- Make it clear who is responsible for prefix-freedom, including how they should do it
- Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths

This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.

2 years agoAuto merge of #96759 - compiler-errors:rollup-p4jtm92, r=compiler-errors
bors [Fri, 6 May 2022 04:56:23 +0000 (04:56 +0000)]
Auto merge of #96759 - compiler-errors:rollup-p4jtm92, r=compiler-errors

Rollup of 7 pull requests

Successful merges:

 - #96174 (mark ptr-int-transmute test as no_run)
 - #96639 (Fix typo in `offset_from` documentation)
 - #96704 (Add rotation animation on settings button when loading)
 - #96730 (Add a regression test for #64173 and #66152)
 - #96741 (Improve settings loading strategy)
 - #96744 (Implement [OsStr]::join)
 - #96747 (Add `track_caller` to `DefId::expect_local()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoturn `append_place_to_string` from recursion into iteration
SparrowLii [Fri, 6 May 2022 04:11:42 +0000 (12:11 +0800)]
turn `append_place_to_string` from recursion into iteration

2 years agoRollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors
Michael Goulet [Fri, 6 May 2022 02:34:27 +0000 (19:34 -0700)]
Rollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors

Add `track_caller` to `DefId::expect_local()`

Suggested in https://github.com/rust-lang/rust/issues/96738#issuecomment-1118961888.
`DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.

2 years agoRollup merge of #96744 - est31:join_osstr, r=thomcc
Michael Goulet [Fri, 6 May 2022 02:34:26 +0000 (19:34 -0700)]
Rollup merge of #96744 - est31:join_osstr, r=thomcc

Implement [OsStr]::join

Implements join for `OsStr` and `OsString` slices:

```Rust
    let strings = [OsStr::new("hello"), OsStr::new("dear"), OsStr::new("world")];
    assert_eq!("hello dear world", strings.join(OsStr::new(" ")));
````

This saves one from converting to strings and back, or from implementing it manually.

2 years agoRollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, r=jsha
Michael Goulet [Fri, 6 May 2022 02:34:25 +0000 (19:34 -0700)]
Rollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, r=jsha

Improve settings loading strategy

I learned about this thanks to ```@jsha``` who suggested this approach:

It improves the settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections.

r? ```@jsha```

2 years agoRollup merge of #96730 - JohnTitor:unused-lifetimes-tests, r=compiler-errors
Michael Goulet [Fri, 6 May 2022 02:34:25 +0000 (19:34 -0700)]
Rollup merge of #96730 - JohnTitor:unused-lifetimes-tests, r=compiler-errors

Add a regression test for #64173 and #66152

Closes #64173
Closes #66152

Mixed the code as the root cause seems the same.

2 years agoRollup merge of #96704 - GuillaumeGomez:rotation-animation, r=jsha
Michael Goulet [Fri, 6 May 2022 02:34:24 +0000 (19:34 -0700)]
Rollup merge of #96704 - GuillaumeGomez:rotation-animation, r=jsha

Add rotation animation on settings button when loading

As discussed, I added an animation when the settings JS file is loading (I voluntarily made the timeout at the end of the `settings.js` super long so we can see what the animation looks like):

https://user-images.githubusercontent.com/3050060/166693243-816a08b7-5e39-4142-acd3-686ad9950d8e.mp4

r? ````@jsha````

2 years agoRollup merge of #96639 - adpaco-aws:fix-offset-from-typo, r=scottmcm
Michael Goulet [Fri, 6 May 2022 02:34:23 +0000 (19:34 -0700)]
Rollup merge of #96639 - adpaco-aws:fix-offset-from-typo, r=scottmcm

Fix typo in `offset_from` documentation

Small fix for what I think is a typo in the `offset_from` documentation.

Someone reading this may understand that the distance in bytes is obtained by dividing the distance by `mem::size_of::<T>()`, but here we just want to define "units of T" in terms of bytes (i.e., units of T == bytes / `mem::size_of::<T>()`).

2 years agoRollup merge of #96174 - RalfJung:no-run-transmute, r=scottmcm
Michael Goulet [Fri, 6 May 2022 02:34:22 +0000 (19:34 -0700)]
Rollup merge of #96174 - RalfJung:no-run-transmute, r=scottmcm

mark ptr-int-transmute test as no_run

This causes [CI failures in Miri](https://github.com/rust-lang/miri-test-libstd/runs/6062500259?check_suite_focus=true) since ptr-int-transmutes are rejected there (when strict provenance is enabled).

2 years agoFix test case checking for where the JS goes
Michael Howell [Fri, 6 May 2022 01:26:47 +0000 (18:26 -0700)]
Fix test case checking for where the JS goes

2 years agorustdoc: ensure HTML/JS side implementors don't have dups
Michael Howell [Fri, 6 May 2022 00:20:14 +0000 (17:20 -0700)]
rustdoc: ensure HTML/JS side implementors don't have dups

2 years agoPut the 2229 migration errors in alphabetical order
Scott McMurray [Wed, 4 May 2022 02:17:57 +0000 (19:17 -0700)]
Put the 2229 migration errors in alphabetical order

Looks like they were in FxHash order before, so it might just be luck that this used to be consistent across different word lengths.

2 years agoFixing #95444 by only displaying passes that take more than 5 milliseconds
Peh [Wed, 30 Mar 2022 00:29:29 +0000 (00:29 +0000)]
Fixing #95444 by only displaying passes that take more than 5 milliseconds

95444: Adding passes that include memory increase

Fix95444: Change the substraction with the abs_diff() method

Fix95444: Change the substraction with abs_diff() method

2 years agoAuto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkov
bors [Thu, 5 May 2022 23:24:36 +0000 (23:24 +0000)]
Auto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkov

generalize "incoherent impls" impl for user defined types

To allow the move of `trait Error` into core.

continues the work from #94963, finishes https://github.com/rust-lang/compiler-team/issues/487

r? `@petrochenkov` cc `@yaahc`

2 years agoAdd `track_caller` to `DefId::expect_local()`
Yuki Okushi [Thu, 5 May 2022 22:28:06 +0000 (07:28 +0900)]
Add `track_caller` to `DefId::expect_local()`

2 years agoImplement [OsStr]::join
est31 [Thu, 5 May 2022 19:38:15 +0000 (21:38 +0200)]
Implement [OsStr]::join

2 years agoRemove condvar::two_mutexes test.
Mara Bos [Thu, 5 May 2022 19:47:13 +0000 (21:47 +0200)]
Remove condvar::two_mutexes test.

We don't guarantee this panics. On most platforms it doesn't anymore.

2 years agoAuto merge of #96735 - flip1995:clippyup, r=Manishearth
bors [Thu, 5 May 2022 19:28:41 +0000 (19:28 +0000)]
Auto merge of #96735 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoImprove settings loading strategy by loading CSS and JS at the same time to prevent...
Guillaume Gomez [Thu, 5 May 2022 18:19:40 +0000 (20:19 +0200)]
Improve settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections

2 years agoDon't cache results of coinductive cycle
Aaron Hill [Wed, 27 Apr 2022 00:34:58 +0000 (20:34 -0400)]
Don't cache results of coinductive cycle

Fixes #96319

The logic around handling co-inductive cycles in the evaluation cache
is confusing and error prone. Fortunately, a perf run showed that it
doesn't actually appear to improve performance, so we can simplify
this code (and eliminate a source of ICEs) by just skipping caching
the evaluation results for co-inductive cycle participants.

This commit makes no changes to any of the other logic around
co-inductive cycle handling. Thus, while this commit could
potentially expose latent bugs that were being hidden by
caching, it should not introduce any new bugs.

2 years agoAuto merge of #96734 - matthiaskrgr:rollup-hng33tb, r=matthiaskrgr
bors [Thu, 5 May 2022 16:59:54 +0000 (16:59 +0000)]
Auto merge of #96734 - matthiaskrgr:rollup-hng33tb, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #95359 (Update `int_roundings` methods from feedback)
 - #95843 (Improve Rc::new_cyclic and Arc::new_cyclic documentation)
 - #96507 (Suggest calling `Self::associated_function()`)
 - #96635 (Use "strict" mode in JS scripts)
 - #96673 (Report that opaque types are not allowed in impls even in the presence of other errors)
 - #96682 (Show invisible delimeters (within comments) when pretty printing.)
 - #96714 (interpret/validity: debug-check ScalarPair layout information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agorustdoc: fix JS error when rendering parse error
Michael Howell [Tue, 3 May 2022 16:20:45 +0000 (09:20 -0700)]
rustdoc: fix JS error when rendering parse error

2 years agorustdoc: add test case assertions for ArrowDown highlight first result
Michael Howell [Tue, 3 May 2022 16:20:22 +0000 (09:20 -0700)]
rustdoc: add test case assertions for ArrowDown highlight first result

2 years agorustdoc: fix keyboard shortcuts and console log on search page
Michael Howell [Mon, 2 May 2022 22:50:01 +0000 (15:50 -0700)]
rustdoc: fix keyboard shortcuts and console log on search page

2 years agorustdoc: change the "In Function Signatures" to context-sensitive
Michael Howell [Mon, 2 May 2022 16:45:32 +0000 (09:45 -0700)]
rustdoc: change the "In Function Signatures" to context-sensitive

* If it's just `-> a`, use "In Function Return Types"
* If it's just `a b`, use "In Function Parameters"
* Otherwise, still use "In Function Signatures"

2 years agoUse STARTS_WITH, since it's more specific
Michael Howell [Sun, 1 May 2022 22:40:46 +0000 (15:40 -0700)]
Use STARTS_WITH, since it's more specific

Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2 years agorustdoc: when running a function-signature search, tweak the tab bar
Michael Howell [Sat, 30 Apr 2022 20:05:40 +0000 (13:05 -0700)]
rustdoc: when running a function-signature search, tweak the tab bar

2 years agoUpdate Cargo.lock
flip1995 [Thu, 5 May 2022 14:13:10 +0000 (15:13 +0100)]
Update Cargo.lock

2 years agoMerge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup
flip1995 [Thu, 5 May 2022 14:12:52 +0000 (15:12 +0100)]
Merge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup

2 years agoRollup merge of #96714 - RalfJung:scalar-pair-debug, r=oli-obk
Matthias Krüger [Thu, 5 May 2022 13:43:07 +0000 (15:43 +0200)]
Rollup merge of #96714 - RalfJung:scalar-pair-debug, r=oli-obk

interpret/validity: debug-check ScalarPair layout information

This would have caught https://github.com/rust-lang/rust/issues/96158.
I ran the Miri test suite and it still passes.

r? `@oli-obk`

2 years agoRollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov
Matthias Krüger [Thu, 5 May 2022 13:43:05 +0000 (15:43 +0200)]
Rollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov

Show invisible delimeters (within comments) when pretty printing.

Because invisible syntax is really hard to work with!

r? `@petrochenkov`

2 years agoRollup merge of #96673 - oli-obk:tait_impl_diagnostic, r=petrochenkov
Matthias Krüger [Thu, 5 May 2022 13:43:05 +0000 (15:43 +0200)]
Rollup merge of #96673 - oli-obk:tait_impl_diagnostic, r=petrochenkov

Report that opaque types are not allowed in impls even in the presence of other errors

fixes  #96569

before this PR those useful errors were hidden because either `unused parameter` or `only traits defined in the current crate can be implemented for arbitrary types` got emitted first.

2 years agoRollup merge of #96635 - GuillaumeGomez:js-script-mode, r=notriddle
Matthias Krüger [Thu, 5 May 2022 13:43:04 +0000 (15:43 +0200)]
Rollup merge of #96635 - GuillaumeGomez:js-script-mode, r=notriddle

Use "strict" mode in JS scripts

Part of #93058.

r? `@notriddle`

2 years agoRollup merge of #96507 - TaKO8Ki:suggest-calling-associated-function, r=lcnr
Matthias Krüger [Thu, 5 May 2022 13:43:03 +0000 (15:43 +0200)]
Rollup merge of #96507 - TaKO8Ki:suggest-calling-associated-function, r=lcnr

Suggest calling `Self::associated_function()`

closes #96453

2 years agoRollup merge of #95843 - GuillaumeGomez:improve-new-cyclic-doc, r=m-ou-se
Matthias Krüger [Thu, 5 May 2022 13:43:02 +0000 (15:43 +0200)]
Rollup merge of #95843 - GuillaumeGomez:improve-new-cyclic-doc, r=m-ou-se

Improve Rc::new_cyclic and Arc::new_cyclic documentation

Fixes https://github.com/rust-lang/rust/issues/95672.

cc `@CAD97` (since I used your explanations)

2 years agoRollup merge of #95359 - jhpratt:int_roundings, r=joshtriplett
Matthias Krüger [Thu, 5 May 2022 13:43:00 +0000 (15:43 +0200)]
Rollup merge of #95359 - jhpratt:int_roundings, r=joshtriplett

Update `int_roundings` methods from feedback

This updates `#![feature(int_roundings)]` (#88581) from feedback. All methods now take `NonZeroX`. The documentation makes clear that they panic in debug mode and wrap in release mode.

r? `@joshtriplett`

`@rustbot` label +T-libs +T-libs-api +S-waiting-on-review

2 years agoBless clippy error msg
Gary Guo [Thu, 5 May 2022 13:27:11 +0000 (14:27 +0100)]
Bless clippy error msg

2 years agoAuto merge of #8788 - flip1995:rustup, r=xFrednet,flip1995
bors [Thu, 5 May 2022 13:12:09 +0000 (13:12 +0000)]
Auto merge of #8788 - flip1995:rustup, r=xFrednet,flip1995

Rustup

r? `@ghost`

changelog: move trait_duplication_in_bounds and type_repetition_in_bounds to nursery temporarily. This could already be reverted before the release. Check the Clippy in the Rust repo beta branch when writing this changelog.

2 years agoFix ICE in EarlyAttribtues lints
flip1995 [Thu, 5 May 2022 13:10:06 +0000 (14:10 +0100)]
Fix ICE in EarlyAttribtues lints

2 years agoHACK: Move buggy lints to nursery
flip1995 [Thu, 5 May 2022 12:32:31 +0000 (13:32 +0100)]
HACK: Move buggy lints to nursery

Those lints are trait_duplication_in_bounds and
type_repetition_in_bounds. I don't think those can be fixed on the
Clippy side alone, but need changes in the compiler. So let's move them
to nursery to get the sync through and then fix them on the rustc side.

Also adds a regression test that has to be fixed before they can be
moved back to pedantic.

2 years agoBump nightly version -> 2022-05-05
flip1995 [Thu, 5 May 2022 12:32:18 +0000 (13:32 +0100)]
Bump nightly version -> 2022-05-05

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 5 May 2022 12:01:37 +0000 (13:01 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoupdate error messages and explicitly mention them in tests
lcnr [Thu, 5 May 2022 12:29:24 +0000 (14:29 +0200)]
update error messages and explicitly mention them in tests

2 years agoAuto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoerister
bors [Thu, 5 May 2022 12:26:38 +0000 (12:26 +0000)]
Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoerister

Add a new Rust attribute to support embedding debugger visualizers

Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB.

Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies.

RFC: https://github.com/rust-lang/rfcs/pull/3191

2 years agoAdd a regression test for #64173 and #66152
Yuki Okushi [Thu, 5 May 2022 11:03:34 +0000 (20:03 +0900)]
Add a regression test for #64173 and #66152

2 years agoAuto merge of #96649 - tbu-:pr_to_ipv4_loopback_doc, r=m-ou-se
bors [Thu, 5 May 2022 09:45:53 +0000 (09:45 +0000)]
Auto merge of #96649 - tbu-:pr_to_ipv4_loopback_doc, r=m-ou-se

Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback

2 years agoAdd rotation animation on settings button when loading
Guillaume Gomez [Wed, 4 May 2022 13:39:18 +0000 (15:39 +0200)]
Add rotation animation on settings button when loading

2 years agoUse "strict" mode in JS scripts
Guillaume Gomez [Mon, 2 May 2022 12:32:56 +0000 (14:32 +0200)]
Use "strict" mode in JS scripts

2 years agoforbid empty impls for types with incoherent impls
lcnr [Thu, 5 May 2022 07:37:50 +0000 (09:37 +0200)]
forbid empty impls for types with incoherent impls

2 years agoremove unnecessary check
lcnr [Fri, 29 Apr 2022 13:55:54 +0000 (15:55 +0200)]
remove unnecessary check

2 years agogeneralize "incoherent impls" impl for custom types
lcnr [Thu, 28 Apr 2022 14:26:30 +0000 (16:26 +0200)]
generalize "incoherent impls" impl for custom types

2 years agogive it a scary name
Ralf Jung [Thu, 5 May 2022 07:55:38 +0000 (09:55 +0200)]
give it a scary name

2 years agosuggest calling `Self::associated_function()`
Takayuki Maeda [Thu, 28 Apr 2022 07:54:28 +0000 (16:54 +0900)]
suggest calling `Self::associated_function()`

do not suggest when trait_ref is some

Update compiler/rustc_resolve/src/late/diagnostics.rs

Co-authored-by: lcnr <rust@lcnr.de>
use helper struct

add a test for functions with some params

refactor debug log

2 years agoAuto merge of #96630 - m-ysk:fix/issue-88038, r=notriddle
bors [Thu, 5 May 2022 07:25:18 +0000 (07:25 +0000)]
Auto merge of #96630 - m-ysk:fix/issue-88038, r=notriddle

Include nonexported macro_rules! macros in the doctest target

Fixes #88038

This PR aims to include nonexported `macro_rules!` macros in the doctest target. For more details, please see the above issue.

2 years agoAuto merge of #96626 - thomcc:rand-bump, r=m-ou-se
bors [Thu, 5 May 2022 05:08:44 +0000 (05:08 +0000)]
Auto merge of #96626 - thomcc:rand-bump, r=m-ou-se

Avoid using `rand::thread_rng` in the stdlib benchmarks.

This is kind of an anti-pattern because it introduces extra nondeterminism for no real reason. In thread_rng's case this comes both from the random seed and also from the reseeding operations it does, which occasionally does syscalls (which adds additional nondeterminism). The impact of this would be pretty small in most cases, but it's a good practice to avoid (particularly because avoiding it was not hard).

Anyway, several of our benchmarks already did the right thing here anyway, so the change was pretty easy and mostly just applying it more universally. That said, the stdlib benchmarks aren't particularly stable (nor is our benchmark framework particularly great), so arguably this doesn't matter that much in practice.

~~Anyway, this also bumps the `rand` dev-dependency to 0.8, since it had fallen somewhat out of date.~~ Nevermind, too much of a headache.

2 years agoUpdate `int_roundings` methods from feedback
Jacob Pratt [Sun, 27 Mar 2022 07:15:21 +0000 (03:15 -0400)]
Update `int_roundings` methods from feedback

2 years agoAuto merge of #96720 - JohnTitor:rollup-9jaaekr, r=JohnTitor
bors [Thu, 5 May 2022 02:49:16 +0000 (02:49 +0000)]
Auto merge of #96720 - JohnTitor:rollup-9jaaekr, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #96603 (Enable full revision in const generics ui tests)
 - #96616 (Relax memory ordering used in `min_stack`)
 - #96619 (Relax memory ordering used in SameMutexCheck)
 - #96628 (Stabilize `bool::then_some`)
 - #96658 (Move callback to the () => {} syntax.)
 - #96677 (Add more tests for label-break-value)
 - #96697 (Enable tracing for all queries)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #96697 - oli-obk:trace_queries, r=michaelwoerister
Yuki Okushi [Thu, 5 May 2022 01:20:38 +0000 (10:20 +0900)]
Rollup merge of #96697 - oli-obk:trace_queries, r=michaelwoerister

Enable tracing for all queries

This allows you to log everything within a specific query, e.g.

```
env RUSTC_LOG=[mir_borrowck]
```

dumping all borrowck queries may be a bit verbose, so you can also restrict it to just an item of your choice:

```
env RUSTC_LOG=[mir_borrowck{key=\.\*name_of_item\.\*}]
```

the regex `.*` in the key name are because the key is a debug printed DefId, so you'd get all kinds of things like hashes in there. The tracing logs will show you the key, so you can restrict it further if you want.

2 years agoRollup merge of #96677 - jyn514:label-break-value-tests, r=petrochenkov
Yuki Okushi [Thu, 5 May 2022 01:20:37 +0000 (10:20 +0900)]
Rollup merge of #96677 - jyn514:label-break-value-tests, r=petrochenkov

Add more tests for label-break-value

Helps with https://github.com/rust-lang/rust/issues/48594. The tests are adapted from https://github.com/rust-lang/rust/issues/48594#issuecomment-421625182.

2 years agoRollup merge of #96658 - Folyd:es6, r=GuillaumeGomez
Yuki Okushi [Thu, 5 May 2022 01:20:36 +0000 (10:20 +0900)]
Rollup merge of #96658 - Folyd:es6, r=GuillaumeGomez

Move callback to the () => {} syntax.

Part of https://github.com/rust-lang/rust/issues/93058.

r? `@GuillaumeGomez`

2 years agoRollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se
Yuki Okushi [Thu, 5 May 2022 01:20:35 +0000 (10:20 +0900)]
Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se

Stabilize `bool::then_some`

FCP completed in https://github.com/rust-lang/rust/issues/80967

2 years agoRollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, r=m-ou-se
Yuki Okushi [Thu, 5 May 2022 01:20:34 +0000 (10:20 +0900)]
Rollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, r=m-ou-se

Relax memory ordering used in SameMutexCheck

`SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.

2 years agoRollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplett
Yuki Okushi [Thu, 5 May 2022 01:20:33 +0000 (10:20 +0900)]
Rollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplett

Relax memory ordering used in `min_stack`

`min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.

2 years agoRollup merge of #96603 - Alexendoo:const-generics-tests, r=Mark-Simulacrum
Yuki Okushi [Thu, 5 May 2022 01:20:32 +0000 (10:20 +0900)]
Rollup merge of #96603 - Alexendoo:const-generics-tests, r=Mark-Simulacrum

Enable full revision in const generics ui tests

The ICEs no longer occur since https://github.com/rust-lang/rust/pull/95776 so the revisions can be reenabled

Also adds some regression tests for issues that no longer ICE because of it

closes #77357
closes #78180
closes #83993

2 years agoAuto merge of #96593 - jackh726:issue-93262, r=compiler-errors
bors [Thu, 5 May 2022 00:24:48 +0000 (00:24 +0000)]
Auto merge of #96593 - jackh726:issue-93262, r=compiler-errors

Revert "Prefer projection candidates instead of param_env candidates for Sized predicates"

Fixes #93262
Reopens #89352

This was a hack that seemed to have no negative side-effects at the time. Given that the latter has a workaround and likely less common than the former, it makes sense to revert this change.

r? `@compiler-errors`

2 years agoCleanup broken doc links.
ridwanabdillahi [Thu, 5 May 2022 00:17:57 +0000 (17:17 -0700)]
Cleanup broken doc links.

2 years agoMake it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback
Tobias Bucher [Mon, 2 May 2022 21:20:51 +0000 (23:20 +0200)]
Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback

2 years agoAuto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
bors [Wed, 4 May 2022 21:16:28 +0000 (21:16 +0000)]
Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov

Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`

2 years agoAuto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
bors [Wed, 4 May 2022 21:16:28 +0000 (21:16 +0000)]
Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov

Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`

2 years agoAdd a comment on `TokenKind::Interpolated`.
Nicholas Nethercote [Wed, 4 May 2022 06:12:09 +0000 (16:12 +1000)]
Add a comment on `TokenKind::Interpolated`.

2 years agoOverhaul `MacArgs::Eq`.
Nicholas Nethercote [Thu, 28 Apr 2022 20:52:01 +0000 (06:52 +1000)]
Overhaul `MacArgs::Eq`.

The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.

2 years agoOverhaul `MacArgs::Eq`.
Nicholas Nethercote [Thu, 28 Apr 2022 20:52:01 +0000 (06:52 +1000)]
Overhaul `MacArgs::Eq`.

The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.