]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd support for a new attribute `#[debugger_visualizer]` to support embedding debugge...
ridwanabdillahi [Tue, 26 Apr 2022 01:02:43 +0000 (18:02 -0700)]
Add support for a new attribute `#[debugger_visualizer]` to support embedding debugger visualizers into a generated PDB.

Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries.

Merge the queries for debugger visualizers into a single query.

Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`.

Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate.

Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature.

Respond to PR comments and minor cleanups.

2 years agoAuto merge of #96280 - lygstate:ffi-fixes, r=joshtriplett
bors [Tue, 3 May 2022 17:22:58 +0000 (17:22 +0000)]
Auto merge of #96280 - lygstate:ffi-fixes, r=joshtriplett

library/core: Fixes implement of c_uint, c_long, c_ulong

Fixes: aa670166243 ("make memcmp return a value of c_int_width instead of i32")
Introduce c_num_definition to getting the cfg_if logic easier to maintain
Add newlines for easier code reading

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
2 years agoignore the doctest for map
Yoshiki Matsuda [Tue, 3 May 2022 15:53:46 +0000 (00:53 +0900)]
ignore the doctest for map

2 years agoMove only_used_in_recursion to nursery
flip1995 [Tue, 3 May 2022 15:41:12 +0000 (16:41 +0100)]
Move only_used_in_recursion to nursery

2 years agoReport that opaque types are not allowed in impls even in the presence of other errors
Oli Scherer [Tue, 3 May 2022 13:53:53 +0000 (13:53 +0000)]
Report that opaque types are not allowed in impls even in the presence of other errors

2 years agoIgnore type aliases in `init_numbered_fields`
Alex Macleod [Tue, 3 May 2022 12:39:38 +0000 (13:39 +0100)]
Ignore type aliases in `init_numbered_fields`

2 years agoAuto merge of #96601 - tmiasko:ssa-rpo, r=davidtwco
bors [Tue, 3 May 2022 12:16:00 +0000 (12:16 +0000)]
Auto merge of #96601 - tmiasko:ssa-rpo, r=davidtwco

Use reverse postorder in `non_ssa_locals`

The reverse postorder, unlike preorder, is now cached inside the MIR
body. Code generation uses reverse postorder anyway, so it might be
a small perf improvement to use it here as well.

2 years agoRound timeouts up to infinite in futex_wait on DragonFlyBSD.
Mara Bos [Tue, 3 May 2022 10:33:10 +0000 (12:33 +0200)]
Round timeouts up to infinite in futex_wait on DragonFlyBSD.

2 years agoAdd #[cfg] in cfg_if for linux in unix/futex.
Mara Bos [Tue, 3 May 2022 10:32:41 +0000 (12:32 +0200)]
Add #[cfg] in cfg_if for linux in unix/futex.

2 years agoDon't use futexes on netbsd.
Mara Bos [Tue, 3 May 2022 07:08:38 +0000 (09:08 +0200)]
Don't use futexes on netbsd.

The latest NetBSD release doesn't include the futex syscall yet.

2 years agocargo dev bless
binggh [Tue, 3 May 2022 09:51:34 +0000 (17:51 +0800)]
cargo dev bless

2 years agoEasier readability for needless_late_init
binggh [Tue, 3 May 2022 09:51:23 +0000 (17:51 +0800)]
Easier readability for needless_late_init

2 years agoignore a doctest for the non-exported macro
Yoshiki Matsuda [Tue, 3 May 2022 09:33:56 +0000 (18:33 +0900)]
ignore a doctest for the non-exported macro

2 years agoAuto merge of #96666 - lnicola:rust-analyzer-2022-05-03, r=lnicola
bors [Tue, 3 May 2022 09:27:59 +0000 (09:27 +0000)]
Auto merge of #96666 - lnicola:rust-analyzer-2022-05-03, r=lnicola

:arrow_up: rust-analyzer

r? `@ghost`

2 years agoMake rustc_parse_format compile on stable
bjorn3 [Fri, 29 Apr 2022 16:48:58 +0000 (18:48 +0200)]
Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may
allow it to be used by rust-analyzer.

2 years agoMake rustc_parse_format compile on stable
bjorn3 [Fri, 29 Apr 2022 16:48:58 +0000 (18:48 +0200)]
Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may
allow it to be used by rust-analyzer.

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 3 May 2022 09:13:22 +0000 (12:13 +0300)]
:arrow_up: rust-analyzer

2 years agoAuto merge of #8730 - tamaroning:fix8724, r=Alexendoo
bors [Tue, 3 May 2022 07:05:51 +0000 (07:05 +0000)]
Auto merge of #8730 - tamaroning:fix8724, r=Alexendoo

[FP] identity_op in front of if

fix #8724

changelog: FP: [`identity_op`]: is now allowed in front of if statements, blocks and other expressions where the suggestion would be invalid.

Resolved simular problems with blocks, mathces, and loops.
identity_op always does NOT suggest reducing `0 + if b { 1 } else { 2 } + 3` into  `if b { 1 } else { 2 } + 3` even in the case that the expression is in `f(expr)` or `let x = expr;` for now.

2 years agoAuto merge of #96663 - JohnTitor:rollup-lthuzdq, r=JohnTitor
bors [Tue, 3 May 2022 06:09:57 +0000 (06:09 +0000)]
Auto merge of #96663 - JohnTitor:rollup-lthuzdq, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #93097 (Switch settings menu to full js)
 - #96587 (Refactor the WriteBackendMethods and ExtraBackendMethods traits)
 - #96589 (Use source callsite in check_argument_types suggestion)
 - #96599 (Update `RValue::Discriminant` documentation)
 - #96614 (Add a regression test for #92305)
 - #96629 (Fix invalid keyword order for function declarations)
 - #96641 (Use a yes/no enum instead of a bool.)
 - #96646 (Mitigate impact of subtle invalid call suggestion logic)

Failed merges:

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

2 years agoRollup merge of #96646 - estebank:issue-96638, r=jackh726
Yuki Okushi [Tue, 3 May 2022 05:59:03 +0000 (14:59 +0900)]
Rollup merge of #96646 - estebank:issue-96638, r=jackh726

Mitigate impact of subtle invalid call suggestion logic

There's some subtle interaction between inferred expressions being
passed as an argument to fn calls with fewer than expected arguments. To
avoid the ICE, I'm changing indexing operations with `.get(idx)`, but
the underlying logic still needs to be audited as it was written with
the assumption that `final_arg_types` and `provided_args` have the right
length.

Address #96638.

2 years agoRollup merge of #96641 - oli-obk:bool_args, r=wesleywiser
Yuki Okushi [Tue, 3 May 2022 05:59:01 +0000 (14:59 +0900)]
Rollup merge of #96641 - oli-obk:bool_args, r=wesleywiser

Use a yes/no enum instead of a bool.

The bool's meaning wasn't obvious to me at some call sites.

2 years agoRollup merge of #96629 - ken-matsui:fix-invalid-keyword-order-for-function-declaratio...
Yuki Okushi [Tue, 3 May 2022 05:59:01 +0000 (14:59 +0900)]
Rollup merge of #96629 - ken-matsui:fix-invalid-keyword-order-for-function-declarations, r=davidtwco

Fix invalid keyword order for function declarations

Closes: https://github.com/rust-lang/rust/issues/94879
2 years agoRollup merge of #96614 - JohnTitor:test-92305, r=oli-obk
Yuki Okushi [Tue, 3 May 2022 05:59:00 +0000 (14:59 +0900)]
Rollup merge of #96614 - JohnTitor:test-92305, r=oli-obk

Add a regression test for #92305

Closes #92305
r? ``@oli-obk`` as per https://github.com/rust-lang/rust/issues/92305#issuecomment-1114043188

2 years agoRollup merge of #96599 - tmiasko:discriminant-docs, r=estebank
Yuki Okushi [Tue, 3 May 2022 05:58:59 +0000 (14:58 +0900)]
Rollup merge of #96599 - tmiasko:discriminant-docs, r=estebank

Update `RValue::Discriminant` documentation

`RValue::Discriminant` returns zero for types without discriminant.
This guarantee is already documented for `discriminant_value`
intrinsics which is implemented in terms of `RValue::Discriminant`.

2 years agoRollup merge of #96589 - Badel2:source-callsite, r=michaelwoerister
Yuki Okushi [Tue, 3 May 2022 05:58:58 +0000 (14:58 +0900)]
Rollup merge of #96589 - Badel2:source-callsite, r=michaelwoerister

Use source callsite in check_argument_types suggestion

This makes the "remove extra arguement" suggestion valid when the function argument is a macro.

Additionally, this may fix #96225, but the only way I can reproduce that issue is using the playground, so we will need to wait until after this is merged to ensure it's fixed.

2 years agoRollup merge of #96587 - bjorn3:refactor_backend_write, r=michaelwoerister
Yuki Okushi [Tue, 3 May 2022 05:58:57 +0000 (14:58 +0900)]
Rollup merge of #96587 - bjorn3:refactor_backend_write, r=michaelwoerister

Refactor the WriteBackendMethods and ExtraBackendMethods traits

The new interface is slightly less confusing and is easier to implement for non-LLVM backends.

2 years agoRollup merge of #93097 - GuillaumeGomez:settings-js, r=jsha
Yuki Okushi [Tue, 3 May 2022 05:58:56 +0000 (14:58 +0900)]
Rollup merge of #93097 - GuillaumeGomez:settings-js, r=jsha

Switch settings menu to full js

Since the settings can only be set when the JS is enabled, it's not really a problem. It also fixes a debate we had around the themes not being accessible easily before.

![Screenshot from 2022-01-19 23-06-59](https://user-images.githubusercontent.com/3050060/150221936-fd1a1e76-06b6-4416-a653-dbae111979ed.png)

You can test it [here](https://rustdoc.crud.net/imperio/settings-js/doc/foo/index.html).

r? ``@jsha``

2 years agoFix typo in lint levels doc
Rock Boynton [Tue, 3 May 2022 05:33:28 +0000 (22:33 -0700)]
Fix typo in lint levels doc

2 years agoUpdate library/core/src/ffi/mod.rs
Yonggang Luo [Tue, 3 May 2022 02:42:46 +0000 (10:42 +0800)]
Update library/core/src/ffi/mod.rs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2 years agoTweak wording
Esteban Kuber [Tue, 3 May 2022 02:07:47 +0000 (02:07 +0000)]
Tweak wording

2 years agoWhen suggesting to import an item, also suggest changing the path if appropriate
Esteban Küber [Sat, 23 Apr 2022 23:41:36 +0000 (16:41 -0700)]
When suggesting to import an item, also suggest changing the path if appropriate

When we don't find an item we search all of them for an appropriate
import and suggest `use`ing it. This is sometimes done for expressions
that have paths with more than one segment. We now also suggest changing
that path to work with the `use`.

Fix #95413

2 years agoAuto merge of #96580 - CAD97:E0705-no-ignore, r=michaelwoerister
bors [Tue, 3 May 2022 00:45:18 +0000 (00:45 +0000)]
Auto merge of #96580 - CAD97:E0705-no-ignore, r=michaelwoerister

Remove `ignore` from E0705 test

Spotted this, and I think this can be made to test now.

2 years agoAuto merge of #92566 - the8472:inline-tra, r=m-ou-se
bors [Mon, 2 May 2022 21:45:20 +0000 (21:45 +0000)]
Auto merge of #92566 - the8472:inline-tra, r=m-ou-se

Inline `__iterator_get_unchecked` for some iterator adapters.

This aligns the inline attributes of existing `__iterator_get_unchecked` with those of `next()` on adapters that have both.

It improves the performance of iterators using unchecked access when building in incremental mode (due to the larger CGU count?). It might negatively affect incremental compile times for better runtime results, but considering that the equivalent `next()` implementations also are `#[inline]` and usually are more complex this should be ok.

