Commit Graph

168976 Commits

Author SHA1 Message Date
est31
cdb8e64bc7 Use Box::new() instead of box syntax in core tests 2022-05-29 01:44:11 +02:00
est31
d75c60f9a3 Use Box::new() instead of box syntax in std tests 2022-05-29 01:44:11 +02:00
est31
7230a15c32 Use Box::new() instead of box syntax in alloc tests 2022-05-29 00:41:14 +02:00
bors
68314177e7 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`
2022-05-28 11:49:42 +00:00
bors
19abca1172 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
2022-05-28 09:08:49 +00:00
Dylan DPC
5badc299d9
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.
2022-05-28 08:45:54 +02:00
Dylan DPC
529fcb579b
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.
2022-05-28 08:45:53 +02:00
Dylan DPC
7e7dd1c069
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`
2022-05-28 08:45:52 +02:00
Dylan DPC
880d3ea3c2
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 :)
2022-05-28 08:45:51 +02:00
Dylan DPC
837cd9e26c
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.
2022-05-28 08:45:50 +02:00
bors
b97bfc3b38 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.
2022-05-28 06:45:15 +00:00
bors
ed76b773b5 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`
2022-05-28 04:04:29 +00:00
bors
764b8615e9 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`
2022-05-28 01:37:09 +00:00
Jakob Degen
7a99da1d50 Switch incremental/hashes tests to all use optimizations. 2022-05-27 18:17:39 -07:00
bors
2aae8020c7 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
2022-05-27 23:17:18 +00:00
Matthias Krüger
b37b735038
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`
2022-05-28 01:11:51 +02:00
Matthias Krüger
0804ef6563
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.
2022-05-28 01:11:50 +02:00
Matthias Krüger
29ac9b13d4
Rollup merge of #97457 - JohnTitor:issue-81899, r=compiler-errors
Add regression test for #81899

Closes #81899
r? `@compiler-errors`
2022-05-28 01:11:49 +02:00
Matthias Krüger
e96397b63f
Rollup merge of #97453 - lcnr:comment, r=jackh726
rename `TyKind` to `RegionKind` in comment in rustc_middle
2022-05-28 01:11:48 +02:00
Matthias Krüger
1174dba02f
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.
2022-05-28 01:11:47 +02:00
Matthias Krüger
4254f922db
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.
2022-05-28 01:11:46 +02:00
Joshua Nelson
81e2c112d9 [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.
2022-05-27 17:52:41 -05:00
Joshua Nelson
6f5de285eb Fix x dist --stage 1 src/tools/rust-analyzer
Previously, this would break because the submodule wasn't checked out.
2022-05-27 17:47:31 -05:00
Guillaume Gomez
334f12c28e Add "eqeqeq" eslint rule 2022-05-27 22:30:19 +02:00
Guillaume Gomez
3741a88ad7 Add "no-unused-vars" eslint rule 2022-05-27 22:22:22 +02:00
Guillaume Gomez
b7d6a429b5 Add "arrow-parens" eslint rule 2022-05-27 22:21:41 +02:00
Guillaume Gomez
6ab8edb931 Pass Context as a &mut to allow to remove RefCell fields 2022-05-27 22:16:24 +02:00
bors
ebbcbfc236 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`.
2022-05-27 18:28:12 +00:00
Esteban Küber
f2a1b7b772 Modify derive(Debug) to use Self in struct literal to avoid redundant error
#97343
2022-05-27 10:48:12 -07:00
Esteban Küber
d21bc6562a Add test for #97343 2022-05-27 10:47:05 -07:00
Yuki Okushi
6ba9ed86c3
Add regression test for #81899 2022-05-28 01:32:15 +09:00
lcnr
4781246a2c fix comment 2022-05-27 16:36:59 +02:00
bors
56fd680cf9 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
2022-05-27 11:31:37 +00:00
Xiretza
202026441b 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.
2022-05-27 12:14:26 +02:00
Oli Scherer
4332c2fbbd Update tests on aarch64 2022-05-27 09:18:11 +00:00
bors
46147119ec 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.
2022-05-27 08:50:51 +00:00
bors
f558990814 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`
2022-05-27 06:09:45 +00:00
Nicholas Nethercote
41c10dde95 Cut down associated_item.
The part of it dealing with types obfuscates and makes the code less
concise. This commit removes that part.
2022-05-27 16:02:24 +10:00
Nicholas Nethercote
e6fa19a3ce Remove unnecessary blank line. 2022-05-27 16:02:24 +10:00
Nicholas Nethercote
f5c9c1215c Rename b as buf in several places.
Because it's easy to confuse with `bridge`.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote
c2c505737f Add some comments about _marker fields.
There is some non-obvious information required to understand them.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote
9a785e0aa5 Clarify a comment.
`reverse_encode` isn't necessary to please the borrow checker, it's to
match the ordering done by `reverse_decode`.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote
bc70d0db92 Rename ProcMacroDerive as DeriveProcMacro.
So it matches the existing `AttrProcMacro` and `BangProcMacro` types.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote
dbdc7dd0dc Rename ProcMacro trait as BangProcMacro.
Similar to the existing `AttrProcMacro` trait.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote
1a9514d5ce Simplify types in proc_macro_harness.rs.
This gives the more obvious derive/attr/bang distinction, and reduces
code size slightly.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote
2ece157e17 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>`.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote
e02789c9f8 Improve formatting in associated_item! definition. 2022-05-27 15:58:35 +10:00
Nicholas Nethercote
a61a85eb24 Add some comments. 2022-05-27 15:58:35 +10:00
Nicholas Nethercote
2469ed0142 Fix a typo in a comment. 2022-05-27 15:58:35 +10:00
bors
9a42c6509d 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
2022-05-27 03:27:04 +00:00