Commit Graph

171591 Commits

Author SHA1 Message Date
Nicholas Nethercote
85e8d94e05 Change Ty::Tuple to Ty::Unit.
Because that's all that is needed in practice.
2022-07-01 15:19:49 +10:00
Nicholas Nethercote
00307a5b6f Rename Ty::Literal as Ty::Path.
Because a `Literal` is a type of expression, and is simply the wrong
name for this.
2022-07-01 15:19:46 +10:00
Nicholas Nethercote
18fef6bbd7 Remove lifetime support in deriving code.
It's unused.
2022-07-01 15:16:17 +10:00
Nicholas Nethercote
b94246693a Simplify pointer handling.
The existing derive code allows for various possibilities that aren't
needed in practice, which complicates the code. There are only a few
auto-derived traits and new ones are unlikely, so this commit simplifies
things.

- `PtrTy` has been eliminated. The `Raw` variant was never used, and the
  lifetime for the `Borrowed` variant was always `None`. That left just
  the mutability field, which has been inlined as necessary.
- `MethodDef::explicit_self` was a confusing `Option<Option<PtrTy>>`.
  Indicating either `&self` or nothing. It's now a `bool`.
- `borrowed_self` is renamed as `self_ref`.
- `Ty::Ptr` is renamed to `Ty::Ref`.
2022-07-01 15:16:17 +10:00
Nicholas Nethercote
78ec19ffe6 expand_deriving_clone tweaks.
Improve a comment, and panic on an impossible code path.
2022-07-01 15:16:15 +10:00
Matthias Krüger
18d4228456
Rollup merge of #98749 - CAD97:patch-3, r=jyn514
Add macro_rules! rustdoc change to 1.62 relnotes

#96630 was tagged <kbd>relnotes</kbd> but didn't make it into the notes. Given this is a compatibility issue (https://github.com/rust-lang/rust/issues/97030, https://github.com/rust-lang/rust/issues/98735, https://github.com/rust-lang/rust/issues/98743), it probably *should* be retroactively added.
2022-07-01 06:06:00 +02:00
Matthias Krüger
335e7d3e33
Rollup merge of #98745 - thomcc:build-dir-arg, r=jyn514
Add a `--build-dir` flag to rustbuild

This adds an optional `--build-dir <path>` flag to rustbuild (to both the python and rust code in src/bootstrap). If provided, it overrides build directory from the config file (if any was provided).