```
./x.py bench library/core -i --stage 0 --test-args bench_trusted_random_access

OLD: 119,172 ns/iter
NEW:  17,714 ns/iter
```

2 years agoMitigate impact of subtle invalid call suggestion logic
Esteban Kuber [Mon, 2 May 2022 19:11:03 +0000 (19:11 +0000)]
Mitigate impact of subtle invalid call suggestion logic

There's some subtle interaction between inferred expressions being
passed as an argument to fn calls with fewer than expected arguments. To
avoid the ICE, I'm changing indexing operations with `.get(idx)`, but
the underlying logic still needs to be audited as it was written with
the assumption that `final_arg_types` and `provided_args` have the right
length.

Address 96638.

2 years agoAuto merge of #96578 - tmiasko:chunked-bit-set-fmt, r=nnethercote
bors [Mon, 2 May 2022 18:57:32 +0000 (18:57 +0000)]
Auto merge of #96578 - tmiasko:chunked-bit-set-fmt, r=nnethercote

Fix -Zdump-mir-dataflow by implementing DebugWithContext for ChunkedBitSet

`DebugWithContext` is used to format changes to dataflow state along with MIR
in graphviz dot files. In the case of `ChunkedBitSet` it was left unimplemented,
so attempts to use `-Zdump-mir-dataflow -Zdump-mir=all` resulted in an ICE:

