Commit Graph

196504 Commits

Author SHA1 Message Date
Nicholas Nethercote
b4fdf648ea Inline first_token.
Because it's tiny and hot.
2022-08-01 08:11:15 +10:00
Nicholas Nethercote
bd23d68b41 Remove StringReader::end_src_index.
It not needed, always being set to the end of the text.
2022-08-01 08:11:15 +10:00
Nicholas Nethercote
55185992d6 Improve shebang handling.
Avoid doing stuff until it's necessary.
2022-08-01 08:11:15 +10:00
bors
34805f3675 Auto merge of #99052 - tmiasko:bitset-clone-from, r=Mark-Simulacrum
Fix cloning from a BitSet with a different domain size

The previous implementation incorrectly assumed that the
number of words in a bit set is equal to the domain size.

The new implementation delegates to `Vec::clone_from` which
is specialized for `Copy` elements.

Fixes #99006.
2022-07-31 21:40:21 +00:00
Matthias Krüger
20a5e9fd7c
Rollup merge of #99986 - WaffleLapkin:record_struct_wrap_suggestion, r=compiler-errors
Add wrap suggestions for record variants

This PR adds a suggestions to wrap an expression in a record struct/variant when encountering mismatched types, similarly to a suggestion to wrap expression in a tuple struct that was added before.

An example:
```rust
struct B {
    f: u8,
}

enum E {
    A(u32),
    B { f: u8 },
}

fn main() {
    let _: B = 1;
    let _: E = 1;
}
```
```text
error[E0308]: mismatched types
  --> ./t.rs:11:16
   |
11 |     let _: B = 1;
   |            -   ^ expected struct `B`, found integer
   |            |
   |            expected due to this
   |
help: try wrapping the expression in `B`
   |
11 |     let _: B = B { f: 1 };
   |                ++++++   +

error[E0308]: mismatched types
  --> ./t.rs:12:16
   |
12 |     let _: E = 1;
   |            -   ^ expected enum `E`, found integer
   |            |
   |            expected due to this
   |
help: try wrapping the expression in a variant of `E`
   |
12 |     let _: E = E::A(1);
   |                +++++ +
12 |     let _: E = E::B { f: 1 };
   |                +++++++++   +
```

r? `@compiler-errors`
2022-07-31 23:39:44 +02:00
Matthias Krüger
e4fcee579e
Rollup merge of #99984 - ChrisDenton:fix-miri, r=Mark-Simulacrum
Fix compat.rs for `cfg(miri)`

Fixes #99982
2022-07-31 23:39:44 +02:00
Matthias Krüger
0c3989e556
Rollup merge of #99980 - GuillaumeGomez:rm-clean-impls, r=Dylan-DPC
Remove more Clean trait implementations

This time as well it allowed to remove a function.

Follow-up of https://github.com/rust-lang/rust/pull/99638.

r? `@notriddle`
2022-07-31 23:39:43 +02:00
Matthias Krüger
549463f114
Rollup merge of #99973 - RalfJung:layout-things, r=eddyb
Layout things

These two commits are pretty independent, but didn't seem worth doing individual PRs for:
- Always check that size is a multiple of align, even without debug assertions
- Change Layout debug printing to put `variants` last, since it often huge and not usually the part we are most interested in

Cc `@eddyb`
2022-07-31 23:39:42 +02:00
Matthias Krüger
c98e893bad
Rollup merge of #99932 - madsmtm:fix-unwinding-debug-assertions, r=Amanieu
Fix unwinding on certain platforms when debug assertions are enabled

This came up on `armv7-apple-ios` when using `-Zbuild-std`.

Looks like this is a leftover from a [conversion from C to Rust](051c2d14fb), where integer wrapping is implicit.

Not at all sure how the unwinding code works!
2022-07-31 23:39:41 +02:00
Matthias Krüger
9cc06eb54d
Rollup merge of #99620 - hudson-ayers:fix-location-detail, r=davidtwco
`-Z location-detail`: provide option to disable all location details