My reason for wanting this is that I often will make a change, save, and then go run `x.py check` or `x.py test` (or something). Because I've saved, vscode will start doing its thing in the background, but this will take the file lock, preventing `x.py` from running until vscode finishes whatever it's doing (since the manually invoked x.py won't be able to acquire said file lock). This is annoying, because I'd rather the command I explicitly invoke *not* wait for r-a to complete, as r-a's check is conceptually a background task (and one which can take quite some time to complete).

Anyway, while there are likely other ways this could be handled, if you have the disk space an easy way is to just have vscode be configured to use a different build directory, and then they never have to block each-other.

This can currently be arranged without this patch, by maintaining two `config.toml`s, one of which has a different build dir, and just exists to be passed into the overridden check command in vscode.

Unfortunately, this has the downside of requiring I maintain two `config.toml`s and keep them (at least somewhat) in sync, aside from the build dir. I dislike for several reasons, not the least of which because I know myself well enough to know that these will inevitably get out of sync and confuse me in the future (perhaps this case would be different since I've thought about it enough to write this patch? Who knows, I'd rather not find out).

Either way, it would be much easier for me to have a way for *only* the build directory to differ, which this patch provides by way of a new flag.  I suggested this to `@jyn514` who indicated it sounded reasonable so long as it didn't add too much complexity, which I think I've achieved, but he can be the judge.

Anyway, with this patch I can just use something like `["python3", "x.py", "check", "--build-dir", "build-vscode", "--json-output"]` as the overridden check command to rust-analyzer, and do not need to futz with any additional `config.toml`s. Which is very nice!

I've tested this manually, and can confirm that it works. I'm not sure if it needs automated tests, or where I should add them if so.

r? `@jyn514` (who has had to put up with my complaints about this... many times. <3)
2022-07-01 06:05:59 +02:00
Matthias Krüger
c4acd06a57
Rollup merge of #98734 - tmiasko:uninhabited-calls-release-notes, r=Mark-Simulacrum
Update RELEASES.md

Clarify that flow sensitive checks now understand that *visibly*
uninhabited call expressions never return.

The change influences checks of reachable and unreachable code alike,
not just dead code like previous wording would imply.

cc ``@Kixunil``
2022-07-01 06:05:58 +02:00
Matthias Krüger
80dd48b73f
Rollup merge of #98733 - celinval:patch-1, r=Mark-Simulacrum
Request to be notified of MIR changes

Adding myself (celinval) to be notified of PRs that changes the MIR.
2022-07-01 06:05:57 +02:00
Matthias Krüger
734f21c9e2
Rollup merge of #98729 - the8472:exactsize-docs, r=thomcc
clarify that ExactSizeIterator::len returns the remaining length

fixes #98721
2022-07-01 06:05:56 +02:00
Matthias Krüger
e59693a046
Rollup merge of #98727 - notriddle:notriddle/issue-98697, r=GuillaumeGomez
rustdoc: filter '_ lifetimes from ty::PolyTraitRef

Fixes #98697
2022-07-01 06:05:55 +02:00
Matthias Krüger
0420231989
Rollup merge of #98686 - matthiaskrgr:test-46511, r=compiler-errors
add ice test for 46511

Fixes #46511

r? ``@compiler-errors``
2022-07-01 06:05:54 +02:00
Matthias Krüger
41e79910aa
Rollup merge of #98640 - cuviper:stable-rust-analyzer, r=Mark-Simulacrum
Let rust-analyzer ship on stable, non-preview

The consensus on rust-lang/rust-analyzer#12432 seems to be that we are ready for `rust-analyzer` to ship as a rustup component on the beta and stable channels. This won't always be the preferred distribution method, e.g. the VS Code extension will probably still independently update to its weekly releases, but it's still useful to have a component that follows the release train with the rest of the Rust toolchain. So this removes the nightly-only gating on the bundled component, and removes the "-preview" suffix as well by the usual renaming mechanism.

cc ``@rust-lang/wg-rls-2`` ``@rust-lang/release``
2022-07-01 06:05:53 +02:00
Matthias Krüger
0d5636ce88
Rollup merge of #98610 - lcnr:emit_inference_failure_err-ice, r=estebank
fix `emit_inference_failure_err` ICE

fixes #98598

this fix doesn't make me too happy, but 🤷
2022-07-01 06:05:52 +02:00
Joshua Nelson
cec6933d0d Fix x dist rust-dev on a fresh checkout
Previously, it required you to manually run `x build` first, because it
assumed the LLVM binaries were already present.
2022-06-30 23:05:45 -05:00
Christopher Durham
4ea18ccf7e Add macro_rules! rustdoc change to 1.62 relnotes 2022-06-30 23:48:11 -04:00
bors
acdcdfb61b Auto merge of #98706 - flip1995:clippyup, r=Dylan-DPC
Update Clippy

r? `@Manishearth`
2022-07-01 01:30:37 +00:00
Thom Chiovoloni
79f8dc0b89
Add a --build-dir flag to rustbuild 2022-06-30 15:50:48 -07:00
Nicholas Nethercote
679c5ee244 Optimize Vec::insert for the case where index == len.
By skipping the call to `copy` with a zero length. This makes it closer
to `push`.

I did this recently for `SmallVec`
(https://github.com/servo/rust-smallvec/pull/282) and it was a big perf win in
one case. Although I don't have a specific use case in mind, it seems
worth doing it for `Vec` as well.

Things to note:
- In the `index < len` case, the number of conditions checked is
  unchanged.
- In the `index == len` case, the number of conditions checked increases
  by one, but the more expensive zero-length copy is avoided.
- In the `index > len` case the code now reserves space for the extra
  element before panicking. This seems like an unimportant change.
2022-07-01 06:46:30 +10:00
Nicholas Nethercote
623ebbe42a Remove some commented-out code.
This was accidentally left behind in a previous commit.
2022-07-01 06:35:14 +10:00
Nicholas Nethercote
57d56891d2 Remove some unnecessary pubs. 2022-07-01 06:35:14 +10:00
Nicholas Nethercote
89f6917a49 Remove Substructure::self_args.
It's unused.
2022-07-01 06:35:14 +10:00
Nicholas Nethercote
1254fe974d Remove {Method,Trait}Def::is_unsafe.
They are always `false`.
2022-07-01 06:35:01 +10:00
Andy Russell
625122af9f
fix grammar in useless doc comment lint 2022-06-30 16:17:38 -04:00
Nicholas Nethercote
d13fa0d21b Remove Substructure::method_ident.
It's unused.
2022-07-01 06:04:36 +10:00
Nicholas Nethercote
7a4fdcbbc5 Remove unnecessary fields from EnumNonMatchingCollapsed.
The `&[ast::Variant]` field isn't used.

The `Vec<Ident>` field is only used for its length, but that's always
the same as the length of the `&[Ident]` and so isn't necessary.
2022-07-01 06:04:36 +10:00
Nicholas Nethercote
72a1621061 Use split_{first,last} in cs_fold1.
It makes the code a little nicer to read.
2022-07-01 06:04:36 +10:00
Camille GILLOT
6a9946143d Specialize a few tests depending on opt-level. 2022-06-30 21:45:29 +02:00
Camille GILLOT
6bb549f0d1 Allow inlining #[inline] functions. 2022-06-30 21:45:29 +02:00
Wesley Wiser
d1d9092e3c Test enabling MIR inliner 2022-06-30 21:45:29 +02:00
Camille GILLOT
b33c6e1bd8 Do not error on the param_env during inlining.
This created unexpected diagnostics while compiling alga:
    cannot satisfy `<Self as Module>::Ring == _`

Turns out that we don't need this diagnostic as we disable inlining when
it would trigger an ICE.
2022-06-30 21:45:29 +02:00
Camille GILLOT
ce4b5c8afc Skip inlining if there are normalization issues. 2022-06-30 21:45:29 +02:00
Camille GILLOT
0161ecd13f Recover when failing to normalize closure signature. 2022-06-30 21:45:29 +02:00
Camille GILLOT
2e45cd4b69 Do not ICE when failing to resolve. 2022-06-30 21:45:29 +02:00
Camille GILLOT
114c9284b9 Check history earlier. 2022-06-30 21:45:29 +02:00
Wesley Wiser
5999f34ff6 Don't assert polymorphization has taken effect in const eval
Const eval no longer runs MIR optimizations so unless this is getting
run as part of a MIR optimization like const-prop, there can be unused
type parameters even if polymorphization is enabled.
2022-06-30 21:45:29 +02:00
pinkforest
6565509c19 rustdoc: fix 98690 2022-07-01 05:16:37 +10:00
Vincenzo Palazzo
835b7a523a ui: improve suggestion test by addig the help message
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-06-30 18:59:36 +00:00
Celina G. Val
d791310b92
Request to be notified of MIR changes
Adding myself (celinval) to be notified of PRs that changes the MIR.
2022-06-30 11:18:56 -07:00
InfRandomness
81b525e2a4 Revert #95993 fix
This reverts the temporary fix implemented by https://github.com/rust-lang/rust/pull/95993 since a permanent fix has been implemented by https://github.com/rust-lang/cargo/pull/10594
2022-06-30 20:16:04 +02:00
Matthias Krüger
6e918b4a97
Rollup merge of #98717 - RalfJung:make-tidy-less-annoying, r=jyn514
get rid of tidy 'unnecessarily ignored' warnings

I think these warnings are quite pointless: when I say `allow(foo)` in my code, that doesn't necessarily mean that I expect `foo` to happen -- it just means that I am okay with `foo` happening.

For example, having to add and remove `ignore-tidy-linelength` as the longest line in the file keeps growing and shrinking is just annoying and doesn't benefit anyone, IMO. This usually incurs *two* CI roundtrips: first CI tells you that line lengths in your test file are ignored unnecessarily, so you go and remove that attribute; then CI tells you that now your line numbers changed, so you re-bless your tests (often takes >5min if parts of rustc need rebuilding because `./x.py fmt` changed something somewhere). That's just a lot of wasted effort and time and patience.
2022-06-30 19:55:57 +02:00
Matthias Krüger
f916c7fbb9
Rollup merge of #98709 - GuillaumeGomez:rm-decl-for-old-browsers, r=Dylan-DPC
Remove unneeded methods declaration for old web browsers

All these methods were not defined for IE mostly. But since we don't support it anymore, no need to keep them around.

cc ```@jsha```
r? ```@notriddle```
2022-06-30 19:55:56 +02:00
Matthias Krüger
8385d6bee4
Rollup merge of #98695 - tshepang:or-pattern, r=compiler-errors
use "or pattern"
2022-06-30 19:55:55 +02:00
Matthias Krüger
9bcf992499
Rollup merge of #98688 - RalfJung:from-mplace, r=oli-obk
interpret: add From<&MplaceTy> for PlaceTy

We have a similar instance for `&MPlaceTy` to `OpTy`. Also add the same for `&mut`.

This avoids having to write `&(*place).into()`, which we have a few times here and at least twice in Miri (and it comes up again in my current patch).

r? ```@oli-obk```
2022-06-30 19:55:54 +02:00
Matthias Krüger
783989098b
Rollup merge of #98684 - matthiaskrgr:ice-test-72793, r=oli-obk
add test for 72793

Fixes #72793

r? ````@oli-obk````
2022-06-30 19:55:54 +02:00
Matthias Krüger
6ee667374e
Rollup merge of #98677 - lyming2007:issue-98492-fix, r=lcnr
For diagnostic information of Boolean, remind it as use the type: 'bool'

Fixes #98492.

It helps programmers coming from other languages
	modified:   compiler/rustc_resolve/src/late/diagnostics.rs
2022-06-30 19:55:53 +02:00
Matthias Krüger
b1403d6b78
Rollup merge of #98671 - GuillaumeGomez:source-sidebar-fixes, r=notriddle
Fix source sidebar bugs

This PR fixes the following two bugs:

![Screenshot from 2022-06-29 14-39-58](https://user-images.githubusercontent.com/3050060/176449070-3e3762da-2bfe-4acf-8eb0-34f6eb4c94ed.png)
![Screenshot from 2022-06-29 15-05-09](https://user-images.githubusercontent.com/3050060/176449073-b164820b-bd71-4b1a-990c-bba4e5fce196.png)

I added regression tests to prevent them to happen again.

I think we should backport it to beta as well.

You can test it [here](https://rustdoc.crud.net/imperio/source-sidebar-fixes/src/std/lib.rs.html).

cc ```@jsha```
r? ```@notriddle```
2022-06-30 19:55:52 +02:00
Matthias Krüger
5cd41d7be8
Rollup merge of #98670 - krasimirgg:llvm-15-LLVMConstExtractValue, r=nikic
llvm-wrapper: adapt for LLVMConstExtractValue removal

`LLVMConstExtractValue` was removed recently from LLVM: 5548e807b5.

This adapts llvm-wrapper to use the new alternative where available, following https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/LLVMConstExtractValue.20removal.
2022-06-30 19:55:52 +02:00
Matthias Krüger
ebecc13106
Rollup merge of #98503 - RalfJung:scope-race, r=m-ou-se
fix data race in thread::scope

Puts the `ScopeData` into an `Arc` so it sticks around as long as we need it.
This means one extra `Arc::clone` per spawned scoped thread, which I hope is fine.

Fixes https://github.com/rust-lang/rust/issues/98498
r? `````@m-ou-se`````
2022-06-30 19:55:51 +02:00
Matthias Krüger
0e71d1f237
Rollup merge of #97629 - guswynn:exclusive_struct, r=m-ou-se
[core] add `Exclusive` to sync

(discussed here: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Adding.20.60SyncWrapper.60.20to.20std)

`Exclusive` is a wrapper that exclusively allows mutable access to the inner value if you have exclusive access to the wrapper. It acts like a compile time mutex, and hold an unconditional `Sync` implementation.

## Justification for inclusion into std
- This wrapper unblocks actual problems:
  - The example that I hit was a vector of `futures::future::BoxFuture`'s causing a central struct in a script to be non-`Sync`. To work around it, you either write really difficult code, or wrap the futures in a needless mutex.
- Easy to maintain: this struct is as simple as a wrapper can get, and its `Sync` implementation has very clear reasoning
- Fills a gap: `&/&mut` are to `RwLock` as `Exclusive` is to `Mutex`

## Public Api
```rust
// core::sync
#[derive(Default)]
struct Exclusive<T: ?Sized> { ... }

impl<T: ?Sized> Sync for Exclusive {}

impl<T> Exclusive<T> {
    pub const fn new(t: T) -> Self;
    pub const fn into_inner(self) -> T;
}

impl<T: ?Sized> Exclusive<T> {
    pub const fn get_mut(&mut self) -> &mut T;
    pub const fn get_pin_mut(Pin<&mut self>) -> Pin<&mut T>;
    pub const fn from_mut(&mut T) -> &mut Exclusive<T>;
    pub const fn from_pin_mut(Pin<&mut T>) -> Pin<&mut Exclusive<T>>;
}

impl<T: Future> Future for Exclusive { ... }

impl<T> From<T> for Exclusive<T> { ... }
impl<T: ?Sized> Debug for Exclusive { ... }
```

## Naming
This is a big bikeshed, but I felt that `Exclusive` captured its general purpose quite well.

## Stability and location
As this is so simple, it can be in `core`. I feel that it can be stabilized quite soon after it is merged, if the libs teams feels its reasonable to add. Also, I don't really know how unstable feature work in std/core's codebases, so I might need help fixing them

## Tips for review
The docs probably are the thing that needs to be reviewed! I tried my best, but I'm sure people have more experience than me writing docs for `Core`

### Implementation:
The API is mostly pulled from https://docs.rs/sync_wrapper/latest/sync_wrapper/struct.SyncWrapper.html (which is apache 2.0 licenesed), and the implementation is trivial:
- its an unsafe justification for pinning
- its an unsafe justification for the `Sync` impl (mostly reasoned about by ````@danielhenrymantilla```` here: https://github.com/Actyx/sync_wrapper/pull/2)
- and forwarding impls, starting with derivable ones and `Future`
2022-06-30 19:55:50 +02:00