> thread 'rustc' panicked at 'not implemented: implement when/if needed',

Provide the missing implementation.

r? `@nnethercote`

2 years agoThis aligns the inline attributes of existing `__iterator_get_unchecked` with those...
The 8472 [Wed, 5 Jan 2022 01:22:39 +0000 (02:22 +0100)]
This aligns the inline attributes of existing `__iterator_get_unchecked` with those of `next()` on adapters that have both.

It improves the performance of iterators using unchecked access when building in incremental mode
(due to the larger CGU count?). It might negatively affect incremental compile times for better runtime results,
but considering that the equivalent `next()` implementations also are `#[inline]` and usually are more complex this
should be ok.

```
./x.py bench library/core -i --stage 0 --test-args bench_trusted_random_access

OLD: 119,172 ns/iter
NEW:  17,714 ns/iter
```

2 years agoadd benchmark
The 8472 [Wed, 5 Jan 2022 01:28:30 +0000 (02:28 +0100)]
add benchmark

2 years agoAuto merge of #96436 - petrochenkov:nowhole2, r=wesleywiser
bors [Mon, 2 May 2022 16:28:47 +0000 (16:28 +0000)]
Auto merge of #96436 - petrochenkov:nowhole2, r=wesleywiser

linker: Stop using whole-archive on dependencies of dylibs

https://github.com/rust-lang/rust/pull/95604 implemented a better and more fine-grained way of keeping exported symbols alive.

