]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agorustdoc-json: Make the `fns/generics.rs` test much more robust
Nixon Enraght-Moony [Fri, 25 Feb 2022 19:34:00 +0000 (20:34 +0100)]
rustdoc-json: Make the `fns/generics.rs` test much more robust

2 years agorustdoc-json: Include GenericParamDefKind::Type::synthetic in JSON
Martin Nordholts [Sat, 19 Feb 2022 08:50:35 +0000 (09:50 +0100)]
rustdoc-json: Include GenericParamDefKind::Type::synthetic in JSON

The rustdoc JSON for

```
pub fn f(_: impl Clone) {}
```

will effectively be

```
pub fn f<impl Clone: Clone>(_: impl Clone)
```

where a synthetic generic parameter called `impl Clone` with generic
trait bound `Clone` is added to the function declaration.

The generated HTML filters out these generic parameters by doing
`self.params.iter().filter(|p| !p.is_synthetic_type_param())`, because
the synthetic generic parameter is not of interest to regular users.

For the same reason, we should expose whether or not a generic parameter
is synthetic or not also in the rustdoc JSON, so that rustdoc JSON
clients can also have the option to hide synthetic generic parameters.

2 years agoAuto merge of #94009 - compiler-errors:gat-rustdoc, r=GuillaumeGomez
bors [Fri, 4 Mar 2022 00:27:23 +0000 (00:27 +0000)]
Auto merge of #94009 - compiler-errors:gat-rustdoc, r=GuillaumeGomez

Support GATs in Rustdoc

Implements:
1. Rendering GATs in trait definitions and impl blocks
2. Rendering GATs in types (e.g. in the return type of a function)

Fixes #92341

This is my first rustdoc PR, so I have absolutely no idea how to produce tests for this. Advice from the rustdoc team would be wonderful!