As reported [here](https://github.com/rust-lang/rust/pull/89920#issuecomment-1190598924), when I first implemented the `-Z location-detail` flag there was a bug, where passing an empty list was not correctly supported, and instead rejected by the compiler. This PR fixes that such that passing an empty list results in no location details being tracked, as originally specified in https://github.com/rust-lang/rfcs/pull/2091 .

This PR also adds a test case to verify that this option continues to work as intended.
2022-07-31 23:39:40 +02:00
Matthias Krüger
e820ecdba1
Rollup merge of #99519 - Urgau:check-cfg-implicit, r=petrochenkov
Remove implicit names and values from `--cfg` in `--check-cfg`

This PR remove the implicit names and values from `--cfg` in `--check-cfg` because the behavior is quite surprising but also because it's really easy to inadvertently really on the implicitness and when the `--cfg` is not set anymore to have an unexpected warning from an unexpected condition that pass with the implicitness.

This change in behavior will also enable us to warn when an unexpected `--cfg` is passed, ex: the user wrote `--cfg=unstabl` instead of `--cfg=unstable`. The implementation of the warning will be done in a follow-up PR.

cc `@petrochenkov`
2022-07-31 23:39:38 +02:00
bors
f9cba63746 Auto merge of #99988 - rylev:allow-try-perf, r=Mark-Simulacrum
Allow try-perf branch to run in CI

We want to be able to build artifacts through the try-perf branch but without this change the CI fails early.

r? `@Mark-Simulacrum`
2022-07-31 18:59:10 +00:00
BlackHoleFox
0e54d71e15 Add validation to const fn CStr creation 2022-07-31 13:14:18 -05:00
Obei Sideg
86dd457e6a Improve cannot move out of error message 2022-07-31 21:06:43 +03:00
bors
2b472f6684 Auto merge of #12915 - lnicola:promote-subtree, r=lnicola
internal: Update `xtask promote` and release instructions

Update `xtask` for the subtree workflow. This doesn't explain how to do a `rust -> RA`  sync, since that's definitely more involved, but will probably only happen rarely.
2022-07-31 17:58:40 +00:00
bors
af646621de Auto merge of #12916 - Veykril:nits, r=Veykril
minor: Properly cfg the `max` field of Limit
2022-07-31 17:42:10 +00:00
Lukas Wirth
3b2ecf44a0 Give variables more descriptive names 2022-07-31 19:27:34 +02:00
Lukas Wirth
d31f3605ce Properly cfg the max field of Limit 2022-07-31 19:27:20 +02:00
Laurențiu Nicola
58c3a5634f Update xtask promote and release instructions 2022-07-31 20:26:35 +03:00
Ryan Levick
0942efdb66 Allow try-perf branch to run in CI 2022-07-31 18:53:34 +02:00
Chris Denton
bf0b18e910
Make sure symbol_name is const evaluated 2022-07-31 17:41:07 +01:00
bors
3405e402fa Auto merge of #78802 - faern:simplify-socketaddr, r=joshtriplett
Implement network primitives with ideal Rust layout, not C system layout

This PR is the result of this internals forum thread: https://internals.rust-lang.org/t/why-are-socketaddrv4-socketaddrv6-based-on-low-level-sockaddr-in-6/13321.

Instead of basing `std:::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}` on system (C) structs, they are encoded in a more optimal and idiomatic Rust way.

This changes the public API of std by introducing structural equality impls for all four types here, which means that `match ipv4addr { SOME_CONSTANT => ... }` will now compile, whereas previously this was an error. No other intentional changes are introduced to public API.

It's possible to observe the current layout of these types (e.g., by pointer casting); most but not all libraries which were found by Crater to do this have had updates issued and affected versions yanked. See report below.

### Benefits of this change

- It will become possible to move these fundamental network types from `std` into `core` ([RFC](https://github.com/rust-lang/rfcs/pull/2832)).
- Some methods that can't be made `const fn`s today can be made `const fn`s with this change.
- `SocketAddrV4` only occupies 6 bytes instead of 16 bytes.
- These simple primitives become easier to read and uses less `unsafe`.
- Makes these types support structural equality, which means you can now (for instance) match an `Ipv4Addr` against a constant

### ~Remaining~ Previous problems

This change obviously changes the memory layout of the types. And it turns out some libraries invalidly assumes the memory layout and does very dangerous pointer casts to convert them. These libraries will have undefined behaviour and perform invalid memory access until patched.

- [x] - `mio` - Issue: https://github.com/tokio-rs/mio/issues/1386.
  - [x] `0.7` branch https://github.com/tokio-rs/mio/pull/1388
  - [x] `0.7.6` published https://github.com/tokio-rs/mio/pull/1398
  - [x] Yank all `0.7` versions older than `0.7.6`
  - [x] Report `<0.7.6` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0081.html
- [x] - `socket2` - Issue: https://github.com/rust-lang/socket2-rs/issues/119.
  - [x] `0.3.x` branch https://github.com/rust-lang/socket2-rs/pull/120
  - [x] `0.3.16` published
  - [x] `master` branch https://github.com/rust-lang/socket2-rs/pull/122
  - [x] Yank all `0.3` versions older than `0.3.16`
  - [x] Report `<0.3.16` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0079.html
- [x] - `net2` - Issue: https://github.com/deprecrated/net2-rs/issues/105
  - [x] https://github.com/deprecrated/net2-rs/pull/106
  - [x] `0.2.36` published
  - [x] Yank all `0.2` versions older than `0.2.36`
  - [x] Report `<0.2.36` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0078.html
- [x] - `miow` - Issue: https://github.com/yoshuawuyts/miow/issues/38
  - [x] `0.3.x` - https://github.com/yoshuawuyts/miow/pull/39
  - [x] `0.3.6` published
  - [x] `0.2.x` - https://github.com/yoshuawuyts/miow/pull/40
  - [x] `0.2.2` published
  - [x] Yanked all `0.2` versions older than `0.2.2`
  - [x] Yanked all `0.3` versions older than `0.3.6`
  - [x] Report `<0.2.2` and `<0.3.6` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0080.html
- [x] - `quinn master` (aka what became 0.7) - https://github.com/quinn-rs/quinn/issues/968 https://github.com/quinn-rs/quinn/pull/987
  - [x] - `quinn 0.6` - https://github.com/quinn-rs/quinn/pull/1045
  - [x] - `quinn 0.5` - https://github.com/quinn-rs/quinn/pull/1046
  - [x] - Release `0.7.0`, `0.6.2` and `0.5.4`
- [x] - `nb-connect` - https://github.com/smol-rs/nb-connect/issues/1
  - [x] - Release `1.0.3`
  - [x] - Yank all versions older than `1.0.3`
- [x] - `shadowsocks-rust` - https://github.com/shadowsocks/shadowsocks-rust/issues/462
- [ ] - `rio` - https://github.com/spacejam/rio/issues/44
- [ ] - `seaslug` - https://github.com/spacejam/seaslug/issues/1

#### Fixed crate versions

All crates I have found that assumed the memory layout have been fixed and published. The crates and versions that will continue working even as/if this PR is merged is (please upgrade these to help unblock this PR):

* `net2 0.2.36`
* `socket2 0.3.16`
* `miow 0.2.2`
* `miow 0.3.6`
* `mio 0.7.6`
* `mio 0.6.23` - Never had the invalid assumption itself, but has now been bumped to only allow fixed dependencies (`net2` + `miow`)
* `nb-connect 1.0.3`
* `quinn 0.5.4`
* `quinn 0.6.2`

### Release notes draft

This release changes the memory layout of `Ipv4Addr`, `Ipv6Addr`, `SocketAddrV4` and `SocketAddrV6`. The standard library no longer implements these as the corresponding `libc` structs (`sockaddr_in`, `sockaddr_in6` etc.). This internal representation was never exposed, but some crates relied on it anyway by unsafely transmuting. This change will cause those crates to make invalid memory accesses. Notably `net2 <0.2.36`, `socket2 <0.3.16`, `mio <0.7.6`, `miow <0.3.6` and a few other crates are affected. All known affected crates have been patched and have had fixed versions published over a year ago. If any affected crate is still in your dependency tree, you need to upgrade them before using this version of Rust.
2022-07-31 15:56:28 +00:00
Maybe Waffle
1c2ea78f29 Skip unstable fields when suggesting wrapping expression in structs 2022-07-31 19:12:53 +04:00
Alex Macleod
2a0b51d852 Always include a position span in rustc_parse_format::Argument 2022-07-31 15:11:33 +00:00
Maybe Waffle
5e39b35a2f --bless tests 2022-07-31 18:09:39 +04:00
Maybe Waffle
260a840543 Refactor wrap suggestion code (just a bit) 2022-07-31 17:53:47 +04:00
Chris Denton
7f3d11e1d8
Fix compat.rs for cfg(miri) 2022-07-31 14:45:26 +01:00
Maybe Waffle
506c98f291 Suggest wrapping expressions in single-field record variants 2022-07-31 17:38:28 +04:00
bors
e5a7d8f945 Auto merge of #99979 - Dylan-DPC:rollup-ikkejgy, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #99186 (Use LocalDefId for closures more)
 - #99741 (Use `impl`'s generics when suggesting fix on bad `impl Copy`)
 - #99844 (Introduce an ArchiveBuilderBuilder)
 - #99921 (triagebot.yml: CC Enselic when rustdoc-json-types changes)
 - #99974 (Suggest removing a semicolon and boxing the expressions for if-else)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-31 13:26:27 +00:00
Ralf Jung
c4aca2bc88
typo
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2022-07-31 09:00:49 -04:00
Guillaume Gomez
fc1c858a48 Remove Clean trait implementation for hir::TypeBindingKind 2022-07-31 14:24:13 +02:00
Ralf Jung
abd80d904b reorder fields in Laout debug output 2022-07-31 08:23:27 -04:00
Guillaume Gomez
9dd59ddfbf Remove Clean trait implementation for hir::TypeBinding 2022-07-31 14:21:07 +02:00
Guillaume Gomez
279af1d7e0 Remove Clean trait implementation for hir::Path 2022-07-31 14:17:23 +02:00
Dylan DPC
990bce4da0
Rollup merge of #99974 - TaKO8Ki:suggest-removing-semicolon-and-boxing-the-expressions, r=compiler-errors
Suggest removing a semicolon and boxing the expressions for if-else

`InferCtxt::suggest_remove_semi_or_return_binding` was not working well, so I fixed it and added a ui test.
2022-07-31 17:36:44 +05:30
Dylan DPC
8b2637fd3b
Rollup merge of #99921 - Enselic:cc-enselic, r=GuillaumeGomez
triagebot.yml: CC Enselic when rustdoc-json-types changes

Being the maintainer of [cargo-public-api](https://github.com/Enselic/cargo-public-api) which relies on [rustdoc JSON](https://github.com/rust-lang/rust/issues/76578) means I have high stakes in the rustdoc JSON format itself. Would be great if I could be pinged when the format is about to change.

I hope this is OK. Big thanks in advance.
2022-07-31 17:36:43 +05:30
Dylan DPC
1d010d4382
Rollup merge of #99844 - bjorn3:archive_builder_interface_refactor, r=nagisa
Introduce an ArchiveBuilderBuilder

This avoids monomorphizing all linker code for each codegen backend and will allow passing in extra information to the archive builder from the codegen backend. I'm going to use this in https://github.com/rust-lang/rust/pull/97485 to allow passing in the right function to extract symbols from object files to a generic archive builder to be used by cg_llvm, cg_clif and cg_gcc.
2022-07-31 17:36:42 +05:30
Dylan DPC
2c14bc3b55
Rollup merge of #99741 - compiler-errors:copy-impl-impl-generics, r=fee1-dead
Use `impl`'s generics when suggesting fix on bad `impl Copy`

See the UI test for a more complicated example, but we weren't correctly suggesting to add bounds given a manual `impl` whose generics didn't match the struct generics.

```rust
#[derive(Clone)]
struct Wrapper<T>(T);

impl<S> Copy for Wrapper<S> {}
```

Coincidentally this fix didn't cause any regressions for `derive(Copy)` impls, I think because those use the same spans in the impl generics as the struct generics, so the machinery still applies the same change.
2022-07-31 17:36:41 +05:30
Dylan DPC
403c1b3802
Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot
Use LocalDefId for closures more
2022-07-31 17:36:40 +05:30
bors
76822a2878 Auto merge of #99553 - ChrisDenton:lazy-compat-fn, r=Mark-Simulacrum
Rewrite Windows `compat_fn` macro

This allows using most delay loaded functions before the init code initializes them. It also only preloads a select few functions, rather than all functions.

This is optimized for the common case where a function is used after already being loaded (or failed to load). The only change in codegen at the call site is to use an atomic load instead of a plain load, which should have negligible or no impact.

I've split the old `compat_fn` macro in two so as not to mix two different use cases. If/when Windows 7 support is dropped `compat_fn_optional` can be removed entirely.

r? rust-lang/libs
2022-07-31 10:44:11 +00:00
bjorn3
b87f8a4d9c Add issue reference 2022-07-31 10:33:44 +00:00
bjorn3
df13721863 Remove workarounds for issue 59998 2022-07-31 10:33:44 +00:00
Ralf Jung
98e52c2a27 check 'size multiple of align' for all layouts 2022-07-31 06:29:57 -04:00
bors
482153bc20 Auto merge of #99529 - Milo123459:stage-1-test, r=jyn514
Run `x test --stage 1` in CI

Fixes #99135

r? `@jyn514`
2022-07-31 08:03:26 +00:00
Takayuki Maeda
f6908be329 add a test to check if suggest_remove_semi_or_return_binding is working well for if-else 2022-07-31 11:36:04 +09:00
Takayuki Maeda
03622552ec use appropriate HirID for finding else_span 2022-07-31 11:33:01 +09:00
bors
a2318651d4 Auto merge of #99959 - cuviper:niche-size, r=eddyb
Fix the size of niche enums with ZST alignment

For enums with an aligned ZST variant, like `[T; 0]`, the niche layout
was not computing a sufficient size to be consistent with alignment. Now
we pad that size up to the alignment, and also make sure to only use the
niche variant's ABI when the size and alignment still match.

Fixes #99836
r? `@eddyb`
2022-07-30 23:47:51 +00:00
Milo
1f7b6552bb dont run stage1 tests in pr 2022-07-30 22:10:26 +00:00
Milo
0f121d7288 add to full test-suite 2022-07-30 21:56:53 +00:00
bors
0f4bcadb46 Auto merge of #99964 - matthiaskrgr:rollup-jr836e2, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #99650 (Support `x --keep-stage 0 check`)
 - #99873 (rustdoc: align invalid-html-tags lint with commonmark spec)
 - #99889 (Remove `parent_pat` from `TopInfo`)
 - #99890 (Do not allow bad projection term to leak into the type checker)
 - #99937 (Reset directory iteration in remove_dir_all)
 - #99950 (Remove more Clean trait implementations)
 - #99956 (Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GE)
 - #99962 (Discover channel for LLVM download)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-30 21:01:42 +00:00