Addresses the second question from https://github.com/rust-lang/rust/pull/93901#issuecomment-1041325522.
r? `@wesleywiser`

2 years agoUse a yes/no enum instead of a bool.
Oli Scherer [Mon, 2 May 2022 15:36:48 +0000 (15:36 +0000)]
Use a yes/no enum instead of a bool.

The bool's meaning wasn't obvious to me at some call sites.

2 years agoFix typo in `offset_from` documentation
Adrian Palacios [Mon, 2 May 2022 14:41:21 +0000 (14:41 +0000)]
Fix typo in `offset_from` documentation

2 years agoAuto merge of #96431 - petrochenkov:parent, r=cjgillot
bors [Mon, 2 May 2022 14:03:20 +0000 (14:03 +0000)]
Auto merge of #96431 - petrochenkov:parent, r=cjgillot

rustc: Panic by default in `DefIdTree::parent`

Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.

2 years agoAuto merge of #96310 - bertptrs:remove-debugger-bootstrap, r=Mark-Simulacrum
bors [Mon, 2 May 2022 11:22:29 +0000 (11:22 +0000)]
Auto merge of #96310 - bertptrs:remove-debugger-bootstrap, r=Mark-Simulacrum

Remove DebbugerScripts from bootstrap CLI

This PR implements #95992 and removes the debugger scripts from the bootstrap CLI.

I could not find a lot of documentation on the bootstrap binary so perhaps there's still some documentation to be updated.

2 years agoremove the special case for nonexported macro_rules! macros
Yoshiki Matsuda [Mon, 2 May 2022 09:50:54 +0000 (18:50 +0900)]
remove the special case for nonexported macro_rules! macros

2 years agoFix invalid keyword order for function declarations
Ken Matsui [Mon, 2 May 2022 09:14:43 +0000 (18:14 +0900)]
Fix invalid keyword order for function declarations

2 years agoAuto merge of #96596 - scottmcm:limited-calloc, r=Mark-Simulacrum
bors [Mon, 2 May 2022 09:05:22 +0000 (09:05 +0000)]
Auto merge of #96596 - scottmcm:limited-calloc, r=Mark-Simulacrum

Tweak the vec-calloc runtime check to only apply to shortish-arrays

r? `@Mark-Simulacrum`

`@nbdd0121` pointed out in https://github.com/rust-lang/rust/pull/95362#issuecomment-1114085395 that LLVM currently doesn't constant-fold the `IsZero` check for long arrays, so that seems like a reasonable justification for limiting it.

It appears that it's based on length, not byte size, (https://godbolt.org/z/4s48Y81dP), so that's what I used in the PR.  Maybe it's a ["the number of inlining shall be three"](https://youtu.be/s4wnuiCwTGU?t=320) sort of situation.

Certainly there's more that could be done here -- that generated code that checks long arrays byte-by-byte is highly suboptimal, for example -- but this is an easy, low-risk tweak.

2 years agoAvoid use of `rand::thread_rng` in stdlib benchmarks
Thom Chiovoloni [Mon, 2 May 2022 06:10:56 +0000 (23:10 -0700)]
Avoid use of `rand::thread_rng` in stdlib benchmarks

2 years agoRemove DebbugerScripts from bootstrap CLI
Bert Peters [Fri, 22 Apr 2022 06:49:58 +0000 (08:49 +0200)]
Remove DebbugerScripts from bootstrap CLI

2 years agoAuto merge of #96600 - c410-f3r:z-errors, r=petrochenkov
bors [Mon, 2 May 2022 05:52:01 +0000 (05:52 +0000)]
Auto merge of #96600 - c410-f3r:z-errors, r=petrochenkov

Move some tests to more reasonable places

cc https://github.com/rust-lang/rust/issues/73494
r? `@petrochenkov`

16602 -> `codegen` because of https://github.com/rust-lang/rust/issues/16602#issuecomment-53806665

2 years agoTweak the calloc optimization to only apply to shortish-arrays
Scott McMurray [Sun, 1 May 2022 07:16:16 +0000 (00:16 -0700)]
Tweak the calloc optimization to only apply to shortish-arrays

2 years agoopenbsd: unbreak build on native platform
Sébastien Marie [Mon, 2 May 2022 04:55:04 +0000 (04:55 +0000)]
openbsd: unbreak build on native platform

after #95612, only linux and windows target are build with -Zunstable-options,
but others platforms might use -Csplit-debuginfo

add "openbsd" target in the list of platforms using it.

2 years agoAuto merge of #96622 - JohnTitor:rollup-8hckgaj, r=JohnTitor
bors [Mon, 2 May 2022 03:28:14 +0000 (03:28 +0000)]
Auto merge of #96622 - JohnTitor:rollup-8hckgaj, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #94126 (Classify BinaryHeap & LinkedList unit tests as such)
 - #96222 (Clarify docs for `from_raw_parts` on `Vec` and `String`)
 - #96499 (Make it possible to write doctests for bootstrap)
 - #96567 (Fix docs for u32 and i32 logs func)
 - #96568 (std::fmt: Various fixes and improvements to documentation)
 - #96571 (Add a bathroom stall to weird expressions test)
 - #96610 (Update browser-ui-test version to 0.9.0)