I tested locally and things looked correct:
![image](https://user-images.githubusercontent.com/3674314/153988325-9732cbf3-0645-4e1a-9e64-ddfd93877b55.png)

2 years agoAuto merge of #94571 - matthiaskrgr:rollup-4ul5ydb, r=matthiaskrgr
bors [Thu, 3 Mar 2022 21:40:28 +0000 (21:40 +0000)]
Auto merge of #94571 - matthiaskrgr:rollup-4ul5ydb, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #92697 (Use cgroup quotas for calculating `available_parallelism`)
 - #94057 (improve comments for `simplify_type`)
 - #94547 (`parse_tt` cleanups)
 - #94550 (rustdoc: Add test for higher kinded functions generated by macros)
 - #94551 (Doc: Fix use of quote instead of backstick in Adapter::map.)
 - #94554 (Fix invalid lint_node_id being put on a removed stmt)
 - #94555 (all: fix some typos)
 - #94563 (Remove a unnecessary `..` pattern)

Failed merges:

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

2 years agoadd tests
Michael Goulet [Sun, 20 Feb 2022 03:34:05 +0000 (19:34 -0800)]
add tests

2 years agodon't forget generics for GATs in impls
Michael Goulet [Tue, 15 Feb 2022 03:06:08 +0000 (19:06 -0800)]
don't forget generics for GATs in impls

2 years agomake generic projection types print correctly
Michael Goulet [Tue, 15 Feb 2022 03:01:56 +0000 (19:01 -0800)]
make generic projection types print correctly

2 years agoRollup merge of #94563 - TaKO8Ki:remove-unnecessary-patten-for-ignoring-remaining...
Matthias Krüger [Thu, 3 Mar 2022 19:01:49 +0000 (20:01 +0100)]
Rollup merge of #94563 - TaKO8Ki:remove-unnecessary-patten-for-ignoring-remaining-parts, r=Dylan-DPC

Remove a unnecessary `..` pattern

2 years agoRollup merge of #94555 - cuishuang:master, r=oli-obk
Matthias Krüger [Thu, 3 Mar 2022 19:01:48 +0000 (20:01 +0100)]
Rollup merge of #94555 - cuishuang:master, r=oli-obk

all: fix some typos

Signed-off-by: cuishuang <imcusg@gmail.com>
2 years agoRollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkov
Matthias Krüger [Thu, 3 Mar 2022 19:01:48 +0000 (20:01 +0100)]
Rollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkov

Fix invalid lint_node_id being put on a removed stmt

This pull-request remove a invalid `assign_id!` being put on an stmt node.

The problem is that this node is being removed away by a cfg making it unreachable when triggering a buffered lint.
The comment in the other match arm already tell to not assign a id because it could have a `#[cfg()]` so this is just respecting the comment.

Fixes https://github.com/rust-lang/rust/issues/94523
r? ```````@petrochenkov```````

2 years agoRollup merge of #94551 - darnuria:doc-map-backstick, r=dtolnay
Matthias Krüger [Thu, 3 Mar 2022 19:01:47 +0000 (20:01 +0100)]
Rollup merge of #94551 - darnuria:doc-map-backstick, r=dtolnay

Doc: Fix use of quote instead of backstick in Adapter::map.

A little commit to fix documentation rendering and semantics in https://doc.rust-lang.org/std/iter/struct.Map.html#notes-about-side-effects `"` where used around an expression instead \`.

Screenshot on doc.rust-lang.org:
![2022-03-03 11-21-43_backstick](https://user-images.githubusercontent.com/2827553/156546536-569b7692-7ac4-4388-8e93-c1628ddc6a0f.png)

Looking forward: Maybe reworking the doc to use assert_eq like the upper paragraph:
```
let v: Vec<i32> = vec![1, 2, 3].into_iter().map(|x| x + 1).rev().collect();

assert_eq!(v, [4, 3, 2]);
```

2 years agoRollup merge of #94550 - GuillaumeGomez:HKF-macros, r=notriddle
Matthias Krüger [Thu, 3 Mar 2022 19:01:46 +0000 (20:01 +0100)]
Rollup merge of #94550 - GuillaumeGomez:HKF-macros, r=notriddle

rustdoc: Add test for higher kinded functions generated by macros

Fixes #75564.

The problem has been solved apparently so adding a test to prevent a regression.

r? ```@notriddle```

2 years agoRollup merge of #94547 - nnethercote:parse_tt-cleanups, r=petrochenkov
Matthias Krüger [Thu, 3 Mar 2022 19:01:45 +0000 (20:01 +0100)]
Rollup merge of #94547 - nnethercote:parse_tt-cleanups, r=petrochenkov

`parse_tt` cleanups

I've been looking closely at this code, and saw some opportunities to improve its readability.

r? ```````@petrochenkov```````

2 years agoRollup merge of #94057 - lcnr:simplify_type-uwu, r=nikomatsakis
Matthias Krüger [Thu, 3 Mar 2022 19:01:44 +0000 (20:01 +0100)]
Rollup merge of #94057 - lcnr:simplify_type-uwu, r=nikomatsakis

improve comments for `simplify_type`

Should now correctly describe what's going on. Experimented with checking the invariant for projections
but that ended up requiring fairly involved changes. I assume that it is not possible to get unsoundness here,
at least for now and I can pretty much guarantee that it's impossible to trigger it by accident.

r? `````@nikomatsakis````` cc #92721

2 years agoRollup merge of #92697 - the8472:cgroups, r=joshtriplett
Matthias Krüger [Thu, 3 Mar 2022 19:01:43 +0000 (20:01 +0100)]
Rollup merge of #92697 - the8472:cgroups, r=joshtriplett

Use cgroup quotas for calculating `available_parallelism`

Automated tests for this are possible but would require a bunch of assumptions. It requires root + a recent kernel, systemd and maybe docker. And even then it would need a helper binary since the test has to run in a separate process.

Limitations

* only supports cgroup v2 and assumes it's mounted under `/sys/fs/cgroup`
* procfs must be available
* the quota gets mixed into `sched_getaffinity`, so if the latter doesn't work then quota information gets ignored too

Manually tested via

```
// spawn a new cgroup scope for the current user
$ sudo systemd-run -p CPUQuota="300%" --uid=$(id -u) -tdS

// quota.rs
#![feature(available_parallelism)]
fn main() {
    println!("{:?}", std::thread::available_parallelism()); // prints Ok(3)
}
```

strace:

```
sched_getaffinity(3041643, 32, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) = 32
openat(AT_FDCWD, "/proc/self/cgroup", O_RDONLY|O_CLOEXEC) = 3
statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address)
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = 0
read(3, "0::/system.slice/run-u31477.serv"..., 128) = 36
read(3, "", 92)                         = 0
close(3)                                = 0
statx(AT_FDCWD, "/sys/fs/cgroup/system.slice/run-u31477.service/cgroup.controllers", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=0, ...}) = 0
openat(AT_FDCWD, "/sys/fs/cgroup/system.slice/run-u31477.service/cpu.max", O_RDONLY|O_CLOEXEC) = 3
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = 0
read(3, "300000 100000\n", 20)          = 14
read(3, "", 6)                          = 0
close(3)                                = 0
openat(AT_FDCWD, "/sys/fs/cgroup/system.slice/cpu.max", O_RDONLY|O_CLOEXEC) = 3
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = 0
read(3, "max 100000\n", 20)             = 11
read(3, "", 9)                          = 0
close(3)                                = 0
openat(AT_FDCWD, "/sys/fs/cgroup/cpu.max", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
sched_getaffinity(0, 128, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) = 40
```

r? ```````@joshtriplett```````
cc ```````@yoshuawuyts```````

Tracking issue and previous discussion: #74479

2 years agoAuto merge of #87835 - xFrednet:rfc-2383-expect-attribute-with-ids, r=wesleywiser
bors [Thu, 3 Mar 2022 18:59:32 +0000 (18:59 +0000)]
Auto merge of #87835 - xFrednet:rfc-2383-expect-attribute-with-ids, r=wesleywiser

Implementation of the `expect` attribute (RFC 2383)

This is an implementation of the `expect` attribute as described in [RFC-2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html). The attribute allows the suppression of lint message by expecting them. Unfulfilled lint expectations (meaning no expected lint was caught) will emit the `unfulfilled_lint_expectations` lint at the `expect` attribute.

### Example
#### input
```rs
// required feature flag
#![feature(lint_reasons)]

#[expect(unused_mut)] // Will warn about an unfulfilled expectation
#[expect(unused_variables)] // Will be fulfilled by x
fn main() {
    let x = 0;
}
```

#### output

```txt
warning: this lint expectation is unfulfilled
  --> $DIR/trigger_lint.rs:3:1
   |
LL | #[expect(unused_mut)] // Will warn about an unfulfilled expectation
   |          ^^^^^^^^^^
   |
   = note: `#[warn(unfulfilled_lint_expectations)]` on by default
```

### Implementation

This implementation introduces `Expect` as a new lint level for diagnostics, which have been expected. All lint expectations marked via the `expect` attribute are collected in the [`LintLevelsBuilder`] and assigned an ID that is stored in the new lint level. The `LintLevelsBuilder` stores all found expectations and the data needed to emit the `unfulfilled_lint_expectations` in the [`LintLevelsMap`] which is the result of the [`lint_levels()`] query.

The [`rustc_errors::HandlerInner`] is the central error handler in rustc and handles the emission of all diagnostics. Lint message with the level `Expect` are suppressed during this emission, while the expectation ID is stored in a set which marks them as fulfilled. The last step is then so simply check if all expectations collected by the [`LintLevelsBuilder`] in the [`LintLevelsMap`] have been marked as fulfilled in the [`rustc_errors::HandlerInner`]. Otherwise, a new lint message will be emitted.

The implementation of the `LintExpectationId` required some special handling to make it stable between sessions. Lints can be emitted during [`EarlyLintPass`]es. At this stage, it's not possible to create a stable identifier. The level instead stores an unstable identifier, which is later converted to a stable `LintExpectationId`.

### Followup TO-DOs
All open TO-DOs have been marked with `FIXME` comments in the code. This is the combined list of them:

* [ ] The current implementation doesn't cover cases where the `unfulfilled_lint_expectations` lint is actually expected by another `expect` attribute.
   * This should be easily possible, but I wanted to get some feedback before putting more work into this.
   * This could also be done in a new PR to not add to much more code to this one
* [ ] Update unstable documentation to reflect this change.
* [ ] Update unstable expectation ids in [`HandlerInner::stashed_diagnostics`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.HandlerInner.html#structfield.stashed_diagnostics)

### Open questions
I also have a few open questions where I would like to get feedback on:
1. The RFC discussion included a suggestion to change the `expect` attribute to something else. (Initiated by `@Ixrec` [here](https://github.com/rust-lang/rfcs/pull/2383#issuecomment-378424091), suggestion from `@scottmcm` to use `#[should_lint(...)]` [here](https://github.com/rust-lang/rfcs/pull/2383#issuecomment-378648877)). No real conclusion was drawn on that point from my understanding. Is this still open for discussion, or was this discarded with the merge of the RFC?
2. How should the expect attribute deal with the new `force-warn` lint level?

---

This approach was inspired by a discussion with `@LeSeulArtichaut.`

RFC tracking issue: #54503

Mentoring/Implementation issue: #85549

[`LintLevelsBuilder`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/levels/struct.LintLevelsBuilder.html
[`LintLevelsMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/struct.LintLevelMap.html
[`lint_levels()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.lint_levels
[`rustc_errors::HandlerInner`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.HandlerInner.html
[`EarlyLintPass`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html

2 years agoremove a unnecessary `..` pattern
Takayuki Maeda [Thu, 3 Mar 2022 15:57:38 +0000 (00:57 +0900)]
remove a unnecessary `..` pattern

2 years agoAuto merge of #84944 - lcnr:obligation-dedup, r=jackh726
bors [Thu, 3 Mar 2022 15:43:42 +0000 (15:43 +0000)]
Auto merge of #84944 - lcnr:obligation-dedup, r=jackh726

remove obligation dedup from `impl_or_trait_obligations`

Looking at the examples from #38528 they all seem to compile fine even without this and it seems like this might be unnecessary effort

2 years agoAuto merge of #94512 - RalfJung:sdiv-ub, r=oli-obk
bors [Thu, 3 Mar 2022 12:56:24 +0000 (12:56 +0000)]
Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obk

Miri/CTFE: properly treat overflow in (signed) division/rem as UB

To my surprise, it looks like LLVM treats overflow of signed div/rem as UB. From what I can tell, MIR `Div`/`Rem` directly lowers to the corresponding LLVM operation, so to make that correct we also have to consider these overflows UB in the CTFE/Miri interpreter engine.

r? `@oli-obk`

2 years agoall: fix some typos
cuishuang [Thu, 3 Mar 2022 11:47:23 +0000 (19:47 +0800)]
all: fix some typos

Signed-off-by: cuishuang <imcusg@gmail.com>
2 years agoFix invalid lint_node_id being put on a removed stmt
Loïc BRANSTETT [Thu, 3 Mar 2022 10:52:09 +0000 (11:52 +0100)]
Fix invalid lint_node_id being put on a removed stmt

2 years agoChange `initial_matcher_pos()` into `MatcherPos::new()`.
Nicholas Nethercote [Thu, 3 Mar 2022 01:14:27 +0000 (12:14 +1100)]
Change `initial_matcher_pos()` into `MatcherPos::new()`.

2 years agoUse a better return type for `inner_parse_loop`.
Nicholas Nethercote [Thu, 3 Mar 2022 00:10:21 +0000 (11:10 +1100)]
Use a better return type for `inner_parse_loop`.

Because `inner_parse_loop` has only one way to not succeed, not three.

2 years agoIntroduce `MatcherPosRepetition`.
Nicholas Nethercote [Thu, 3 Mar 2022 00:04:04 +0000 (11:04 +1100)]
Introduce `MatcherPosRepetition`.

There are three `Option` fields in `MatcherPos` that are only used in
tandem. This commit combines them, making the code slightly easier to
read. (It also makes clear that the `sep` field arguably should have
been `Option<Option<Token>>`!)

2 years agoAdd a static size assertion for `MatcherPos`.
Nicholas Nethercote [Thu, 3 Mar 2022 00:02:43 +0000 (11:02 +1100)]
Add a static size assertion for `MatcherPos`.

2 years agoImprove if/else formatting in macro_parser.rs.
Nicholas Nethercote [Thu, 3 Mar 2022 00:00:50 +0000 (11:00 +1100)]
Improve if/else formatting in macro_parser.rs.

To avoid the strange style where comments force `else` onto its own
line.

The commit also removes several else-after-return constructs, which can
be hard to read.

2 years agoAdd test for higher kinded functions generated by macros
Guillaume Gomez [Thu, 3 Mar 2022 10:32:07 +0000 (11:32 +0100)]
Add test for higher kinded functions generated by macros

2 years agoDoc: Fix use of quote instead of backstick in Adapter::map.
Axel Viala [Thu, 3 Mar 2022 10:25:01 +0000 (11:25 +0100)]
Doc: Fix use of quote instead of backstick in Adapter::map.

2 years agoAuto merge of #94548 - matthiaskrgr:rollup-spa38z8, r=matthiaskrgr
bors [Thu, 3 Mar 2022 10:14:04 +0000 (10:14 +0000)]
Auto merge of #94548 - matthiaskrgr:rollup-spa38z8, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #93562 (Update the documentation for `{As,Into,From}Raw{Fd,Handle,Socket}`.)
 - #94101 (rustdoc: add test cases for hidden enum variants)
 - #94484 (8 - Make more use of `let_chains`)
 - #94522 (Remove out-of-context line at end of E0284 message)
 - #94534 (Re-export (unstable) core::ffi types from std::ffi)
 - #94536 (Move transmute_undefined_repr back to nursery again)
 - #94537 (Use ? operator in one instance instead of manual match)
 - #94544 (Add some examples to comments in mbe code)

Failed merges:

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

2 years agoRollup merge of #94544 - mark-i-m:macro-comments, r=petrochenkov
Matthias Krüger [Thu, 3 Mar 2022 10:02:56 +0000 (11:02 +0100)]
Rollup merge of #94544 - mark-i-m:macro-comments, r=petrochenkov

Add some examples to comments in mbe code

I found these things non-obvious when re-familiarizing myself with the code.

r? `@petrochenkov`

2 years agoRollup merge of #94537 - est31:master, r=notriddle
Matthias Krüger [Thu, 3 Mar 2022 10:02:55 +0000 (11:02 +0100)]
Rollup merge of #94537 - est31:master, r=notriddle

Use ? operator in one instance instead of manual match

As suggested [here](https://github.com/rust-lang/rust/pull/94139#discussion_r818102403).

r? `@notriddle`

2 years agoRollup merge of #94536 - dtolnay:transmute, r=Manishearth
Matthias Krüger [Thu, 3 Mar 2022 10:02:54 +0000 (11:02 +0100)]
Rollup merge of #94536 - dtolnay:transmute, r=Manishearth

Move transmute_undefined_repr back to nursery again

This PR reapplies #94014, which was reverted unintentionally I think by #94329. The combination of https://github.com/rust-lang/rust-clippy/pull/8432 + https://github.com/rust-lang/rust-clippy/pull/8497 in clippy should prevent this from happening again.

r? `@Manishearth`

2 years agoRollup merge of #94534 - bstrie:cffistd, r=Mark-Simulacrum
Matthias Krüger [Thu, 3 Mar 2022 10:02:53 +0000 (11:02 +0100)]
Rollup merge of #94534 - bstrie:cffistd, r=Mark-Simulacrum

Re-export (unstable) core::ffi types from std::ffi

2 years agoRollup merge of #94522 - thinety:fix-e0284-message, r=Dylan-DPC
Matthias Krüger [Thu, 3 Mar 2022 10:02:52 +0000 (11:02 +0100)]
Rollup merge of #94522 - thinety:fix-e0284-message, r=Dylan-DPC

Remove out-of-context line at end of E0284 message

Removed the last line of E0284 message because it was out of context (probably kept by accident when changing whole error message).

2 years agoRollup merge of #94484 - c410-f3r:more-let-chains, r=jackh726
Matthias Krüger [Thu, 3 Mar 2022 10:02:51 +0000 (11:02 +0100)]
Rollup merge of #94484 - c410-f3r:more-let-chains, r=jackh726

8 - Make more use of `let_chains`

Continuation of #94376.

cc #53667

2 years agoRollup merge of #94101 - notriddle:notriddle/strip-test-cases, r=GuillaumeGomez
Matthias Krüger [Thu, 3 Mar 2022 10:02:50 +0000 (11:02 +0100)]
Rollup merge of #94101 - notriddle:notriddle/strip-test-cases, r=GuillaumeGomez

rustdoc: add test cases for hidden enum variants

2 years agoRollup merge of #93562 - sunfishcode:sunfishcode/io-docs, r=joshtriplett
Matthias Krüger [Thu, 3 Mar 2022 10:02:49 +0000 (11:02 +0100)]
Rollup merge of #93562 - sunfishcode:sunfishcode/io-docs, r=joshtriplett

Update the documentation for `{As,Into,From}Raw{Fd,Handle,Socket}`.

This change weakens the descriptions of the
`{as,into,from}_raw_{fd,handle,socket}` descriptions from saying that
they *do* express ownership relations to say that they are *typically used*
in ways that express ownership relations. This is needed since, for
example, std's own [`RawFd`] implements `{As,From,Into}Fd` without any of
the ownership relationships.

This adds proper `# Safety` comments to `from_raw_{fd,handle,socket}`,
adds the requirement that raw handles be not opened with the
`FILE_FLAG_OVERLAPPED` flag, and merges the `OwnedHandle::from_raw_handle`
comment into the main `FromRawHandle::from_raw_handle` comment.

And, this changes `HandleOrNull` and `HandleOrInvalid` to not implement
`FromRawHandle`, since they are intended for limited use in FFI situations,
and not for generic use, and they have constraints that are stronger than
the those of `FromRawHandle`.

[`RawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/type.RawFd.html

2 years agoAuto merge of #94541 - Dylan-DPC:rollup-564wbq3, r=Dylan-DPC
bors [Thu, 3 Mar 2022 04:28:08 +0000 (04:28 +0000)]
Auto merge of #94541 - Dylan-DPC:rollup-564wbq3, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #92061 (update char signess for openbsd)
 - #93072 (Compatible variants suggestion with desugaring)
 - #93354 (Add documentation about `BorrowedFd::to_owned`.)
 - #93663 (Rename `BorrowedFd::borrow_raw_fd` to `BorrowedFd::borrow_raw`.)
 - #94375 (Adt copy suggestions)
 - #94433 (Improve allowness of the unexpected_cfgs lint)
 - #94499 (Documentation was missed when demoting Windows XP to no_std only)
 - #94505 (Restore the local filter on mono item sorting)
 - #94529 (Unused doc comments blocks)

Failed merges:

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

2 years agoadd some examples to comments in mbe code
mark [Thu, 3 Mar 2022 03:33:43 +0000 (21:33 -0600)]
add some examples to comments in mbe code

2 years agoRemove the comment about `FILE_FLAG_OVERLAPPED`.
Dan Gohman [Thu, 3 Mar 2022 00:25:31 +0000 (16:25 -0800)]
Remove the comment about `FILE_FLAG_OVERLAPPED`.

There may eventually be something to say about `FILE_FLAG_OVERLAPPED` here,
however this appears to be independent of the other changes in this PR,
so remove them from this PR so that it can be discussed separately.

2 years agobless clippy
Ralf Jung [Thu, 3 Mar 2022 00:20:27 +0000 (19:20 -0500)]
bless clippy

2 years agoRollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebank
Dylan DPC [Thu, 3 Mar 2022 00:09:15 +0000 (01:09 +0100)]
Rollup merge of #94529 - GuillaumeGomez:unused-doc-comments-blocks, r=estebank

Unused doc comments blocks

Fixes #77030.

2 years agoRollup merge of #94505 - cuviper:mono-item-sort-local, r=michaelwoerister,davidtwco
Dylan DPC [Thu, 3 Mar 2022 00:09:14 +0000 (01:09 +0100)]
Rollup merge of #94505 - cuviper:mono-item-sort-local, r=michaelwoerister,davidtwco

Restore the local filter on mono item sorting

In `CodegenUnit::items_in_deterministic_order`, there's a comment that
only local HirIds should be taken into account, but #90408 removed the
`as_local` call that sets others to None. Restoring that check fixes the
s390x hangs seen in [RHBZ 2058803].

[RHBZ 2058803]: https://bugzilla.redhat.com/show_bug.cgi?id=2058803

2 years agoRollup merge of #94499 - RandomInsano:patch-1, r=Dylan-DPC
Dylan DPC [Thu, 3 Mar 2022 00:09:13 +0000 (01:09 +0100)]
Rollup merge of #94499 - RandomInsano:patch-1, r=Dylan-DPC

Documentation was missed when demoting Windows XP to no_std only

After a quick discussion on #81250 which removed special casing for mutexes added [here](https://github.com/rust-lang/rust/commit/10b103af48368c5df644fa61dc417a36083922c8) to support Windows XP, we can't say that the standard library can build for it.

This change modifies the tier 3 non-ARM targets to show the standard library will no longer build for these and there is no work being done to change that.

2 years agoRollup merge of #94433 - Urgau:check-cfg-allowness, r=petrochenkov
Dylan DPC [Thu, 3 Mar 2022 00:09:12 +0000 (01:09 +0100)]
Rollup merge of #94433 - Urgau:check-cfg-allowness, r=petrochenkov

Improve allowness of the unexpected_cfgs lint

This pull-request improve the allowness (`#[allow(...)]`) of the `unexpected_cfgs` lint.

Before this PR only crate level `#![allow(unexpected_cfgs)]` worked, now with this PR it also work when put around `cfg!` or if it is in a upper level. Making it work ~for the attributes `cfg`, `cfg_attr`, ...~ for the same level is awkward as the current code is design to give "Some parent node that is close to this macro call" (cf. https://doc.rust-lang.org/nightly/nightly-rustc/rustc_expand/base/struct.ExpansionData.html) meaning that allow on the same line as an attribute won't work. I'm note even sure if this would be possible.

Found while working on https://github.com/rust-lang/rust/pull/94298.
r? ````````@petrochenkov````````

2 years agoRollup merge of #94375 - WaffleLapkin:copy-suggestion, r=estebank
Dylan DPC [Thu, 3 Mar 2022 00:09:11 +0000 (01:09 +0100)]
Rollup merge of #94375 - WaffleLapkin:copy-suggestion, r=estebank

Adt copy suggestions

Previously we've only suggested adding `Copy` bounds when the type being moved/copied is a type parameter (generic). With this PR we also suggest adding bounds when a type
- Can be copy
- All predicates that need to be satisfied for that are based on type params

i.e. we will suggest `T: Copy` for `Option<T>`, but won't suggest anything for `Option<String>`.

An example:
```rust
fn duplicate<T>(t: Option<T>) -> (Option<T>, Option<T>) {
    (t, t)
}
```
New error (current compiler doesn't provide `help`:):
```text
error[E0382]: use of moved value: `t`
 --> t.rs:2:9
  |
1 | fn duplicate<T>(t: Option<T>) -> (Option<T>, Option<T>) {
  |                 - move occurs because `t` has type `Option<T>`, which does not implement the `Copy` trait
2 |     (t, t)
  |      -  ^ value used here after move
  |      |
  |      value moved here
  |
help: consider restricting type parameter `T`
  |
1 | fn duplicate<T: Copy>(t: Option<T>) -> (Option<T>, Option<T>) {
  |               ++++++
```

Fixes #93623
r? ``````````@estebank``````````
``````````@rustbot`````````` label +A-diagnostics +A-suggestion-diagnostics +C-enhancement

----

I'm not at all sure if this is the right implementation for this kind of suggestion, but it seems to work :')

2 years agoRollup merge of #93663 - sunfishcode:sunfishcode/as-raw-name, r=joshtriplett
Dylan DPC [Thu, 3 Mar 2022 00:09:10 +0000 (01:09 +0100)]
Rollup merge of #93663 - sunfishcode:sunfishcode/as-raw-name, r=joshtriplett

Rename `BorrowedFd::borrow_raw_fd` to `BorrowedFd::borrow_raw`.

Also, rename `BorrowedHandle::borrow_raw_handle` and
`BorrowedSocket::borrow_raw_socket` to `BorrowedHandle::borrow_raw` and
`BorrowedSocket::borrow_raw`.

This is just a minor rename to reduce redundancy in the user code calling
these functions, and to eliminate an inessential difference between
`BorrowedFd` code and `BorrowedHandle`/`BorrowedSocket` code.

While here, add a simple test exercising `BorrowedFd::borrow_raw_fd`.

r? ``````@joshtriplett``````

2 years agoRollup merge of #93354 - sunfishcode:sunfishcode/document-borrowedfd-toowned, r=josht...
Dylan DPC [Thu, 3 Mar 2022 00:09:09 +0000 (01:09 +0100)]
Rollup merge of #93354 - sunfishcode:sunfishcode/document-borrowedfd-toowned, r=joshtriplett

Add documentation about `BorrowedFd::to_owned`.

Following up on #88564, this adds documentation explaining why
`BorrowedFd::to_owned` returns another `BorrowedFd` rather than an
`OwnedFd`. And similar for `BorrowedHandle` and `BorrowedSocket`.

r? `````@joshtriplett`````

2 years agoRollup merge of #93072 - m-ou-se:compatible-variants-suggestion-with-desugaring,...
Dylan DPC [Thu, 3 Mar 2022 00:09:08 +0000 (01:09 +0100)]
Rollup merge of #93072 - m-ou-se:compatible-variants-suggestion-with-desugaring, r=estebank

Compatible variants suggestion with desugaring

This fixes #90553 for `for` loops and other desugarings.

r? ```@estebank```

2 years agoRollup merge of #92061 - semarie:openbsd-archs, r=joshtriplett
Dylan DPC [Thu, 3 Mar 2022 00:09:07 +0000 (01:09 +0100)]
Rollup merge of #92061 - semarie:openbsd-archs, r=joshtriplett

update char signess for openbsd

it adds more archs support for openbsd: arm, mips64, powerpc, powerpc64, and riscv64.

2 years agoupdate available_parallelism docs since cgroups and sched_getaffinity are now taken...
The 8472 [Wed, 2 Mar 2022 23:36:23 +0000 (00:36 +0100)]
update available_parallelism docs since cgroups and sched_getaffinity are now taken into account

2 years agohardcode /sys/fs/cgroup instead of doing a lookup via mountinfo
The 8472 [Wed, 2 Mar 2022 23:35:47 +0000 (00:35 +0100)]
hardcode /sys/fs/cgroup instead of doing a lookup via mountinfo

this avoids parsing mountinfo which can be huge on some systems and
something might be emulating cgroup fs for sandboxing reasons which means
it wouldn't show up as mountpoint

additionally the new implementation operates on a single pathbuffer, reducing allocations

2 years agoUse cgroup quotas for calculating `available_parallelism`
The 8472 [Sun, 9 Jan 2022 18:39:02 +0000 (19:39 +0100)]
Use cgroup quotas for calculating `available_parallelism`

Manually tested via

```
// spawn a new cgroup scope for the current user
$ sudo systemd-run -p CPUQuota="300%" --uid=$(id -u) -tdS

// quota.rs
#![feature(available_parallelism)]
fn main() {
    println!("{:?}", std::thread::available_parallelism()); // prints Ok(3)
}
```

Caveats

* cgroup v1 is ignored
* funky mountpoints (containing spaces, newlines or control chars) for cgroupfs will not be handled correctly since that would require unescaping /proc/self/mountinfo
  The escaping behavior of procfs seems to be undocumented. systemd and docker default to `/sys/fs/cgroup` so it should be fine for most systems.
* quota will be ignored when `sched_getaffinity` doesn't work
* assumes procfs is mounted under `/proc` and cgroupfs mounted and readable somewhere in the directory tree

2 years agoUse ? operator in one instance instead of manual match
est31 [Wed, 2 Mar 2022 21:10:35 +0000 (22:10 +0100)]
Use ? operator in one instance instead of manual match

2 years agoMove transmute_undefined_repr back to nursery
flip1995 [Tue, 15 Feb 2022 09:54:38 +0000 (10:54 +0100)]
Move transmute_undefined_repr back to nursery

There's still open discussion if this lint is ready to be enabled by
default. We want to give us more time to figure this out and prevent
this lint from getting to stable as an enabled-by-default lint.

2 years agoFix a broken doc link on Windows.
Dan Gohman [Wed, 2 Mar 2022 20:39:36 +0000 (12:39 -0800)]
Fix a broken doc link on Windows.

2 years agoAuto merge of #92214 - ehuss:submodule-bg-exit, r=Mark-Simulacrum
bors [Wed, 2 Mar 2022 19:50:55 +0000 (19:50 +0000)]
Auto merge of #92214 - ehuss:submodule-bg-exit, r=Mark-Simulacrum

Error if submodule fetch fails.

In CI, if fetching a submodule fails, the script would exit successfully. Later parts of the build will fail due to the missing files, but it is a bit confusing, and I think it would be better to error out earlier.

The reason is that in bash, `wait` without arguments will exit 0 even if a background job exits with an error. The solution here is to wait on each individual job, which will return the exit code of the job.

This was encountered in #92177.

2 years agoUpdate stdarch submodule
Guillaume Gomez [Wed, 2 Mar 2022 18:50:08 +0000 (19:50 +0100)]
Update stdarch submodule

2 years agoUpdate unused_doc_comments ui test
Guillaume Gomez [Wed, 2 Mar 2022 16:58:49 +0000 (17:58 +0100)]
Update unused_doc_comments ui test

2 years agoFix unused_doc_comments lint errors
Guillaume Gomez [Wed, 2 Mar 2022 16:58:33 +0000 (17:58 +0100)]
Fix unused_doc_comments lint errors

2 years ago8 - Make more use of `let_chains`
Caio [Wed, 2 Mar 2022 19:02:37 +0000 (16:02 -0300)]
8 - Make more use of `let_chains`

2 years agoRe-export core::ffi types from std::ffi
bstrie [Wed, 2 Mar 2022 18:52:31 +0000 (13:52 -0500)]
Re-export core::ffi types from std::ffi

2 years agoUpdate test output.
Mara Bos [Wed, 2 Mar 2022 18:30:25 +0000 (19:30 +0100)]
Update test output.

2 years agoAdd more tests for mismatched Option/Result return types.
Mara Bos [Wed, 19 Jan 2022 12:11:48 +0000 (13:11 +0100)]
Add more tests for mismatched Option/Result return types.

2 years agoFix Ok(()) suggestion when desugaring is involved.
Mara Bos [Wed, 19 Jan 2022 12:11:26 +0000 (13:11 +0100)]
Fix Ok(()) suggestion when desugaring is involved.

2 years agoUse Vec for expectations to have a constant order (RFC-2383)
xFrednet [Wed, 2 Mar 2022 17:10:07 +0000 (18:10 +0100)]
Use Vec for expectations to have a constant order (RFC-2383)

2 years agoExtend unused_doc_comments lint to check on blocks
Guillaume Gomez [Wed, 2 Mar 2022 16:58:10 +0000 (17:58 +0100)]
Extend unused_doc_comments lint to check on blocks

2 years agoAddress review comments
xFrednet [Fri, 18 Feb 2022 11:00:16 +0000 (12:00 +0100)]
Address review comments

2 years agoAdded `panics` for unreachable states for expectations (RFC 2383)
xFrednet [Thu, 25 Nov 2021 20:59:55 +0000 (21:59 +0100)]
Added `panics` for unreachable states for expectations (RFC 2383)

2 years agoEmit `unfullfilled_lint_expectation` using a `HirId` for performance (RFC-2383)
xFrednet [Thu, 25 Nov 2021 16:45:11 +0000 (17:45 +0100)]
Emit `unfullfilled_lint_expectation` using a `HirId` for performance (RFC-2383)

2 years agoReduced the size of `LintExpectationId` by 12 bytes (RFC-2383)
xFrednet [Wed, 24 Nov 2021 22:21:10 +0000 (23:21 +0100)]
Reduced the size of `LintExpectationId` by 12 bytes (RFC-2383)

2 years agoTest `expect` with `forbid` and fix doc errors (RFC-2383)
xFrednet [Thu, 25 Nov 2021 09:45:25 +0000 (10:45 +0100)]
Test `expect` with `forbid` and fix doc errors (RFC-2383)

* Add test to expect and the forbid a lint (RFC 2383)

2 years agoExpect each lint in attribute individually (RFC-2383)
xFrednet [Wed, 24 Nov 2021 20:57:38 +0000 (21:57 +0100)]
Expect each lint in attribute individually (RFC-2383)

2 years agoAdd UI tests for the `expect` attribute (RFC-2383)
xFrednet [Fri, 6 Aug 2021 21:38:09 +0000 (23:38 +0200)]
Add UI tests for the `expect` attribute (RFC-2383)

* Add UI tests with macros for the `expect` attribute (RFC-2383)
* Addressed review comments - mostly UI test updates (RFC-2383)
* Documented lint level attribute on macro not working bug (RFC-2383)
  See `rust#87391`

2 years agoMake `LintExpectationId` stable between compilation sessions (RFC-2383)
xFrednet [Sat, 20 Nov 2021 19:45:27 +0000 (20:45 +0100)]
Make `LintExpectationId` stable between compilation sessions (RFC-2383)

2 years agoCheck lint expectations and emit lint if unfulfilled (RFC-2383)
xFrednet [Fri, 6 Aug 2021 21:36:33 +0000 (23:36 +0200)]
Check lint expectations and emit lint if unfulfilled (RFC-2383)

2 years agoSet `LintExpectationId` in level and collect fulfilled ones (RFC-2383)
xFrednet [Fri, 6 Aug 2021 21:28:58 +0000 (23:28 +0200)]
Set `LintExpectationId` in level and collect fulfilled ones (RFC-2383)

* Collect lint expectations and set expectation ID in level (RFC-2383)
* Collect IDs of fulfilled lint expectations from diagnostics (RFC 2383)

2 years agoAdded `unfulfilled_lint_expectations` lint for (RFC-2383)
xFrednet [Fri, 6 Aug 2021 21:23:34 +0000 (23:23 +0200)]
Added `unfulfilled_lint_expectations` lint for (RFC-2383)

2 years agoAdded `Expect` lint level and attribute (RFC-2383)
xFrednet [Fri, 6 Aug 2021 21:18:16 +0000 (23:18 +0200)]
Added `Expect` lint level and attribute (RFC-2383)

* Also added the `LintExpectationId` which will be used in future commits

2 years agoAuto merge of #93244 - mark-i-m:doomed, r=oli-obk
bors [Wed, 2 Mar 2022 16:13:38 +0000 (16:13 +0000)]
Auto merge of #93244 - mark-i-m:doomed, r=oli-obk

Rename `ErrorReported` -> `ErrorGuaranteed`

r? `@eddyb`

cc https://github.com/rust-lang/rust/pull/93222 https://github.com/rust-lang/rust/issues/69426

The idea is that we would like to use it for both errors and `delay_span_bug`. Its semantics indicate a _guarantee_ that compilation will fail.

2 years agorename ErrorReported -> ErrorGuaranteed
mark [Sun, 23 Jan 2022 18:34:26 +0000 (12:34 -0600)]
rename ErrorReported -> ErrorGuaranteed

2 years agoRemove out-of-context line at end of E0284 message
Thiago Trannin [Wed, 2 Mar 2022 13:09:02 +0000 (10:09 -0300)]
Remove out-of-context line at end of E0284 message

2 years agomerge the char signess list of archs with freebsd as it is the same
Sébastien Marie [Wed, 2 Mar 2022 12:12:28 +0000 (12:12 +0000)]
merge the char signess list of archs with freebsd as it is the same

2 years agoupdate char signess for openbsd
Sébastien Marie [Wed, 2 Mar 2022 10:33:50 +0000 (10:33 +0000)]
update char signess for openbsd

adds more archs for openbsd: arm, mips64, powerpc, powerpc64, and riscv64.

2 years agoAuto merge of #94229 - erikdesjardins:rem2, r=nikic
bors [Wed, 2 Mar 2022 08:48:33 +0000 (08:48 +0000)]
Auto merge of #94229 - erikdesjardins:rem2, r=nikic

Remove LLVM attribute removal

This was necessary before, because `declare_raw_fn` would always apply
the default optimization attributes to every declared function.
Then `attributes::from_fn_attrs` would have to remove the default
attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build.
(see [`src/test/codegen/optimize-attr-1.rs`](https://github.com/rust-lang/rust/blob/03a8cc7df1d65554a4d40825b0490c93ac0f0236/src/test/codegen/optimize-attr-1.rs#L33))

However, every relevant callsite of `declare_raw_fn` (i.e. where we
actually generate code for the function, and not e.g. a call to an
intrinsic, where optimization attributes don't [?] matter)
calls `from_fn_attrs`, so we can remove the attribute setting
from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct
attributes all at once.

r? `@ghost` (blocked on #94221)
`@rustbot` label S-blocked

2 years agoAuto merge of #94514 - matthiaskrgr:rollup-pdzn82h, r=matthiaskrgr
bors [Wed, 2 Mar 2022 05:32:00 +0000 (05:32 +0000)]
Auto merge of #94514 - matthiaskrgr:rollup-pdzn82h, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #94464 (Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls.)
 - #94476 (7 - Make more use of `let_chains`)
 - #94478 (Fix panic when handling intra doc links generated from macro)
 - #94482 (compiler: fix some typos)
 - #94490 (Update books)
 - #94496 (tests: accept llvm intrinsic in align-checking test)
 - #94498 (9 - Make more use of `let_chains`)
 - #94503 (Provide C FFI types via core::ffi, not just in std)
 - #94513 (update Miri)

Failed merges:

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

2 years agoRollup merge of #94513 - RalfJung:miri, r=RalfJung
Matthias Krüger [Wed, 2 Mar 2022 03:30:13 +0000 (04:30 +0100)]
Rollup merge of #94513 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/94474
r? `@ghost`

2 years agoRollup merge of #94503 - joshtriplett:core-ffi-c, r=Amanieu
Matthias Krüger [Wed, 2 Mar 2022 03:30:12 +0000 (04:30 +0100)]
Rollup merge of #94503 - joshtriplett:core-ffi-c, r=Amanieu

Provide C FFI types via core::ffi, not just in std

Tracking issue: https://github.com/rust-lang/rust/issues/94501

The ability to interoperate with C code via FFI is not limited to crates
using std; this allows using these types without std.

The existing types in `std::os::raw` become type aliases for the ones in
`core::ffi`. This uses type aliases rather than re-exports, to allow the
std types to remain stable while the core types are unstable.

This also moves the currently unstable `NonZero_` variants and
`c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving
them unstable.

Historically, we didn't do this because these types are target-dependent.
However, `core` itself is also target-dependent. `core` should not call
any OS services, but it knows the target and the target's ABI.

2 years agoRollup merge of #94498 - c410-f3r:chega-ja-deu, r=Dylan-DPC
Matthias Krüger [Wed, 2 Mar 2022 03:30:11 +0000 (04:30 +0100)]
Rollup merge of #94498 - c410-f3r:chega-ja-deu, r=Dylan-DPC

9 - Make more use of `let_chains`

Continuation of #94376.

cc #53667

2 years agoRollup merge of #94496 - durin42:llvm-15-moar-intrinsic, r=nikic
Matthias Krüger [Wed, 2 Mar 2022 03:30:10 +0000 (04:30 +0100)]
Rollup merge of #94496 - durin42:llvm-15-moar-intrinsic, r=nikic

tests: accept llvm intrinsic in align-checking test

This changed in upstream change https://reviews.llvm.org/D98152 (aka
https://github.com/llvm/llvm-project/commit/a266af721153fab6452094207b09ed265ab0be7b)
wherein LLVM got smarter about using intrinsics. As best I can tell the
change I've made here preserves the intent of the test on LLVM 14 and
before while also passing on LLVM 15 and later.

2 years agoRollup merge of #94490 - ehuss:update-books, r=ehuss
Matthias Krüger [Wed, 2 Mar 2022 03:30:10 +0000 (04:30 +0100)]
Rollup merge of #94490 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in 90993eeac93dbf9388992de92965f99cf6f29a03..f6d6126fc96ecf4a7f7d22da330df9506293b0d0
2022-02-13 12:44:12 +0900 to 2022-02-26 02:21:21 +0900
- ffi: explicitly declare hello_from_rust for C99 (rust-lang/nomicon#343)

## reference

20 commits in 70fc73a6b908e08e66aa0306856c5211312f6c05..9d289c05fce7254b99c6a0d354d84abb7fd7a032
2022-02-14 19:33:01 -0800 to 2022-02-23 08:58:20 -0800
- Fix typo in `functions.md` (rust-lang/reference#1173)
- Fix CI
- Unify global_asm/asm directive list
- Update src/inline-assembly.md
- Update src/inline-assembly.md
- Fix changes unintentional reverted in d5d3d80
- Add note about operand interpolations
- Sort lists, add syntax control directives
- Add another missed batch suggestion
- Add missed batch suggestion
- Apply suggestions from code review
- Add .type, .size, and .p2align
- Reformat directive lists
- Add `.inst` directive
- Add missing directives
- Add additional directives in use
- Add `.fill` directive
- Style fixes
- Fix code block
- Add supported Directives list

## book

13 commits in 67b768c0b660a069a45f0e5d8ae2f679df1022ab..3f255ed40b8c82a0434088568fbed270dc31bf00
2022-02-09 21:52:41 -0500 to 2022-02-27 21:26:12 -0500
- Add a back reference about enum variant initializer fns. Fixes rust-lang/book#800.
- Update ch01-03-hello-cargo.md
- ch03-05: Add definite article for the block of code
- Change variable names from "slice" to "values"
- Remove reference to advanced lifetime section that no longer exists
- Fix link to go to the right newtype section
- Remove confusing and redundant part of a sentence about newtypes
- Make transition less repetitive
- Correct wording about associated functions.
- Remove unnecessary extern crate proc_macro
- Clarify that this code is defining, not using a procedural macro
- Add manual regeneration steps for cargo new test
- Update Listing 11-1 to reflect current contents

## rust-by-example

11 commits in 18c0055b8aea49391e8f758a4400097999c9cf1e..2a928483a20bb306a7399c0468234db90d89afb5
2022-01-19 08:51:55 -0300 to 2022-02-28 11:36:59 -0300
- Update destructure_slice.md (rust-lang/rust-by-example#1513)
- Update iter_find.md (rust-lang/rust-by-example#1512)
- Add an example of collecting errors while iterating successes (rust-lang/rust-by-example#1509)
- Fix broken link on asm (rust-lang/rust-by-example#1508)
- Update abort_unwind.md (rust-lang/rust-by-example#1505)
- Remove duplicate text in asm.md (rust-lang/rust-by-example#1506)
- Improve asm clobber example (rust-lang/rust-by-example#1504)
- Add +1 to next_age (rust-lang/rust-by-example#1503)
- fix comment on into_iter() for arrays (rust-lang/rust-by-example#1502)
- Added new Rust 1.58 direct format args (rust-lang/rust-by-example#1501)
- documentation for cfg_panic (rust-lang/rust-by-example#1500)

## rustc-dev-guide

13 commits in 62f58394ba7b203f55ac35ddcc4c0b79578f5706..32f2a5b4e7545318846185198542230170dd8a42
2022-02-11 08:42:50 -0500 to 2022-03-01 10:45:24 -0600
- Add architecture suggestion for Apple silicon (rust-lang/rustc-dev-guide#1320)
- cargo timings has been stabilized (rust-lang/rustc-dev-guide#1319)
- Add known-bug header. (rust-lang/rustc-dev-guide#1311)
- Fix typo (rust-lang/rustc-dev-guide#1315)
- Typo (rust-lang/rustc-dev-guide#1313)
- instrument-coverage has been stabilized.
- symbol-mangling-version has been stabilized
- Fix `Ty` link (rust-lang/rustc-dev-guide#1308)
- Edit glossary (rust-lang/rustc-dev-guide#1302)
- Fix heading levels in the query chapter (rust-lang/rustc-dev-guide#1305)
- Fix link
- Edit "Queries" chapter (rust-lang/rustc-dev-guide#1301)
- Link to The Rust Performance Book (rust-lang/rustc-dev-guide#1300)

## edition-guide

1 commits in beea0a3cdc3885375342fd010f9ad658e6a5e09a..c55611dd6c58bdeb52423b5c52fd0f3c93615ba8
2021-12-05 07:06:45 -0800 to 2022-02-21 14:21:39 +0100
- Remove `+nightly` for `cargo new` (rust-lang/edition-guide#276)

2 years agoRollup merge of #94482 - cuishuang:master, r=Dylan-DPC
Matthias Krüger [Wed, 2 Mar 2022 03:30:09 +0000 (04:30 +0100)]
Rollup merge of #94482 - cuishuang:master, r=Dylan-DPC

compiler: fix some typos

2 years agoRollup merge of #94478 - GuillaumeGomez:macro-generated-intra-doc-link, r=notriddle
Matthias Krüger [Wed, 2 Mar 2022 03:30:08 +0000 (04:30 +0100)]
Rollup merge of #94478 - GuillaumeGomez:macro-generated-intra-doc-link, r=notriddle

Fix panic when handling intra doc links generated from macro

Fixes #78591.
Fixes #92789.

r? ``@notriddle``

2 years agoRollup merge of #94476 - c410-f3r:yet-more-let-chains, r=Dylan-DPC
Matthias Krüger [Wed, 2 Mar 2022 03:30:06 +0000 (04:30 +0100)]
Rollup merge of #94476 - c410-f3r:yet-more-let-chains, r=Dylan-DPC

7 - Make more use of `let_chains`

Continuation of #94376.

cc #53667

2 years agoRollup merge of #94464 - kckeiks:lifetime-elision-mismatch-hint-for-traits, r=estebank
Matthias Krüger [Wed, 2 Mar 2022 03:30:04 +0000 (04:30 +0100)]
Rollup merge of #94464 - kckeiks:lifetime-elision-mismatch-hint-for-traits, r=estebank

Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls.

Suggest adding a new lifetime parameter when two elided lifetimes should match up for functions in traits and impls.

Issue #94462

2 years agoAuto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, r=estebank
bors [Wed, 2 Mar 2022 03:03:22 +0000 (03:03 +0000)]
Auto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, r=estebank

Direct users towards using Rust target feature names in CLI

This PR consists of a couple of changes on how we handle target features.

In particular there is a bug-fix wherein we avoid passing through features that aren't prefixed by `+` or `-` to LLVM. These appear to be causing LLVM to assert, which is pretty poor a behaviour (and also makes it pretty clear we expect feature names to be prefixed).

The other commit, I anticipate to be somewhat more controversial is outputting a warning when users specify a LLVM-specific, or otherwise unknown, feature name on the CLI. In those situations we request users to either replace it with a known Rust feature name (e.g. `bmi` -> `bmi1`) or file a feature request. I've a couple motivations for this: first of all, if users are specifying these features on the command line, I'm pretty confident there is also a need for these features to be usable via `#[cfg(target_feature)]` machinery.  And second, we're growing a fair number of backends recently and having ability to provide some sort of unified-ish interface in this place seems pretty useful to me.

Sponsored by: standard.ai

2 years agoupdate Miri
Ralf Jung [Wed, 2 Mar 2022 02:58:38 +0000 (21:58 -0500)]
update Miri

2 years agoMiri/CTFE: properly treat overflow in (signed) division/rem as UB
Ralf Jung [Wed, 2 Mar 2022 01:02:59 +0000 (20:02 -0500)]
Miri/CTFE: properly treat overflow in (signed) division/rem as UB

2 years agoTemporarily make `CStr` not a link in the `c_char` docs
Josh Triplett [Wed, 2 Mar 2022 01:36:40 +0000 (17:36 -0800)]
Temporarily make `CStr` not a link in the `c_char` docs

When CStr moves to core with an alias in std, this can link to
`crate::ffi::CStr`. However, linking in the reverse direction (from core
to std) requires a relative path, and that path can't work from both
core::ffi and std::os::raw (different number of `../` traversals
required).

2 years agoProvide C FFI types via core::ffi, not just in std
Josh Triplett [Tue, 1 Mar 2022 22:46:41 +0000 (14:46 -0800)]
Provide C FFI types via core::ffi, not just in std

The ability to interoperate with C code via FFI is not limited to crates
using std; this allows using these types without std.

The existing types in `std::os::raw` become type aliases for the ones in
`core::ffi`. This uses type aliases rather than re-exports, to allow the
std types to remain stable while the core types are unstable.

This also moves the currently unstable `NonZero_` variants and
`c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving
them unstable.