Rollup of 6 pull requests
Successful merges:
- #59823 ([wg-async-await] Drop `async fn` arguments in async block )
- #59839 (Warn on unused results for operation methods on nums)
- #60146 (Update fonts used by rustdoc)
- #60169 (Warn when ignore-tidy-linelength is present, but no lines are too long)
- #60177 (Promote rust comments to rustdoc)
- #60191 (Add f16c target_feature)
Failed merges:
r? @ghost
Warn when ignore-tidy-linelength is present, but no lines are too long
It's easy for a `// ignore-tidy-linelength` to be added when there is a genuine need to ignore a file's line length, but then after refactoring the need is gone, but the tidy directive is not removed. This means that in the future, further editing may accidentally add unnecessarily long lines. This change forces `// ignore-tidy-linelength` to be used exactly when necessary, to make sure such changes are intentional.
Update fonts used by rustdoc
Our version of Source Serif Pro is pretty old and is causing issues on Linux, see https://bugzilla.mozilla.org/show_bug.cgi?id=1545317 . I took this opportunity to update all of the fonts we use.
r? @steveklabnik @QuietMisdreavus
Warn on unused results for operation methods on nums
From a suggestion by @llogiq
Adds a `#[must_use]` attribute to operation methods on integers that take self by value as the first operand and another value as the second. It makes it clear that these methods return the result of the operation instead of mutating `self`, which is the source of a rather embarrassing bug I had in a codebase of mine recently...
As an example:
```rust
struct Int {
value: i64,
}
impl Int {
fn add(&mut self, other: i64) {
self.value.wrapping_add(other);
}
}
```
Will produce a warning like:
```
warning: unused return value of `core::num::<impl i64>::wrapping_add` that must be used
--> src/main.rs:7:7
|
7 | self.value.wrapping_add(other);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_must_use)] on by default
= note: this returns the result of the operation, without modifying the original
```
If this is something we're on board with, we could do something similar for `f32` and `f64` too. There are probably other methods on integers that make sense.
[wg-async-await] Drop `async fn` arguments in async block
Fixes#54716.
This PR modifies the HIR lowering (and some other places to make this work) so that unused arguments to a async function are always dropped inside the async move block and not at the end of the function body.
```
async fn foo(<pattern>: <type>) {
async move {
}
} // <-- dropped as you "exit" the fn
// ...becomes...
fn foo(__arg0: <ty>) {
async move {
let <pattern>: <ty> = __arg0;
} // <-- dropped as you "exit" the async block
}
```
However, the exact ordering of drops is not the same as a regular function, [as visible in this playground example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=be39af1a58e5d430be1eb3c722cb1ec3) - I believe this to be an unrelated issue. There is a [Zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/187312-t-compiler.2Fwg-async-await/topic/.2354716.20drop.20order) for this.
r? @cramertj
cc @nikomatsakis
This commit introduces a `assert_drop_order_after_poll` helper function
to the test case for this case to reduce repetitive noise and documents
what each function aims to test.
Remove `visit_subpats` parameter from `check_pat`
The core idea is to keep track of current ID directly in `EllipsisInclusiveRangePatterns` struct and early return in `check_pat` based on it.
Fixes https://github.com/rust-lang/rust/issues/60043.
r? @varkor
Don't stop evaluating due to errors before borrow checking
r? @oli-obk
Fix#60005. Follow up to #59903. Blocked on #53708, fixing the ICE in `src/test/ui/consts/match_ice.rs`.
Disallow double trailing newlines in tidy
This wasn't done previously in https://github.com/rust-lang/rust/pull/47064#issuecomment-354533010 as it affected too many files, but I think it's best to fix it now so that the number of files with double trailing newlines doesn't keep increasing.
r? kennytm
Fix sync_all on macos/ios
`sync_all` should flush all metadata in macos/ios, so it should call `fcntl` with the `F_FULLFSYNC` flag as `sync_data` does.
Note that without this `sync_data` performs more flushes than `sync_all` on macos/ios.
This commit makes the suggestion to dereference when a type implements
`Deref` only apply if the dereference would succeed (ie. the type is
`Copy`, otherwise a borrow check error would occur).
Add a tidy check for leading newlines
This is fairly uncommon, but it can slip through when refactoring (as evidenced by the files with leading newlines here).
Enable NLL migrate mode on the 2015 edition
## What is in this PR?
* Remove the `-Zborrowck=ast` flag option from rustc.
* The default in the 2015 edition is now `-Zborrowck=migrate`.
* The 2018 edition default is unchanged: it's still `-Zborrowck=migrate`.
* Enable two-phase borrows (currently toggled via the `-Ztwo-phase-borrows` flag) on all editions.
* Remove most dead code that handled these options.
* Update tests for the above changes.
## What is *not* in this PR?
These are left for future PRs
* Use `-Zborrowck=mir` in NLL compare mode tests (#56993)
* Remove the `-Zborrowck=compare` option (#59193)
* Remove the `-Ztwo-phase-borrows` flag. It's kept, as a flag that does nothing so that perf.rlo has time to stop using it (cc @Mark-Simulacrum)
* Remove MIR typeck as its own MIR pass - it's now run by NLL.
* Enabling `-Zborrowck=mir` by default (#58781)
* Replace `allow_bind_by_move_patterns_with_guards` and `check_for_mutation_in_guard_via_ast_walk` with just using the feature gate. (#59192)
Soundness issues that are fixed by NLL will stay open until full NLL is emitting hard errors. However, these diagnostics and completeness issues can now be closed:
Closes#18330Closes#22323Closes#23591Closes#26736Closes#27487Closes#28092Closes#28970Closes#29733Closes#30104Closes#38915Closes#39908Closes#43407Closes#47524Closes#48540Closes#49073Closes#52614Closes#55085Closes#56093Closes#56496Closes#57804
cc #43234
r? @pnkfelix
cc @rust-lang/lang
cc @rust-lang/wg-compiler-nll