Failed merges:

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

2 years agoAdd comment
Austin Kiekintveld [Mon, 2 May 2022 02:07:36 +0000 (19:07 -0700)]
Add comment

2 years agoFix formatting
Austin Kiekintveld [Mon, 2 May 2022 02:02:28 +0000 (19:02 -0700)]
Fix formatting

2 years agoRollup merge of #96610 - GuillaumeGomez:update-browser-ui-test, r=notriddle
Yuki Okushi [Mon, 2 May 2022 01:41:59 +0000 (10:41 +0900)]
Rollup merge of #96610 - GuillaumeGomez:update-browser-ui-test, r=notriddle

Update browser-ui-test version to 0.9.0

It adds the command `screenshot` and disables the screenshot comparison by default.

r? `@notriddle`

2 years agoRollup merge of #96571 - thomcc:bathroom-stall, r=Mark-Simulacrum
Yuki Okushi [Mon, 2 May 2022 01:41:59 +0000 (10:41 +0900)]
Rollup merge of #96571 - thomcc:bathroom-stall, r=Mark-Simulacrum

Add a bathroom stall to weird expressions test

2 years agoRollup merge of #96568 - EliasHolzmann:fmt_doc_fixes, r=joshtriplett
Yuki Okushi [Mon, 2 May 2022 01:41:58 +0000 (10:41 +0900)]
Rollup merge of #96568 - EliasHolzmann:fmt_doc_fixes, r=joshtriplett

std::fmt: Various fixes and improvements to documentation

This PR contains the following changes:

- **Added argument index comments to examples for specifying precision**

  The examples for specifying the precision have comments explaining which
  argument the specifier is referring to. However, for implicit positional
  arguments, the examples simply refer to "next arg". To simplify following the
  comments, "next arg" was supplemented with the actual resulting argument index.

- **Fixed documentation for specifying precision via `.*`**

  The documentation stated that in case of the syntax `{<arg>:<spec>.*}`, "the
  `<arg>` part refers to the value to print, and the precision must come in the
  input preceding `<arg>`". This is not correct: the <arg> part does indeed refer
  to the value to print, but the precision does not come in the input preciding
  arg, but in the next implicit input (as if specified with {}).

  Fixes #96413.

- **Fix the grammar documentation**

  According to the grammar documented, the format specifier `{: }` should not be
  legal because of the whitespace it contains. However, in reality, this is
  perfectly fine because the actual implementation allows spaces before the
  closing brace. Fixes #71088.

  Also, the exact meaning of most of the terminal symbols was not specified, for
  example the meaning of `identifier`.

- **Removed reference to Formatter::buf and other private fields**

  Formatter::buf is not a public field and therefore isn't very helpful in user-
  facing documentation. Also, the other public fields of Formatter were removed
  during stabilization of std::fmt (4af3494bb0) and can only be accessed via
  getters.

- **Improved list of formatting macros**

  Two improvements:
  1. write! can not only receive a `io::Write`, but also a `fmt::Write` as first argument.
  2. The description texts now contain links to the actual macros for easier
     navigation.

2 years agoRollup merge of #96567 - alex-semenyuk:fix_docs_for_logs_func, r=Mark-Simulacrum
Yuki Okushi [Mon, 2 May 2022 01:41:57 +0000 (10:41 +0900)]
Rollup merge of #96567 - alex-semenyuk:fix_docs_for_logs_func, r=Mark-Simulacrum

Fix docs for u32 and i32 logs func

Closes #96545

2 years agoRollup merge of #96499 - jyn514:bootstrap-doctests, r=Mark-Simulacrum
Yuki Okushi [Mon, 2 May 2022 01:41:56 +0000 (10:41 +0900)]
Rollup merge of #96499 - jyn514:bootstrap-doctests, r=Mark-Simulacrum

Make it possible to write doctests for bootstrap

This probably isn't super useful in practice, but it was easy to fix
and avoids confusing errors about mismatched versions between beta and the default toolchain.

2 years agoRollup merge of #96222 - jmaargh:john-mark/clarify-from-raw-parts-docs, r=JohnTitor
Yuki Okushi [Mon, 2 May 2022 01:41:55 +0000 (10:41 +0900)]
Rollup merge of #96222 - jmaargh:john-mark/clarify-from-raw-parts-docs, r=JohnTitor

Clarify docs for `from_raw_parts` on `Vec` and `String`

Closes #95427

Original safety explanation for `from_raw_parts` was unclear on safety for consuming a C string. This clarifies when doing so is safe.

2 years agoRollup merge of #94126 - ssomers:alloc_prep_1, r=Mark-Simulacrum
Yuki Okushi [Mon, 2 May 2022 01:41:54 +0000 (10:41 +0900)]
Rollup merge of #94126 - ssomers:alloc_prep_1, r=Mark-Simulacrum

