Commit graph

137723 commits

Author SHA1 Message Date
Mara Bos
676ff77fb7
Rollup merge of #80726 - lcnr:unsize-query, r=oli-obk
relax adt unsizing requirements

Changes unsizing of structs in case the last struct field shares generic params with other adt fields which do not change.
This change is currently insta stable and changes the language, so it at least requires a lang fcp. I feel like the current state is fairly unintuitive.

An example for what's now allowed would be https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6dd331d23f5c9ffc8c978175aae2e967
```rust
struct A<T, U: ?Sized>(T, B<T, U>); // previously ERR
// struct A<T, U: ?Sized>(T, B<[u32; 1], U>); // ok
struct B<T, U: ?Sized>(T, U);

fn main() {
    let x = A([0; 1], B([0; 1], [0; 1]));
    let y: &A<[u32; 1], [u32]> = &x;
    assert_eq!(y.1.1.len(), 1);
}
```
2021-02-05 12:25:52 +01:00
Mara Bos
deec6a96d4
Rollup merge of #79554 - b-naber:generic-associated-types-in-trait-paths, r=jackh726
Generic associated types in trait paths

This is the second part of https://github.com/rust-lang/rust/pull/78978

This should fix:

Fixes #67510
Fixes #68648
Fixes #68649
Fixes #68650
Fixes #68652
Fixes #74684
Fixes #76535
Fixes #79422
Fixes #80433

and implement the remaining functionality needed for https://github.com/rust-lang/rust/issues/44265

r? ``@matthewjasper``
2021-02-05 12:25:50 +01:00
bors
9e5d58fb42 Auto merge of #81688 - pnkfelix:fix-llvm-version-check-in-run-make-tests, r=simulacrum
Use `# min-llvm-version: 11.0` to force a minimum LLVM version

Use `# min-llvm-version: 11.0` to force a minimum LLVM version, rather than ad-hoc internal solution.

In particular: the specific code to define LLVM_VERSION_11_PLUS here was, for some reason, using `$(shell ...)` with bash-specific variable replacement code. On non-bash platforms like dash, that `shell` invocation would fail, and the
LLVM_VERSION_11_PLUS check would always fail, the test would always be ignored, and thus be treated as a "success" (in the sense that `--bless` would never do anything).

 * Note in particular that GNU Make treats the SHELL variable as a very special case: it does not inherit the value of SHELL from the user's environment. Except on Windows. See more explanation in the [GNU Make docs](https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html).
 * The effect of this is that these tests end up using `/bin/sh` (except on Windows) for their `$(shell ...)` invocations, and thus we see differing behaviors depending on whether your `/bin/sh` links to `/bin/dash` or to `/bin/bash`.

This was causing me a lot of pain.
2021-02-05 06:12:26 +00:00
bors
6a388dcfbb Auto merge of #81756 - ehuss:update-cargo, r=ehuss
Update cargo

