]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #97536 - est31:remove_unused_lifetimes, r=compiler-errors
Michael Goulet [Sun, 29 May 2022 23:25:05 +0000 (16:25 -0700)]
Rollup merge of #97536 - est31:remove_unused_lifetimes, r=compiler-errors

Remove unused lifetimes from expand_macro

The function doesn't need the lifetimes
of the two arguments be bound together.

2 years agoRollup merge of #97530 - GuillaumeGomez:more-eslint-checks, r=jsha
Michael Goulet [Sun, 29 May 2022 23:25:04 +0000 (16:25 -0700)]
Rollup merge of #97530 - GuillaumeGomez:more-eslint-checks, r=jsha

Add more eslint checks

Here is a new batch of eslint checks:

 * [no-const-assign](https://eslint.org/docs/rules/no-const-assign)
 * [no-debugger](https://eslint.org/docs/rules/no-debugger)
 * [no-dupe-args](https://eslint.org/docs/rules/no-dupe-args)
 * [no-duple-else-if](https://eslint.org/docs/rules/no-dupe-else-if)
 * [no-dupe-keys](https://eslint.org/docs/rules/no-dupe-keys)
 * [no-duplicate-case](https://eslint.org/docs/rules/no-duplicate-case)
 * [no-ex-assign](https://eslint.org/docs/rules/no-ex-assign)

r? ``@notriddle``

2 years agoRollup merge of #97518 - badboy:rustdoc-ul-div-fix, r=notriddle
Michael Goulet [Sun, 29 May 2022 23:25:03 +0000 (16:25 -0700)]
Rollup merge of #97518 - badboy:rustdoc-ul-div-fix, r=notriddle

Fix order of closing HTML elements in rustdoc output

Initially reported here: https://users.rust-lang.org/t/documentation-itself-parsed-error/76232

2 years agoRollup merge of #97493 - compiler-errors:issue-97490, r=oli-obk
Michael Goulet [Sun, 29 May 2022 23:25:02 +0000 (16:25 -0700)]
Rollup merge of #97493 - compiler-errors:issue-97490, r=oli-obk

Use `type_is_copy_modulo_regions` check in intrisicck

This one canoncalizes region variables correctly, preventing an ICE

Fixes #97490

2 years agoRemove unused lifetimes from expand_macro
est31 [Sun, 29 May 2022 21:30:54 +0000 (23:30 +0200)]
Remove unused lifetimes from expand_macro

The function doesn't need the lifetimes
of the two arguments be bound together.

2 years agoUse type_is_copy_modulo_regions check in intrisicck
Michael Goulet [Sat, 28 May 2022 20:34:54 +0000 (13:34 -0700)]
Use type_is_copy_modulo_regions check in intrisicck

2 years agoAdd "no-ex-assign" eslint rule
Guillaume Gomez [Sun, 29 May 2022 19:44:10 +0000 (21:44 +0200)]
Add "no-ex-assign" eslint rule

2 years agoAdd "no-duplicate-case" eslint rule
Guillaume Gomez [Sun, 29 May 2022 19:43:37 +0000 (21:43 +0200)]
Add "no-duplicate-case" eslint rule

2 years agoAuto merge of #97514 - WaffleLapkin:panick, r=Dylan-DPC
bors [Sun, 29 May 2022 19:42:39 +0000 (19:42 +0000)]
Auto merge of #97514 - WaffleLapkin:panick, r=Dylan-DPC

Fix typo (panick -> panic)

Fix typo (panick -> panic) in `std::error` module docs.

2 years agoAdd "no-dupe-keys" eslint rule
Guillaume Gomez [Sun, 29 May 2022 19:42:11 +0000 (21:42 +0200)]
Add "no-dupe-keys" eslint rule

2 years agoAdd "no-dupe-else-if" eslint rule
Guillaume Gomez [Sun, 29 May 2022 19:41:05 +0000 (21:41 +0200)]
Add "no-dupe-else-if" eslint rule

2 years agoAdd "no-dup-args" eslint rule
Guillaume Gomez [Sun, 29 May 2022 19:40:16 +0000 (21:40 +0200)]
Add "no-dup-args" eslint rule

2 years agoAdd "no-debugger" eslint rule
Guillaume Gomez [Sun, 29 May 2022 19:39:44 +0000 (21:39 +0200)]
Add "no-debugger" eslint rule

2 years agoAdd "no-const-assign" eslint rule
Guillaume Gomez [Sun, 29 May 2022 19:38:52 +0000 (21:38 +0200)]
Add "no-const-assign" eslint rule

2 years agoAuto merge of #97214 - Mark-Simulacrum:stage0-bump, r=pietroalbini
bors [Sun, 29 May 2022 16:28:21 +0000 (16:28 +0000)]
Auto merge of #97214 - Mark-Simulacrum:stage0-bump, r=pietroalbini

Finish bumping stage0

It looks like the last time had left some remaining cfg's -- which made me think
that the stage0 bump was actually successful. This brings us to a released 1.62
beta though.

This now brings us to cfg-clean, with the exception of check-cfg-features in bootstrap;
I'd prefer to leave that for a separate PR at this time since it's likely to be more tricky.

cc https://github.com/rust-lang/rust/pull/97147#issuecomment-1132845061

r? `@pietroalbini`

2 years agoAuto merge of #94214 - nikic:rust-opaque-pointers, r=cuviper
bors [Sun, 29 May 2022 14:12:42 +0000 (14:12 +0000)]
Auto merge of #94214 - nikic:rust-opaque-pointers, r=cuviper

Prepare Rust for opaque pointers

Fix one codegen bug with opaque pointers, and update our IR tests to accept both typed pointer and opaque pointer IR. This is a bit annoying, but unavoidable if we want decent test coverage on both LLVM 14 and LLVM 15.

This prepares Rust for when LLVM will enable opaque pointers by default.

2 years agoFix order of closing HTML elements in rustdoc output
Jan-Erik Rediger [Sun, 29 May 2022 13:22:25 +0000 (15:22 +0200)]
Fix order of closing HTML elements in rustdoc output

2 years agoAuto merge of #97456 - Bryysen:issue-97319-fix, r=compiler-errors
bors [Sun, 29 May 2022 12:00:30 +0000 (12:00 +0000)]
Auto merge of #97456 - Bryysen:issue-97319-fix, r=compiler-errors

Improve error message for E0081

Closes #97319

2 years agoFix typo (panick -> panic)
Maybe Waffle [Sun, 29 May 2022 09:14:59 +0000 (13:14 +0400)]
Fix typo (panick -> panic)

2 years agoAuto merge of #97287 - compiler-errors:type-interner, r=jackh726,oli-obk
bors [Sun, 29 May 2022 08:20:13 +0000 (08:20 +0000)]
Auto merge of #97287 - compiler-errors:type-interner, r=jackh726,oli-obk

Move things to `rustc_type_ir`

Finishes some work proposed in https://github.com/rust-lang/compiler-team/issues/341.

r? `@ghost`

2 years agoAuto merge of #96687 - jyn514:download-rustc, r=Mark-Simulacrum
bors [Sun, 29 May 2022 05:56:09 +0000 (05:56 +0000)]
Auto merge of #96687 - jyn514:download-rustc, r=Mark-Simulacrum

Move download-rustc from python to rustbuild

- Remove download-rustc handling from bootstrap.py
- Allow a custom `pattern` in `builder.unpack()`
- Only download rustc once another part of bootstrap depends on it.

  This is somewhat necessary since the download functions rely on having a full
  `Builder`, which isn't available until after config parsing finishes.

Helps with https://github.com/rust-lang/rust/issues/94829.

2 years agoAuto merge of #96652 - notriddle:notriddle/self, r=GuillaumeGomez
bors [Sun, 29 May 2022 03:15:28 +0000 (03:15 +0000)]
Auto merge of #96652 - notriddle:notriddle/self, r=GuillaumeGomez

rustdoc: include impl generics / self in search index

Fixes #92205

2 years agoAuto merge of #97500 - GuillaumeGomez:rollup-ms1bvps, r=GuillaumeGomez
bors [Sun, 29 May 2022 00:40:45 +0000 (00:40 +0000)]
Auto merge of #97500 - GuillaumeGomez:rollup-ms1bvps, r=GuillaumeGomez

Rollup of 5 pull requests

Successful merges:

 - #96950 (Add regression test for #96395)
 - #97028 (Add support for embedding pretty printers via `#[debugger_visualizer]` attribute)
 - #97478 (Remove FIXME on `ExtCtxt::fn_decl()`)
 - #97479 (Make some tests check-pass)
 - #97482 (ptr::invalid is not equivalent to a int2ptr cast)

Failed merges:

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

2 years agoRollup merge of #97482 - RalfJung:ptr-invalid, r=thomcc
Guillaume Gomez [Sat, 28 May 2022 23:12:33 +0000 (01:12 +0200)]
Rollup merge of #97482 - RalfJung:ptr-invalid, r=thomcc

ptr::invalid is not equivalent to a int2ptr cast

I just realized I forgot to update these docs when adding `from_exposed_addr`.
Right now the docs say `invalid` and `from_exposed_addr` are both equivalent to a cast, and that is clearly not what we want.

Cc ``@Gankra``

2 years agoRollup merge of #97479 - JohnTitor:make-check-pass, r=compiler-errors
Guillaume Gomez [Sat, 28 May 2022 23:12:32 +0000 (01:12 +0200)]
Rollup merge of #97479 - JohnTitor:make-check-pass, r=compiler-errors

Make some tests check-pass

This touches the tests related to lint, parser, and importing, all of them should be fine with `check-pass`.
r? ``@compiler-errors``

2 years agoRollup merge of #97478 - JohnTitor:fixme-fn-decl, r=compiler-errors
Guillaume Gomez [Sat, 28 May 2022 23:12:30 +0000 (01:12 +0200)]
Rollup merge of #97478 - JohnTitor:fixme-fn-decl, r=compiler-errors

Remove FIXME on `ExtCtxt::fn_decl()`

`ExtCtxt::fn_decl()` is used like `self.fn_decl(..)` or `self.cx.fn_decl(..)`, coverting it to an assoc fn, for example, makes it inconvenience (e.g. `self.cx.fn_decl(..)` would be longer to represent). Given that, it doesn't seem a "FIXME" thing and unused `self` is okay, I think.

2 years agoRollup merge of #97028 - ridwanabdillahi:pretty-printer, r=michaelwoerister
Guillaume Gomez [Sat, 28 May 2022 23:12:30 +0000 (01:12 +0200)]
Rollup merge of #97028 - ridwanabdillahi:pretty-printer, r=michaelwoerister

Add support for embedding pretty printers via `#[debugger_visualizer]` attribute

Initial support for [RFC 3191](https://github.com/rust-lang/rfcs/pull/3191) in PR https://github.com/rust-lang/rust/pull/91779 was scoped to supporting embedding NatVis files using a new attribute. This PR implements the pretty printer support as stated in the RFC mentioned above.

This change includes embedding pretty printers in the `.debug_gdb_scripts` just as the pretty printers for rustc are embedded today. Also added additional tests for embedded pretty printers. Additionally cleaned up error checking so all error checking is done up front regardless of the current target.

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

2 years agoRollup merge of #96950 - JohnTitor:issue-96395, r=compiler-errors,oli-obk
Guillaume Gomez [Sat, 28 May 2022 23:12:29 +0000 (01:12 +0200)]
Rollup merge of #96950 - JohnTitor:issue-96395, r=compiler-errors,oli-obk

Add regression test for #96395

Closes #96395
This repeats "fixed" and "ICE", see https://github.com/rust-lang/glacier/pull/1243#issuecomment-1123768138
I think it's good to add a test before regressing again.
r? ``@compiler-errors`` for quick reviiew

cc ``@oli-obk`` you might want to check as you're familiar with MIR

2 years agoAuto merge of #97472 - cuviper:rebase-rustc-rayon, r=Mark-Simulacrum
bors [Sat, 28 May 2022 22:24:53 +0000 (22:24 +0000)]
Auto merge of #97472 - cuviper:rebase-rustc-rayon, r=Mark-Simulacrum

Update to rebased rustc-rayon 0.4

In rayon-rs/rayon#938, miri uncovered a race in `rustc-rayon-core` that had already been fixed in the regular `rayon-core`. I have now rebased that fork onto the latest rayon branch, and published as 0.4. I also updated `indexmap` to bump the dependency.

`Cargo.lock` changes:

    Updating indexmap v1.8.0 -> v1.8.2
    Updating rayon v1.5.1 -> v1.5.3
    Updating rayon-core v1.9.1 -> v1.9.3
    Updating rustc-rayon v0.3.2 -> v0.4.0
    Updating rustc-rayon-core v0.3.2 -> v0.4.1

2 years agoImprove error message for E0081
Bryysen [Fri, 27 May 2022 13:42:15 +0000 (15:42 +0200)]
Improve error message for E0081

Previously whenever a duplicate discriminant was detected for an Enum,
we would print the discriminant bits in the diagnostic without any
casting. This caused us to display incorrect values for negative
discriminants. After this PR we format the discriminant signedness
correctly. Also reworded some of the original error
messages.

2 years agoAuto merge of #97207 - RalfJung:backtrace, r=Mark-Simulacrum
bors [Sat, 28 May 2022 19:30:58 +0000 (19:30 +0000)]
Auto merge of #97207 - RalfJung:backtrace, r=Mark-Simulacrum

update libbacktrace

It seems like previously we were on a tag of the backtrace repo; not sure if there is a policy that it should always be a tag?

Cc https://github.com/rust-lang/backtrace-rs/pull/462 `@alexcrichton` `@DrMeepster`

2 years agoMake TyCtxt implement Interner, make HashStable generic and move to rustc_type_ir
Michael Goulet [Sat, 28 May 2022 03:03:57 +0000 (20:03 -0700)]
Make TyCtxt implement Interner, make HashStable generic and move to rustc_type_ir

2 years agoRemove some comments, inline interner fn
Michael Goulet [Fri, 27 May 2022 14:52:56 +0000 (07:52 -0700)]
Remove some comments, inline interner fn

2 years agoFix TyKind lint, make consts no longer fn, etc
Michael Goulet [Fri, 27 May 2022 03:22:28 +0000 (20:22 -0700)]
Fix TyKind lint, make consts no longer fn, etc

2 years agoInitial fixes on top of type interner commit
Michael Goulet [Sun, 22 May 2022 19:57:46 +0000 (12:57 -0700)]
Initial fixes on top of type interner commit

2 years agoMove things to rustc_type_ir
Wilco Kusee [Sun, 31 Jan 2021 09:32:34 +0000 (10:32 +0100)]
Move things to rustc_type_ir

2 years agoAuto merge of #97461 - eddyb:proc-macro-less-payload, r=bjorn3
bors [Sat, 28 May 2022 16:49:52 +0000 (16:49 +0000)]
Auto merge of #97461 - eddyb:proc-macro-less-payload, r=bjorn3

proc_macro: don't pass a client-side function pointer through the server.

Before this PR, `proc_macro::bridge::Client<F>` contained both:
* the C ABI entry-point `run`, that the server can call to start the client
* some "payload" `f: F` passed to that entry-point
  * in practice, this was always a (client-side Rust ABI) `fn` pointer to the actual function the proc macro author wrote, i.e. `#[proc_macro] fn foo(input: TokenStream) -> TokenStream`

In other words, the client was passing one of its (Rust) `fn` pointers to the server, which was passing it back to the client, for the client to call (see later below for why that was ever needed).

I was inspired by `@nnethercote's` attempt to remove the `get_handle_counters` field from `Client` (see https://github.com/rust-lang/rust/pull/97004#issuecomment-1139273301), which combined with removing the `f` ("payload") field, could theoretically allow for a `#[repr(transparent)]` `Client` that mostly just newtypes the C ABI entry-point `fn` pointer <sub>(and in the context of e.g. wasm isolation, that's *all* you want, since you can reason about it from outside the wasm VM, as just a 32-bit "function table index", that you can pass to the wasm VM to call that function)</sub>.

<hr/>

So this PR removes that "payload". But it's not a simple refactor: the reason the field existed in the first place is because monomorphizing over a function type doesn't let you call the function without having a value of that type, because function types don't implement anything like `Default`, i.e.:
```rust
extern "C" fn ffi_wrapper<A, R, F: Fn(A) -> R>(arg: A) -> R {
    let f: F = ???; // no way to get a value of `F`
    f(arg)
}
```
That could be solved with something like this, if it was allowed:
```rust
extern "C" fn ffi_wrapper<
    A, R,
    F: Fn(A) -> R,
    const f: F // not allowed because the type is a generic param
>(arg: A) -> R {
    f(arg)
}
```

Instead, this PR contains a workaround in `proc_macro::bridge::selfless_reify` (see its module-level comment for more details) that can provide something similar to the `ffi_wrapper` example above, but limited to `F` being `Copy` and ZST (and requiring an `F` value to prove the caller actually can create values of `F` and it's not uninhabited or some other unsound situation).

<hr/>

Hopefully this time we don't have a performance regression, and this has a chance to land.

cc `@mystor` `@bjorn3`

2 years agonote to future self
Ralf Jung [Sat, 28 May 2022 16:15:04 +0000 (18:15 +0200)]
note to future self

2 years agoAuto merge of #97383 - dingxiangfei2009:restore-region-scope-tree-query, r=dingxiangf...
bors [Sat, 28 May 2022 14:30:25 +0000 (14:30 +0000)]
Auto merge of #97383 - dingxiangfei2009:restore-region-scope-tree-query, r=dingxiangfei2009

Try to cache region_scope_tree as a query

This PR will attempt to restore `region_scope_tree` as a query so that caching works again. It seems that `region_scope_tree` could be re-computed for nested items after all, which could explain the performance regression introduced by #95563.

cc `@Mark-Simulacrum` `@pnkfelix` I will try to trigger a perf run here.

2 years agoAuto merge of #97158 - JakobDegen:dse, r=tmiasko,cjgillot
bors [Sat, 28 May 2022 11:49:42 +0000 (11:49 +0000)]
Auto merge of #97158 - JakobDegen:dse, r=tmiasko,cjgillot

Split dead store elimination off dest prop

This splits off a part of #96451 . I've added this in as its own pass for now, so that it actually runs, can be tested, etc. In the dest prop PR, I'll stop invoking this as its own pass, so that it doesn't get invoked twice.

r? `@tmiasko`

2 years agoptr::invalid is not equivalent to a int2ptr cast
Ralf Jung [Sat, 28 May 2022 10:39:36 +0000 (12:39 +0200)]
ptr::invalid is not equivalent to a int2ptr cast

2 years agoMake some tests check-pass
Yuki Okushi [Sat, 28 May 2022 09:57:02 +0000 (18:57 +0900)]
Make some tests check-pass

2 years agoRemove FIXME on `ExtCtxt::fn_decl()`
Yuki Okushi [Sat, 28 May 2022 09:12:34 +0000 (18:12 +0900)]
Remove FIXME on `ExtCtxt::fn_decl()`

2 years agoAuto merge of #97476 - Dylan-DPC:rollup-t53nxoe, r=Dylan-DPC
bors [Sat, 28 May 2022 09:08:49 +0000 (09:08 +0000)]
Auto merge of #97476 - Dylan-DPC:rollup-t53nxoe, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #94640 (Partially stabilize `(const_)slice_ptr_len` feature by stabilizing `NonNull::len`)
 - #97034 (Implement `Hash` for `core::alloc::Layout`)
 - #97327 (macros: introduce `fluent_messages` macro )
 - #97448 (docs: Don't imply that OsStr on Unix is always UTF-8)
 - #97466 ([bootstrap] Move `sanitize_sh` from `dist` to `install`)

Failed merges:

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

2 years agoFix documentation of basic stack protector
Nikita Popov [Sat, 28 May 2022 08:41:28 +0000 (10:41 +0200)]
Fix documentation of basic stack protector

A stack protector is used for N >= 8, not N > 8.

2 years agoRollup merge of #97466 - jyn514:consolidate-install, r=Mark-Simulacrum
Dylan DPC [Sat, 28 May 2022 06:45:54 +0000 (08:45 +0200)]
Rollup merge of #97466 - jyn514:consolidate-install, r=Mark-Simulacrum

[bootstrap] Move `sanitize_sh` from `dist` to `install`

This is the only place it's used, so there's no need for it to be public in another module.
In general, `dist` shouldn't ever touch shell scripts.

2 years agoRollup merge of #97448 - Xiretza:os-str-unix-doc, r=joshtriplett
Dylan DPC [Sat, 28 May 2022 06:45:53 +0000 (08:45 +0200)]
Rollup merge of #97448 - Xiretza:os-str-unix-doc, r=joshtriplett

docs: Don't imply that OsStr on Unix is always UTF-8

The methods in `OsStrExt` consume and return `&[u8]` and don't perform any UTF-8 checks.

2 years agoRollup merge of #97327 - davidtwco:diagnostic-translation-compile-time-validation...
Dylan DPC [Sat, 28 May 2022 06:45:52 +0000 (08:45 +0200)]
Rollup merge of #97327 - davidtwco:diagnostic-translation-compile-time-validation, r=oli-obk

macros: introduce `fluent_messages` macro

Adds a new `fluent_messages` macro which performs compile-time validation of the compiler's Fluent resources (i.e. that the resources parse and don't multiply define the same messages) and generates constants that make using those messages in diagnostics more ergonomic.

For example, given the following invocation of the macro..

```rust
fluent_messages! {
    typeck => "./typeck.ftl",
}
```

..where `typeck.ftl` has the following contents..

```fluent
typeck-field-multiply-specified-in-initializer =
    field `{$ident}` specified more than once
    .label = used more than once
    .label-previous-use = first use of `{$ident}`
```

...then the macro parse the Fluent resource, emitting a diagnostic if it fails to do so...

```text
error: could not parse Fluent resource
  --> $DIR/test.rs:35:28
   |
LL |         missing_message => "./missing-message.ftl",
   |                            ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: see additional errors emitted

error: expected a message field for "missing-message"
 --> ./missing-message.ftl:1:1
  |
1 | missing-message =
  | ^^^^^^^^^^^^^^^^^^
  |
```
...or generating the following code if it succeeds:

```rust
pub static DEFAULT_LOCALE_RESOURCES: &'static [&'static str] = &[
    include_str!("./typeck.ftl"),
];

mod fluent_generated {
    mod typeck {
        pub const field_multiply_specified_in_initializer: DiagnosticMessage =
            DiagnosticMessage::fluent("typeck-field-multiply-specified-in-initializer");
        pub const field_multiply_specified_in_initializer_label_previous_use: DiagnosticMessage =
            DiagnosticMessage::fluent_attr(
                "typeck-field-multiply-specified-in-initializer",
                "previous-use-label"
            );
    }
}
```

When emitting a diagnostic, the generated constants can be used as follows:

```rust
let mut err = sess.struct_span_err(
    span,
    fluent::typeck::field_multiply_specified_in_initializer
);
err.span_label(
    span,
    fluent::typeck::field_multiply_specified_in_initializer_label
);
err.span_label(
    previous_use_span,
    fluent::typeck::field_multiply_specified_in_initializer_label_previous_use
);
err.emit();
```

I'd like to reduce the verbosity of referring to labels/notes/helps with this scheme (though it wasn't much better before), but I'll leave that for a follow-up.

r? `@oli-obk`
cc `@pvdrz` `@compiler-errors`

2 years agoRollup merge of #97034 - fee1-dead-contrib:layout-hash, r=dtolnay
Dylan DPC [Sat, 28 May 2022 06:45:51 +0000 (08:45 +0200)]
Rollup merge of #97034 - fee1-dead-contrib:layout-hash, r=dtolnay

Implement `Hash` for `core::alloc::Layout`

This was brought up on [reddit](https://www.reddit.com/r/rust/comments/uoypui/the_standard_library_types_are_good_except_when/), and I don't see why Layout shouldn't implement `Hash`. Feel free to comment if I am wrong though :)

2 years agoRollup merge of #94640 - Pointerbender:issue-71146-partial-stabilization, r=yaahc
Dylan DPC [Sat, 28 May 2022 06:45:50 +0000 (08:45 +0200)]
Rollup merge of #94640 - Pointerbender:issue-71146-partial-stabilization, r=yaahc

Partially stabilize `(const_)slice_ptr_len` feature by stabilizing `NonNull::len`

This PR partially stabilizes features `const_slice_ptr_len` and `slice_ptr_len` by only stabilizing `NonNull::len`. This partial stabilization is tracked under features `slice_ptr_len_nonnull` and `const_slice_ptr_len_nonnull`, for which this PR can serve as the tracking issue.

To summarize the discussion from #71146 leading up to this partial stabilization request:

It's currently a bit footgunny to obtain the length of a raw slice pointer, stabilization of `NonNull:len` will help with removing these footguns. Some example footguns are:

```rust
/// # Safety
/// The caller must ensure that `ptr`:
/// 1. does not point to memory that was previously allocated but is now deallocated;
/// 2. is within the bounds of a single allocated object;
/// 3. does not to point to a slice for which the length exceeds `isize::MAX` bytes;
/// 4. points to a properly aligned address;
/// 5. does not point to uninitialized memory;
/// 6. does not point to a mutably borrowed memory location.
pub unsafe fn ptr_len<T>(ptr: core::ptr::NonNull<[T]>) -> usize {
   (&*ptr.as_ptr()).len()
}
```

A slightly less complicated version (but still more complicated than it needs to be):

```rust
/// # Safety
/// The caller must ensure that the start of `ptr`:
/// 1. does not point to memory that was previously allocated but is now deallocated;
/// 2. must be within the bounds of a single allocated object.
pub unsafe fn ptr_len<T>(ptr: NonNull<[T]>) -> usize {
   (&*(ptr.as_ptr() as *const [()])).len()
}
```

This PR does not stabilize `<*const [T]>::len` and  `<*mut [T]>::len` because the tracking issue #71146 list a potential blocker for these methods, but this blocker [does not apply](https://github.com/rust-lang/rust/issues/71146#issuecomment-808735714) to `NonNull::len`.

We should probably also ping the [Constant Evaluation WG](https://github.com/rust-lang/const-eval) since this PR includes a `#[rustc_allow_const_fn_unstable(const_slice_ptr_len)]`. My instinct here is that this will probably be okay because the pointer is not actually dereferenced and `len()` does not touch the address component of the pointer, but would be best to double check :)

One potential down-side was raised that stabilizing `NonNull::len` could lead to encouragement of coding patterns like:

```
pub fn ptr_len<T>(ptr: *mut [T]) -> usize {
   NonNull::new(ptr).unwrap().len()
}
```

which unnecessarily assert non-nullness. However, these are much less of a footgun than the above examples and this should be resolved when `slice_ptr_len` fully stabilizes eventually.

2 years agoAuto merge of #97465 - jyn514:dist-ra, r=Mark-Simulacrum
bors [Sat, 28 May 2022 06:45:15 +0000 (06:45 +0000)]
Auto merge of #97465 - jyn514:dist-ra, r=Mark-Simulacrum

Fix `x dist --stage 1 src/tools/rust-analyzer`

Previously, this would break because the submodule wasn't checked out.

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

2 years agoAuto merge of #97284 - b-naber:constraint-dyn-impl-suggestion, r=estebank
bors [Sat, 28 May 2022 04:04:29 +0000 (04:04 +0000)]
Auto merge of #97284 - b-naber:constraint-dyn-impl-suggestion, r=estebank

Add suggestion for relaxing static lifetime bounds on dyn trait impls in NLL

This PR introduces suggestions for relaxing static lifetime bounds on impls of dyn trait items for NLL similar to what is already available in lexical region diagnostics.

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

r? `@estebank`

2 years agoUpdate to rebased rustc-rayon 0.4
Josh Stone [Sat, 28 May 2022 00:14:22 +0000 (17:14 -0700)]
Update to rebased rustc-rayon 0.4

2 years agoAuto merge of #97433 - GuillaumeGomez:rm-refcell-context, r=notriddle
bors [Sat, 28 May 2022 01:37:09 +0000 (01:37 +0000)]
Auto merge of #97433 - GuillaumeGomez:rm-refcell-context, r=notriddle

Pass Context as a &mut to allow to remove RefCell fields

Fixes #90323.

r? `@notriddle`

2 years agoSwitch incremental/hashes tests to all use optimizations.
Jakob Degen [Sat, 28 May 2022 01:17:39 +0000 (18:17 -0700)]
Switch incremental/hashes tests to all use optimizations.

2 years agoAuto merge of #97468 - matthiaskrgr:rollup-8cu0hqr, r=matthiaskrgr
bors [Fri, 27 May 2022 23:17:18 +0000 (23:17 +0000)]
Auto merge of #97468 - matthiaskrgr:rollup-8cu0hqr, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #95214 (Remove impossible panic note from `Vec::append`)
 - #97411 (Print stderr consistently)
 - #97453 (rename `TyKind` to `RegionKind` in comment in rustc_middle)
 - #97457 (Add regression test for #81899)
 - #97458 (Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error)
 - #97462 (Add more eslint rules)

Failed merges:

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

2 years agoRollup merge of #97462 - GuillaumeGomez:more-eslint-rules, r=notriddle
Matthias Krüger [Fri, 27 May 2022 23:11:51 +0000 (01:11 +0200)]
Rollup merge of #97462 - GuillaumeGomez:more-eslint-rules, r=notriddle

Add more eslint rules

The last one is the most useful of this batch. :)

Here are the links for the eslint rules:

 * [arrow-parens](https://eslint.org/docs/rules/arrow-parens)
 * [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars)
 * [eqeqeq](https://eslint.org/docs/rules/eqeqeq)

r? `@notriddle`

2 years agoRollup merge of #97458 - estebank:use-self-in-derive-macro, r=compiler-errors
Matthias Krüger [Fri, 27 May 2022 23:11:50 +0000 (01:11 +0200)]
Rollup merge of #97458 - estebank:use-self-in-derive-macro, r=compiler-errors

Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error

Reduce verbosity in #97343.

2 years agoRollup merge of #97457 - JohnTitor:issue-81899, r=compiler-errors
Matthias Krüger [Fri, 27 May 2022 23:11:49 +0000 (01:11 +0200)]
Rollup merge of #97457 - JohnTitor:issue-81899, r=compiler-errors

Add regression test for #81899

Closes #81899
r? `@compiler-errors`

2 years agoRollup merge of #97453 - lcnr:comment, r=jackh726
Matthias Krüger [Fri, 27 May 2022 23:11:48 +0000 (01:11 +0200)]
Rollup merge of #97453 - lcnr:comment, r=jackh726

rename `TyKind` to `RegionKind` in comment in rustc_middle

2 years agoRollup merge of #97411 - raiyansayeed:print-stderr-consistently, r=Mark-Simulacrum
Matthias Krüger [Fri, 27 May 2022 23:11:47 +0000 (01:11 +0200)]
Rollup merge of #97411 - raiyansayeed:print-stderr-consistently, r=Mark-Simulacrum

Print stderr consistently

Solves https://github.com/rust-lang/rust/issues/96712

I tried to follow what I perceived as the general consensus for error messages in boostrap i.e messages that were ..
* resulting from an Err(...) =>
* literally called as "Error: ...."
* by the end of the block scope forced to run a panic! or process::exit with a guaranteed non-zero error code.

2 years agoRollup merge of #95214 - tbu-:pr_vec_append_doc, r=Mark-Simulacrum
Matthias Krüger [Fri, 27 May 2022 23:11:46 +0000 (01:11 +0200)]
Rollup merge of #95214 - tbu-:pr_vec_append_doc, r=Mark-Simulacrum

Remove impossible panic note from `Vec::append`

Neither the number of elements in a vector can overflow a `usize`, nor
can the amount of elements in two vectors.

2 years ago[bootstrap] Move `sanitize_sh` from `dist` to `install`
Joshua Nelson [Fri, 27 May 2022 22:52:41 +0000 (17:52 -0500)]
[bootstrap] Move `sanitize_sh` from `dist` to `install`

This is the only place it's used, so there's no need for it to be public in another module.
In general, `dist` shouldn't ever touch shell scripts.

2 years agoFix `x dist --stage 1 src/tools/rust-analyzer`
Joshua Nelson [Fri, 27 May 2022 22:47:31 +0000 (17:47 -0500)]
Fix `x dist --stage 1 src/tools/rust-analyzer`

Previously, this would break because the submodule wasn't checked out.

2 years agoAdd "eqeqeq" eslint rule
Guillaume Gomez [Fri, 27 May 2022 20:30:19 +0000 (22:30 +0200)]
Add "eqeqeq" eslint rule

2 years agoAdd "no-unused-vars" eslint rule
Guillaume Gomez [Fri, 27 May 2022 20:22:22 +0000 (22:22 +0200)]
Add "no-unused-vars" eslint rule

2 years agoAdd "arrow-parens" eslint rule
Guillaume Gomez [Fri, 27 May 2022 20:21:41 +0000 (22:21 +0200)]
Add "arrow-parens" eslint rule

2 years agoPass Context as a &mut to allow to remove RefCell fields
Guillaume Gomez [Thu, 26 May 2022 18:18:00 +0000 (20:18 +0200)]
Pass Context as a &mut to allow to remove RefCell fields

2 years agocleanup librustdoc by making parent stack store items
Michael Howell [Fri, 27 May 2022 19:23:29 +0000 (12:23 -0700)]
cleanup librustdoc by making parent stack store items

2 years agoproc_macro: don't pass a client-side function pointer through the server.
Eduard-Mihai Burtescu [Fri, 27 May 2022 17:38:58 +0000 (17:38 +0000)]
proc_macro: don't pass a client-side function pointer through the server.

2 years agoAuto merge of #96790 - lqd:update_jemalloc, r=Mark-Simulacrum
bors [Fri, 27 May 2022 18:28:12 +0000 (18:28 +0000)]
Auto merge of #96790 - lqd:update_jemalloc, r=Mark-Simulacrum

Update jemalloc to v5.3

Now that `jemalloc` version 5.3 has been released, this PR updates `tikv-jemalloc-sys` to the corresponding release.

The crates.io publishing issue seems to have been resolved for the `jemalloc-sys` package, and version 5.3.0 is now also available under the historical name (and should become the preferred crate to be used). Therefore, this PR also switches back to using `jemalloc-sys` instead of  `tikv-jemalloc-sys`.

2 years agoModify `derive(Debug)` to use `Self` in struct literal to avoid redundant error
Esteban Küber [Fri, 27 May 2022 17:48:12 +0000 (10:48 -0700)]
Modify `derive(Debug)` to use `Self` in struct literal to avoid redundant error

#97343

2 years agoAdd test for #97343
Esteban Küber [Fri, 27 May 2022 17:47:05 +0000 (10:47 -0700)]
Add test for #97343

2 years agoAdd regression test for #81899
Yuki Okushi [Fri, 27 May 2022 16:32:15 +0000 (01:32 +0900)]
Add regression test for #81899

2 years agofix comment
lcnr [Fri, 27 May 2022 14:36:59 +0000 (16:36 +0200)]
fix comment

2 years agoFinish bumping stage0
Mark Rousskov [Fri, 20 May 2022 12:54:10 +0000 (08:54 -0400)]
Finish bumping stage0

It looks like the last time had left some remaining cfg's -- which made me think
that the stage0 bump was actually successful. This brings us to a released 1.62
beta though.

2 years agoAuto merge of #96046 - oli-obk:const_typeck, r=cjgillot
bors [Fri, 27 May 2022 11:31:37 +0000 (11:31 +0000)]
Auto merge of #96046 - oli-obk:const_typeck, r=cjgillot

Move various checks to typeck so them failing causes the typeck result to get tainted

Fixes #69487
fixes #79047

cc `@RalfJung` this gets rid of the `Transmute` invalid program error variant

2 years agodocs: Don't imply that OsStr on Unix is always UTF-8
Xiretza [Fri, 27 May 2022 10:12:15 +0000 (12:12 +0200)]
docs: Don't imply that OsStr on Unix is always UTF-8

The methods in `OsStrExt` consume and return `&[u8]` and don't perform
any UTF-8 checks.

2 years agoUpdate tests on aarch64
Oli Scherer [Fri, 27 May 2022 09:18:11 +0000 (09:18 +0000)]
Update tests on aarch64

2 years agoAuto merge of #97442 - hafeoz:master, r=GuillaumeGomez
bors [Fri, 27 May 2022 08:50:51 +0000 (08:50 +0000)]
Auto merge of #97442 - hafeoz:master, r=GuillaumeGomez

Fix multiline attributes processing in doctest

Fixes #97440.

It seems like the call to `check_if_attr_is_complete` is not provided with the correct argument: the pending attribute should be passed, while the current line is actually being passed. This causes any attribute with more than 2 lines to fail and produces ICE when running through doctest.

2 years agoAuto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb
bors [Fri, 27 May 2022 06:09:45 +0000 (06:09 +0000)]
Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb

Proc macro tweaks

Various improvements I spotted while looking through the proc macro code.

r? `@eddyb`

2 years agoCut down `associated_item`.
Nicholas Nethercote [Mon, 16 May 2022 21:42:57 +0000 (07:42 +1000)]
Cut down `associated_item`.

The part of it dealing with types obfuscates and makes the code less
concise. This commit removes that part.

2 years agoRemove unnecessary blank line.
Nicholas Nethercote [Mon, 16 May 2022 22:39:57 +0000 (08:39 +1000)]
Remove unnecessary blank line.

2 years agoRename `b` as `buf` in several places.
Nicholas Nethercote [Wed, 18 May 2022 23:03:26 +0000 (09:03 +1000)]
Rename `b` as `buf` in several places.

Because it's easy to confuse with `bridge`.

2 years agoAdd some comments about `_marker` fields.
Nicholas Nethercote [Sun, 15 May 2022 23:36:52 +0000 (09:36 +1000)]
Add some comments about `_marker` fields.

There is some non-obvious information required to understand them.

2 years agoClarify a comment.
Nicholas Nethercote [Fri, 13 May 2022 05:57:55 +0000 (15:57 +1000)]
Clarify a comment.

`reverse_encode` isn't necessary to please the borrow checker, it's to
match the ordering done by `reverse_decode`.

2 years agoRename `ProcMacroDerive` as `DeriveProcMacro`.
Nicholas Nethercote [Mon, 16 May 2022 01:56:36 +0000 (11:56 +1000)]
Rename `ProcMacroDerive` as `DeriveProcMacro`.

So it matches the existing `AttrProcMacro` and `BangProcMacro` types.

2 years agoRename `ProcMacro` trait as `BangProcMacro`.
Nicholas Nethercote [Fri, 13 May 2022 04:07:56 +0000 (14:07 +1000)]
Rename `ProcMacro` trait as `BangProcMacro`.

Similar to the existing `AttrProcMacro` trait.

2 years agoSimplify types in `proc_macro_harness.rs`.
Nicholas Nethercote [Fri, 13 May 2022 01:45:51 +0000 (11:45 +1000)]
Simplify types in `proc_macro_harness.rs`.

This gives the more obvious derive/attr/bang distinction, and reduces
code size slightly.

2 years agoMake `Buffer<T>` non-generic.
Nicholas Nethercote [Thu, 12 May 2022 23:38:02 +0000 (09:38 +1000)]
Make `Buffer<T>` non-generic.

`u8` is the only type that makes sense for `T`, as demonstrated by the
fact that several impls and functions are hardwired to `Buffer<u8>`.

2 years agoImprove formatting in `associated_item!` definition.
Nicholas Nethercote [Fri, 13 May 2022 00:21:38 +0000 (10:21 +1000)]
Improve formatting in `associated_item!` definition.

2 years agoAdd some comments.
Nicholas Nethercote [Fri, 13 May 2022 00:07:45 +0000 (10:07 +1000)]
Add some comments.

2 years agoFix a typo in a comment.
Nicholas Nethercote [Thu, 12 May 2022 23:44:17 +0000 (09:44 +1000)]
Fix a typo in a comment.

2 years agoAuto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors
bors [Fri, 27 May 2022 03:27:04 +0000 (03:27 +0000)]
Auto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors

Rollup of 3 pull requests

Successful merges:

 - #96051 (Use rounding in float to Duration conversion methods)
 - #97066 (rustdoc: Remove `ItemFragment(Kind)`)
 - #97436 (Update `triagebot.toml` for macos ping group)

Failed merges:

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

2 years agoRollup merge of #97436 - compiler-errors:macos-ping-2, r=Mark-Simulacrum
Michael Goulet [Fri, 27 May 2022 03:15:09 +0000 (20:15 -0700)]
Rollup merge of #97436 - compiler-errors:macos-ping-2, r=Mark-Simulacrum

Update `triagebot.toml` for macos ping group

idk what i'm doing but i saw https://github.com/rust-lang/rust/pull/96392#issuecomment-1138893845

cc: `@thomcc`

2 years agoRollup merge of #97066 - petrochenkov:nofragkind, r=camelid
Michael Goulet [Fri, 27 May 2022 03:15:08 +0000 (20:15 -0700)]
Rollup merge of #97066 - petrochenkov:nofragkind, r=camelid

rustdoc: Remove `ItemFragment(Kind)`

And stop using `write!` when rendering URL fragments to avoid impossible errors.

2 years agoRollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett
Michael Goulet [Fri, 27 May 2022 03:15:07 +0000 (20:15 -0700)]
Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett

Use rounding in float to Duration conversion methods

Closes #96045

2 years agofmt
Артём Павлов [Artyom Pavlov] [Fri, 27 May 2022 02:15:22 +0000 (05:15 +0300)]
fmt

2 years agofix nanos overflow for f64
Артём Павлов [Artyom Pavlov] [Fri, 27 May 2022 01:59:01 +0000 (04:59 +0300)]
fix nanos overflow for f64

2 years agoAuto merge of #96298 - petrochenkov:fromgen, r=estebank
bors [Fri, 27 May 2022 01:01:15 +0000 (01:01 +0000)]
Auto merge of #96298 - petrochenkov:fromgen, r=estebank

libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions

An equally useful little helper.

I didn't follow any of the async-wg work, so I don't know why something like this wasn't added before.