Classify BinaryHeap & LinkedList unit tests as such

All but one of these so-called integration test case are unit tests, just like btree's were (#75531). In addition, reunite the unit tests of linked_list that were split off during #23104 because they needed to remain unit tests (they were later moved to the separate file they are in during #63207). The two sets could remain separate files, but I opted to merge them back together, more or less in the order they used to be, apart from one duplicate name `test_split_off` and one duplicate tiny function `list_from`.

2 years agoRelax memory ordering used in SameMutexCheck
Austin Kiekintveld [Sun, 1 May 2022 23:46:19 +0000 (16:46 -0700)]
Relax memory ordering used in SameMutexCheck

`SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.

2 years agorustc: Panic by default in `DefIdTree::parent`
Vadim Petrochenkov [Mon, 25 Apr 2022 19:08:45 +0000 (22:08 +0300)]
rustc: Panic by default in `DefIdTree::parent`

Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.

2 years agorustc: Panic by default in `DefIdTree::parent`
Vadim Petrochenkov [Mon, 25 Apr 2022 19:08:45 +0000 (22:08 +0300)]
rustc: Panic by default in `DefIdTree::parent`

Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.

2 years agoAuto merge of #96517 - ferrocene:pa-files-related-to-test, r=Mark-Simulacrum
bors [Sun, 1 May 2022 22:56:11 +0000 (22:56 +0000)]
Auto merge of #96517 - ferrocene:pa-files-related-to-test, r=Mark-Simulacrum

[compiletest] Extract code to detect files related to a test into a different function

In the code that checks whether a test needs to be re-executed, compiletest checks the modification date of all the files related to the test. I need the list of files related to the test for other purposes inside compiletest, and while I could copy/paste the code `is_up_to_date` runs, that would produce incomplete results if more related files are added in the future.

This PR extracts the code to detect related files into a separate function, allowing the rest of compiletest to access the same data.

r? `@Mark-Simulacrum`

2 years agoRelax memory ordering used in `min_stack`
Austin Kiekintveld [Sun, 1 May 2022 22:55:54 +0000 (15:55 -0700)]
Relax memory ordering used in `min_stack`

`min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.

2 years agoAdd a regression test for #92305
Yuki Okushi [Sun, 1 May 2022 21:43:17 +0000 (06:43 +0900)]
Add a regression test for #92305

2 years agoAuto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez
bors [Sun, 1 May 2022 20:28:10 +0000 (20:28 +0000)]
Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez

rustdoc: Resolve doc links referring to `macro_rules` items

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

UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.

2 years agoUpdate browser-ui-test version to 0.9.0
Guillaume Gomez [Sun, 1 May 2022 19:36:19 +0000 (21:36 +0200)]
Update browser-ui-test version to 0.9.0

2 years ago* Add documentation for settings page rendering functions.
Guillaume Gomez [Sun, 1 May 2022 19:22:38 +0000 (21:22 +0200)]
* Add documentation for settings page rendering functions.
* Improve code.
* Fix some documentation argument types.
* Make settings order the same as before this PR.
* Change timeout to 0 so that browser will render it as fast as possible.

2 years agoAuto merge of #96582 - petrochenkov:finalize, r=cjgillot
bors [Sun, 1 May 2022 18:05:57 +0000 (18:05 +0000)]
Auto merge of #96582 - petrochenkov:finalize, r=cjgillot

resolve: Cleanup path resolution finalization

Some cleanup after https://github.com/rust-lang/rust/pull/95255 and https://github.com/rust-lang/rust/pull/95405.
r? `@cjgillot`

2 years agoEnable full revision in const generics ui tests
Alex Macleod [Sun, 1 May 2022 15:48:58 +0000 (16:48 +0100)]
Enable full revision in const generics ui tests

2 years agoAuto merge of #96549 - ouz-a:mir-opt, r=oli-obk
bors [Sun, 1 May 2022 15:25:16 +0000 (15:25 +0000)]
Auto merge of #96549 - ouz-a:mir-opt, r=oli-obk

Move Derefer before Retag

_Follow up work to #96116 #95857 #95649_

This moves `Derefer` before `Retag` and creates a new `LocalInfo` called `Temp` to avoid retagging created temp values.

Zulip discussion [link](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/deref.20as.20first.20and.20only.20projection)

r? `@oli-obk`

2 years agoresolve: Rename `unusable_binding` to `ignore_binding`
Vadim Petrochenkov [Sat, 30 Apr 2022 15:01:01 +0000 (18:01 +0300)]
resolve: Rename `unusable_binding` to `ignore_binding`

2 years agoresolve: Merge `last_import_segment` into `Finalize`
Vadim Petrochenkov [Sat, 30 Apr 2022 14:31:44 +0000 (17:31 +0300)]
resolve: Merge `last_import_segment` into `Finalize`

2 years agoresolve: Pass full `Finalize` in nearly all cases
Vadim Petrochenkov [Sat, 30 Apr 2022 13:57:18 +0000 (16:57 +0300)]
resolve: Pass full `Finalize` in nearly all cases