5 commits in e099df243bb2495b9b197f79c19f124032b1e778..34170fcd6e0947808a1ac63ac85ffc0da7dace2f
2021-02-01 16:24:34 +0000 to 2021-02-04 15:52:52 +0000
- Fix permission issue with `cargo vendor`. (rust-lang/cargo#9131)
- Add split-debuginfo profile option (rust-lang/cargo#9112)
- Add RegistryBuilder for tests, and update crates-io error handling. (rust-lang/cargo#9126)
- Add some documentation for index and registry stuff. (rust-lang/cargo#9125)
- Fix env/cfg set for `cargo test` and `cargo run`. (rust-lang/cargo#9122)
2021-02-05 02:13:59 +00:00
bors
dab3a80f23 Auto merge of #81761 - m-ou-se:rollup-xp7v07n, r=m-ou-se
Rollup of 9 pull requests

Successful merges:

 - #74304 (Stabilize the Wake trait)
 - #79805 (Rename Iterator::fold_first to reduce and stabilize it)
 - #81556 (introduce future-compatibility warning for forbidden lint groups)
 - #81645 (Add lint for `panic!(123)` which is not accepted in Rust 2021.)
 - #81710 (OsStr eq_ignore_ascii_case takes arg by value)
 - #81711 (add #[inline] to all the public IpAddr functions)
 - #81725 (Move test to be with the others)
 - #81727 (Revert stabilizing integer::BITS.)
 - #81745 (Stabilize poison API of Once, rename poisoned())

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-04 23:16:08 +00:00
b-naber
12d411febb add tests 2021-02-04 22:56:25 +01:00
b-naber
9e920151a3 remove subst_supertrait call 2021-02-04 21:37:23 +01:00
b-naber
6a68966663 use generic arguments of associated item in trait_ref method 2021-02-04 21:37:14 +01:00
bors
4f4656d46d Auto merge of #81762 - pietroalbini:fix-install-msys2, r=m-ou-se
CI: only copy python.exe to python3.exe if the latter does not exist

We're copying the binary to make sure we can call `python3.exe` around, but it seems like the base image of GitHub Actions changed, copying the file before we do so. This PR changes the CI script to only copy the file if it doesn't already exist.

r? `@m-ou-se`
cc `@Mark-Simulacrum`
2021-02-04 20:30:11 +00:00
Pietro Albini
575f6940b7
ci: only copy python.exe to python3.exe if the latter does not exist
We're copying the binary to make sure we can call python3.exe around,
but it seems like the base image of GitHub Actions changed, copying the
file before we do so.

This commit changes the CI script to only copy the file if it doesn't
already exist.
2021-02-04 21:24:41 +01:00
Mara Bos
6f014cd4db
Rollup merge of #81745 - Kixunil:stabilize_once_poison, r=m-ou-se
Stabilize poison API of Once, rename poisoned()

This stabilizes:

* `OnceState`
* `OnceState::is_poisoned()` (previously named `poisoned()`)
* `Once::call_once_force()`

`poisoned()` was renamed because the new name is more clear as a few
people agreed and nobody objected.

Closes #33577

Notes:

* I'm not entirely sure it's supposed to be 1.51, LMK if I did it wrong
* I failed to run tests locally, so we will have to leave it to bors or someone else can try
2021-02-04 21:10:44 +01:00
Mara Bos
113e27fcfc
Rollup merge of #81727 - m-ou-se:unstabilize-bits, r=Mark-Simulacrum
Revert stabilizing integer::BITS.

We agreed in the libs meeting just now to revert stablization, since the [breakage](https://github.com/rust-lang/rust/issues/81654) is significant throughout the ecosystem, through `lexical-core`.

cc https://github.com/rust-lang/rust/issues/76904

Fixes https://github.com/rust-lang/rust/issues/81654
2021-02-04 21:10:42 +01:00
Mara Bos
83e0fe3dbb
Rollup merge of #81725 - mark-i-m:mv-test, r=Mark-Simulacrum
Move test to be with the others

No functional changes. I just created this test in the wrong place in a past PR. All of the other or-pattern tests are in the `or-patterns` directory.
2021-02-04 21:10:40 +01:00
Mara Bos
e0ddc053f9
Rollup merge of #81711 - saethlin:ipaddr-inline, r=m-ou-se
add #[inline] to all the public IpAddr functions
2021-02-04 21:10:39 +01:00
Mara Bos
21e5827800
Rollup merge of #81710 - TyPR124:patch-2, r=m-ou-se
OsStr eq_ignore_ascii_case takes arg by value

Per a comment on #70516 this changes `eq_ignore_ascii_case` to take the generic parameter `S: AsRef<OsStr>` by value instead of by reference.

This is technically a breaking change to an unstable method. I think the only way it would break is if you called this method with an explicit type parameter, ie `my_os_str.eq_ignore_ascii_case::<str>("foo")` becomes `my_os_str.eq_ignore_ascii_case::<&str>("foo")`.

Besides that, I believe it is overall more flexible since it can now take an owned `OsString` for example.

If this change should be made in some other PR (like #80193) then please just close this.
2021-02-04 21:10:37 +01:00
Mara Bos
87b269ab66
Rollup merge of #81645 - m-ou-se:panic-lint, r=estebank,flip1995
Add lint for `panic!(123)` which is not accepted in Rust 2021.

This extends the `panic_fmt` lint to warn for all cases where the first argument cannot be interpreted as a format string, as will happen in Rust 2021.

It suggests to add `"{}",` to format the message as a string. In the case of `std::panic!()`, it also suggests the recently stabilized
`std::panic::panic_any()` function as an alternative.

It renames the lint to `non_fmt_panic` to match the lint naming guidelines.

![image](https://user-images.githubusercontent.com/783247/106520928-675ea680-64d5-11eb-81f7-d8fa48b93a0b.png)

This is part of #80162.

r? ```@estebank```
2021-02-04 21:10:36 +01:00
Mara Bos
c5990dd8ad
Rollup merge of #81556 - nikomatsakis:forbidden-lint-groups-lint, r=pnkfelix
introduce future-compatibility warning for forbidden lint groups

We used to ignore `forbid(group)` scenarios completely. This changed in #78864, but that led to a number of regressions (#80988, #81218).

This PR introduces a future compatibility warning for the case where a group is forbidden but then an individual lint within that group is allowed. We now issue a FCW when we see the "allow", but permit it to take effect.

r? ``@Mark-Simulacrum``
2021-02-04 21:10:34 +01:00
Mara Bos
5b0acfd049
Rollup merge of #79805 - m-ou-se:iterator-reduce, r=KodrAus
Rename Iterator::fold_first to reduce and stabilize it

This stabilizes `#![feature(iterator_fold_self)]`.

The name for this function (originally `fold_first`) was still an open question, but the discussion on [the tracking issue](https://github.com/rust-lang/rust/issues/68125) seems to have converged to `reduce`.
2021-02-04 21:10:33 +01:00
Mara Bos
d20d097125
Rollup merge of #74304 - yoshuawuyts:stabilize-wake, r=KodrAus
Stabilize the Wake trait

This PR proposes stabilizing the `wake_trait` feature, tracking issue https://github.com/rust-lang/rust/issues/69912.

## Motivation

The surface area this trait introduces is small, and it has been on nightly for 4 months without any reported issues. Given the surface area of this trait is small and only serves to provide a safe interface around the already stable [`std::task::RawWakerVTable`](https://doc.rust-lang.org/std/task/struct.RawWaker.html) it seems unlikely this trait will require any further changes. So I'm proposing we stabilize this.

Personally I would love to have this available on stable, since it would enable cleaning up some runtime internals by removing the tedious pointer required to construct a [`RawWakerVTable`](https://doc.rust-lang.org/std/task/struct.RawWakerVTable.html). I believe the intent was always to introduce a `Wake` counterpart to `RawWaker` in order to safely construct `Waker` instances. And the `Wake` trait feels like it does that job as intended.

## Implementation notes

This PR itself fixes a link in the docs, and introduces an example of how to use the trait: a minimal `block_on` example that runs a future to completion on the current thread. It doesn't include fancier features such as support for nesting, but is intended to serve as a teaching device for both `task::Wake` and futures alike.
2021-02-04 21:10:31 +01:00
Eric Huss
8666a6c434 Update cargo 2021-02-04 10:08:54 -08:00
bors
822ebfd2c4 Auto merge of #81743 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/81726
Cc `@rust-lang/miri` r? `@ghost`
2021-02-04 16:46:38 +00:00
b-naber
da2cf9b9d1 substitutions in trait predicates 2021-02-04 16:35:52 +01:00
b-naber
760a6654fb lowering of generic args in AssocTyConstraint 2021-02-04 16:20:58 +01:00
b-naber
16af7bf3d9 hir pretty printing 2021-02-04 16:20:57 +01:00
b-naber
fdaf603102 add generic args to hir::TypeBinding 2021-02-04 16:20:56 +01:00
Martin Habovstiak
f42e96149d Stabilize poison API of Once, rename poisoned()
This stabilizes:

* `OnceState`
* `OnceState::is_poisoned()` (previously named `poisoned()`)
* `Once::call_once_force()`

`poisoned()` was renamed because the new name is more clear as a few
people agreed and nobody objected.

Closes #33577
2021-02-04 15:20:14 +01:00
Mara Bos
24e0940169 Stabilize feature(iterator_fold_self): Iterator::reduce 2021-02-04 11:31:11 +01:00
Mara Bos
26af55f5c6 Improve documentation of Iterator::{fold, reduce}. 2021-02-04 11:30:42 +01:00
Mara Bos
5c056ed2f5 Rename Iterator::fold_first to reduce. 2021-02-04 11:30:42 +01:00
Ralf Jung
0fe1e26a4f update Miri 2021-02-04 10:35:51 +01:00
Bastian Kauschke
031cce8cfc add relaxed_struct_unsize feature gate 2021-02-04 00:00:41 +01:00
Bastian Kauschke
50e394a05e relax adt unsizing requirements 2021-02-04 00:00:28 +01:00
Mara Bos
0870c154b6 Suggest panic!("{}", ..) instead of panic!(..) clippy::expect_fun_call. 2021-02-03 23:15:51 +01:00
Mara Bos
3f3eb89547 Fix/allow non_fmt_panic in clippy tests. 2021-02-03 23:15:51 +01:00
Mara Bos
753b0b0b80 Update panic!() documentation about non-string panics. 2021-02-03 23:15:51 +01:00
Mara Bos
e9ad5be0f7 Allow/fix non_fmt_panic in tests. 2021-02-03 23:15:45 +01:00
Mara Bos
34d5ac25c5 Make panic/assert calls in rustc compatible with Rust 2021. 2021-02-03 22:42:53 +01:00
Mara Bos
a616f8267e Add lint for panic!(123) which is not accepted in Rust 2021.
This extends the `panic_fmt` lint to warn for all cases where the first
argument cannot be interpreted as a format string, as will happen in
Rust 2021.

It suggests to add `"{}", ` to format the message as a string. In the
case of `std::panic!()`, it also suggests the recently stabilized
`std::panic::panic_any()` function as an alternative.

It renames the lint to `non_fmt_panic` to match the lint naming
guidelines.
2021-02-03 22:42:53 +01:00
Mara Bos
89882388d9 Revert stabilizing integer::BITS. 2021-02-03 22:23:58 +01:00
Felix S. Klock II
5ce6710668 Ignore broken test.
(Test was silently ignored on Linux CI prior to parent commit that switched to
using `# min-llvm-version`. But the switch made the ignoring stop, exposing
other brokenness in the form of bash-dependent syntax in the `$(shell ...)`
invocations.)
2021-02-03 16:02:41 -05:00
bors
e708cbd91c Auto merge of #81717 - Aaron1011:fix/closure-diag, r=estebank
Fix panic when emitting diagnostic for closure mutable binding error

Fixes #81700

The upvar borrow kind may be `ty::BorrowKind::UniqueImmBorrow`, which is
still a mutable borrow for the purposes of this diagnostic code.
2021-02-03 20:53:08 +00:00
mark
3719247f8f move test to be with the others 2021-02-03 14:38:34 -06:00
bors
120b2a704a Auto merge of #81718 - m-ou-se:rollup-3ftbymt, r=m-ou-se
Rollup of 5 pull requests

Successful merges:

 - #80394 (make const_err a future incompat lint)
 - #81532 (Remove incorrect `delay_span_bug`)
 - #81692 (Update clippy)
 - #81715 (Reduce tab formatting assertions to debug only)
 - #81716 (Fix non-existent-field ICE for generic fields.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-03 18:01:37 +00:00
Mara Bos
46174188e8
Rollup merge of #81716 - m-ou-se:fix-ice, r=eddyb
Fix non-existent-field ICE for generic fields.

I mentioned this ICE in a chat and it took about 3 milliseconds before `@eddyb` found the problem and said this change would fix it. :)

This also changes one the field types in the related test to one that triggered the ICE.

Fixes #81627.
Fixes #81672.
Fixes #81709.

Cc https://github.com/rust-lang/rust/pull/81480 `@b-naber` `@estebank.`
2021-02-03 18:51:18 +01:00
Mara Bos
65b3c0caf0
Rollup merge of #81715 - jryans:tab-handling-ice-81614, r=estebank
Reduce tab formatting assertions to debug only

The tab replacement for diagnostics added in #79757 included a few assertions to ensure all tab characters are handled appropriately. We've started getting reports of these assertions firing (#81614). Since it's only a cosmetic issue, this downgrades the assertions to debug only, so we at least continue compiling even if the diagnostics might be a tad wonky.

Minimizes the impact of #81614
2021-02-03 18:51:17 +01:00
Mara Bos
508b4707ac
Rollup merge of #81692 - Manishearth:clippyup, r=tmandry
Update clippy

r? `@flip1995`
2021-02-03 18:51:15 +01:00
Mara Bos
66959448e6
Rollup merge of #81532 - estebank:ice-ice-baby, r=pnkfelix
Remove incorrect `delay_span_bug`

The following code is supposed to compile

```rust
use std::ops::BitOr;

pub trait IntWrapper {
    type InternalStorage;
}

impl<T> BitOr for dyn IntWrapper<InternalStorage = T>
where
    Self: Sized,
    T: BitOr + BitOr<Output = T>,
{
    type Output = Self;
    fn bitor(self, _other: Self) -> Self {
        todo!()
    }
}
```

Before this change it would ICE. In #70998 the removed logic was added
to provide better suggestions, and the `delay_span_bug` guard was added
to  protect against a potential logic error when returning traits. As it
happens, there are cases, like the one above, where traits can indeed be
returned, so valid code was being rejected.

Fix (but not close) #80207.
2021-02-03 18:51:14 +01:00
Mara Bos
00dabfbd28
Rollup merge of #80394 - RalfJung:const-err-future, r=oli-obk
make const_err a future incompat lint

This is the first step for https://github.com/rust-lang/rust/issues/71800: make const_err a future-incompat lint. I also rewrote the const_err lint description as the old one seemed wrong.

This has the unfortunate side-effect of making const-eval error even more verbose by making the const_err message longer without fixing the redundancy caused by additionally emitting an error on each use site of the constant. We cannot fix that redundancy until const_err is a *hard* error (at that point the error-on-use-site can be turned into a `delay_span_bug!` for uses of monomorphic consts, and into a nicely rendered error for [lazily / post-monomorhization evaluated] associated consts).

~~The one annoying effect of this PR is that `let _x = &(1/(1-1));` now also shows the future-incompat warning, even though of course we will *not* make this a hard error. We'll instead (hopefully) stop promoting it -- see https://github.com/rust-lang/rfcs/pull/3027. The only way I see to avoid the future-incompat warning is to use a different lint for "failure to evaluate promoted".~~

Cc `@rust-lang/wg-const-eval`
2021-02-03 18:51:12 +01:00
Mara Bos
68cc12ab71 Fix non-existent-field ICE for generic fields.
Co-authored-by: eddyb <eddyb@lyken.rs>
2021-02-03 18:36:48 +01:00
Aaron Hill
bc84e21107
Fix panic when emitting diagnostic for closure mutable binding error
Fixes #81700

The upvar borrow kind may be `ty::BorrowKind::UniqueImmBorrow`, which is
still a mutable borrow for the purposes of this diagnostic code.
2021-02-03 12:36:24 -05:00