2 years agoresolve: Turn `enum Finalize` into an optional struct
Vadim Petrochenkov [Sat, 30 Apr 2022 13:26:36 +0000 (16:26 +0300)]
resolve: Turn `enum Finalize` into an optional struct

2 years agostd::fmt: Improved list of formatting macros
Elias Holzmann [Sat, 30 Apr 2022 00:41:32 +0000 (02:41 +0200)]
std::fmt: Improved list of formatting macros

Two improvements:
1. write! can not only receive a `io::Write`, but also a `fmt::Write` as first argument.
2. The description texts now contain links to the actual macros for easier
   navigation.

2 years agostd::fmt: Removed reference to Formatter::buf and other private fields
Elias Holzmann [Sat, 30 Apr 2022 00:40:39 +0000 (02:40 +0200)]
std::fmt: Removed reference to Formatter::buf and other private fields

Formatter::buf is not a public field and therefore isn't very helpful in user-
facing documentation. Also, the other public fields of Formatter were made
private during stabilization of std::fmt (4af3494bb0) and can now only be read
via accessor methods.

2 years agostd::fmt: Fix the grammar documentation
Elias Holzmann [Sat, 30 Apr 2022 00:39:59 +0000 (02:39 +0200)]
std::fmt: Fix the grammar documentation

According to the grammar documented, the format specifier `{: }` should not be
legal because of the whitespace it contains. However, in reality, this is
perfectly fine because the actual implementation allows spaces before the
closing brace. Fixes #71088.

Also, the exact meaning of most of the terminal symbols was not specified, for
example the meaning of `identifier`.

2 years agostd::fmt: Added argument index comments to examples for specifying precision
Elias Holzmann [Sat, 30 Apr 2022 00:39:27 +0000 (02:39 +0200)]
std::fmt: Added argument index comments to examples for specifying precision

The examples for specifying the precision have comments explaining which
argument the specifier is referring to. However, for implicit positional
arguments, the examples simply talk about "next arg". To make it easier for
readers to follow the comments, "next arg" was supplemented with the actual
resulting argument index.

2 years agostd::fmt: Fixed documentation for specifying precision via `.*`
Elias Holzmann [Sat, 30 Apr 2022 00:38:22 +0000 (02:38 +0200)]
std::fmt: Fixed documentation for specifying precision via `.*`

The documentation stated that in case of the syntax `{<arg>:<spec>.*}`, "the
`<arg>` part refers to the value to print, and the precision must come in the
input preceding `<arg>`". This is not correct: the <arg> part does indeed refer
to the value to print, but the precision does not come in the input preciding
arg, but in the next implicit input (as if specified with {}).

Fixes #96413.

2 years agoAuto merge of #96376 - scottmcm:do-yeet, r=oli-obk
bors [Sun, 1 May 2022 13:10:21 +0000 (13:10 +0000)]
Auto merge of #96376 - scottmcm:do-yeet, r=oli-obk

Add `do yeet` expressions to allow experimentation in nightly

Two main goals for this:
- Ensure that trait restructuring in https://github.com/rust-lang/rust/issues/84277#issuecomment-1066120333 doesn't accidentally close us off from the possibility of doing this in future, as sketched in https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#possibilities-for-yeet
- Experiment with the *existence* of syntax for this, to be able to weight the syntax-vs-library tradeoffs better than we can right now.  Notably the syntax (with `do`) and name in this PR are not intended as candidates for stabilization, but they make a good v0 PR for adding this with minimal impact to compiler maintenance or priming one possible name choice over another.

r? `@oli-obk`
The lang `second` for doing this: https://github.com/rust-lang/lang-team/issues/160#issuecomment-1107896716

Tracking issues
- Lang, https://github.com/rust-lang/rust/issues/96373
- Libs-api, https://github.com/rust-lang/rust/issues/96374

2 years agoUse reverse postorder in `non_ssa_locals`
Tomasz Miąsko [Sun, 1 May 2022 00:00:00 +0000 (00:00 +0000)]
Use reverse postorder in `non_ssa_locals`

The reverse postorder, unlike preorder, is now cached inside the MIR
body. Code generation uses reverse postorder anyway, so it might be
a small perf improvement to use it here as well.

2 years agore-name stuff
ouz-a [Sun, 1 May 2022 12:38:22 +0000 (15:38 +0300)]
re-name stuff

2 years agoMove some tests to more reasonable places
Caio [Sun, 1 May 2022 11:47:38 +0000 (08:47 -0300)]
Move some tests to more reasonable places

2 years agoAuto merge of #96576 - oli-obk:post_monomorphization_error_backtrace, r=lqd
bors [Sun, 1 May 2022 10:29:39 +0000 (10:29 +0000)]
Auto merge of #96576 - oli-obk:post_monomorphization_error_backtrace, r=lqd

Also report the call site of PME errors locally.

Note this does not produce a full stack all the way to the first call that specifies all monomorphic parameters, it's just shallowly mentioning the last call site.

previous work: https://github.com/rust-lang/rust/pull/85633
tracking issue: https://github.com/rust-lang/rust/issues/85155

r? `@lqd`

I figured we could get some improvement for traces in local crates without going into the backtrace hell you landed in last time

2 years agoUpdate `RValue::Discriminant` documentation
Tomasz Miąsko [Sun, 1 May 2022 00:00:00 +0000 (00:00 +0000)]
Update `RValue::Discriminant` documentation

`RValue::Discriminant` returns zero for types without discriminant.
This guarantee is already documented for `discriminant_value`
intrinsics which is implemented in terms of `RValue::Discriminant`.

2 years agoAuto merge of #96078 - udoprog:refcounted-str-to-u8, r=dtolnay
bors [Sun, 1 May 2022 06:41:59 +0000 (06:41 +0000)]
Auto merge of #96078 - udoprog:refcounted-str-to-u8, r=dtolnay

Implement str to [u8] conversion for refcounted containers

This seems motivated to complete the APIs for shared containers since we already have similar allocation-free conversions for strings like `From<Box<[u8]>> for Box<str>`.

Insta-stable since it's a new trait impl?

2 years agoBump shared_from_str to Rust 1.62.0
David Tolnay [Sun, 1 May 2022 06:40:35 +0000 (23:40 -0700)]
Bump shared_from_str to Rust 1.62.0

2 years agoAuto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum
bors [Sun, 1 May 2022 03:18:53 +0000 (03:18 +0000)]
Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum

Make [e]println macros eagerly drop temporaries (for backport)

This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434.

My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61.

argument position | before #94868 | after #94868 | after this PR
--- |:---:|:---:|:---:
`write!($tmp, "…", …)` | :rage: | :rage: | :rage:
`write!(…, "…", $tmp)` | :rage: | :rage: | :rage:
`writeln!($tmp, "…", …)` | :rage: | :rage: | :rage:
`writeln!(…, "…", $tmp)` | :rage: | :rage: | :rage:
`print!("…", $tmp)` | :rage: | :rage: | :rage:
`println!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat:
`eprint!("…", $tmp)` | :rage: | :rage: | :rage:
`eprintln!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat:
`panic!("…", $tmp)` | :smiley_cat: | :smiley_cat: | :smiley_cat:

2 years agoimprove identity_op
tamaron [Fri, 22 Apr 2022 01:39:38 +0000 (10:39 +0900)]
improve identity_op

fix

Update identity_op.rs

ok

update without_loop_counters test

chore

fix

chore

remove visitor and leftmost

fix

add document

2 years agoRevert "Bless coverage-reports after core macro blocks change"
David Tolnay [Sun, 1 May 2022 01:25:17 +0000 (18:25 -0700)]
Revert "Bless coverage-reports after core macro blocks change"

This reverts commit ac5c657a0801db84b29ea9b3ae322107756575b0.

2 years agoFeature-gate `do yeet` inside `cfg`s too
Scott McMurray [Wed, 27 Apr 2022 02:49:00 +0000 (19:49 -0700)]
Feature-gate `do yeet` inside `cfg`s too

2 years agoBless the UI tests
Scott McMurray [Mon, 25 Apr 2022 02:59:23 +0000 (19:59 -0700)]
Bless the UI tests

2 years agoAuto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum
bors [Sun, 1 May 2022 00:50:46 +0000 (00:50 +0000)]
Auto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum

Support arrays of zeros in Vec's __rust_alloc_zeroed optimization

I happened to notice in https://users.rust-lang.org/t/any-advantage-of-box-u64-16-16-16-over-vec-u64/73500/3?u=scottmcm that the calloc optimization wasn't applying to vectors-of-arrays, so here's the easy fix for that.

2 years agoFix the clippy build
Scott McMurray [Mon, 25 Apr 2022 02:08:23 +0000 (19:08 -0700)]
Fix the clippy build

2 years agoFix the rustfmt build
Scott McMurray [Mon, 25 Apr 2022 02:25:30 +0000 (19:25 -0700)]
Fix the rustfmt build

2 years agoFix the clippy build
Scott McMurray [Mon, 25 Apr 2022 02:08:23 +0000 (19:08 -0700)]
Fix the clippy build

2 years agoAdd `do yeet` expressions to allow experimentation in nightly
Scott McMurray [Sat, 26 Mar 2022 06:43:54 +0000 (23:43 -0700)]
Add `do yeet` expressions to allow experimentation in nightly

Using an obviously-placeholder syntax.  An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point.

But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.

2 years agoAuto merge of #93815 - camsteffen:intravisit-docs, r=cjgillot
bors [Sat, 30 Apr 2022 21:24:53 +0000 (21:24 +0000)]
Auto merge of #93815 - camsteffen:intravisit-docs, r=cjgillot

Update intravisit docs

Follow-up to #90986.

r? `@cjgillot`