Commit Graph

128923 Commits

Author SHA1 Message Date
Dylan DPC
b73f1c77a7
Rollup merge of #97254 - jhpratt:remove-crate-vis, r=cjgillot
Remove feature: `crate` visibility modifier

FCP completed in #53120.
2022-05-23 07:43:50 +02:00
bors
c186f7c079 Auto merge of #96455 - dtolnay:writetmp, r=m-ou-se
Make write/print macros eagerly drop temporaries

This PR fixes the 2 regressions in #96434 (`println` and `eprintln`) and changes all the other similar macros (`write`, `writeln`, `print`, `eprint`) to match the old pre-#94868 behavior of `println` and `eprintln`.

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

Example of code that is affected by this change:

```rust
use std::sync::Mutex;

fn main() {
    let mutex = Mutex::new(0);
    print!("{}", mutex.lock().unwrap()) /* no semicolon */
}
```

You can see several real-world examples like this in the Crater links at the top of #96434. This code failed to compile prior to this PR as follows, but works after this PR.

```console
error[E0597]: `mutex` does not live long enough
 --> src/main.rs:5:18
  |
5 |     print!("{}", mutex.lock().unwrap()) /* no semicolon */
  |                  ^^^^^^^^^^^^---------
  |                  |
  |                  borrowed value does not live long enough
  |                  a temporary with access to the borrow is created here ...
6 | }
  | -
  | |
  | `mutex` dropped here while still borrowed
  | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard`
```
2022-05-23 02:50:50 +00:00
David Tolnay
a6100988ff
Fix clippy explicit_write lint for new writeln implementation 2022-05-22 17:39:56 -07:00
David Tolnay
ae29890ab6
Add test of temporaries inside format_args of core/std macros 2022-05-22 16:11:08 -07:00
Jack Huey
383fbeec63 Use revisions for NLL in lifetimes 2022-05-22 15:21:27 -04:00
Jack Huey
fe91cfd684 Use revisions for NLL in suggestions 2022-05-22 15:21:27 -04:00
Jack Huey
b391b329f0 Use revisions for NLL in issues 2022-05-22 15:21:27 -04:00
Jack Huey
b7c192e346 Use revisions for NLL in hrtb 2022-05-22 15:21:27 -04:00
Jack Huey
b16bd7c3e2 Use revisions for NLL in traits 2022-05-22 15:21:27 -04:00
Jack Huey
34a3154bd9 Use revisions for NLL in async-await 2022-05-22 15:21:27 -04:00
Jack Huey
0fbb315be7 Use revisions or ignore-compare-mode-nll for NLL in generic-associated-types 2022-05-22 15:21:27 -04:00
Jack Huey
62806f7536 Use revisions for NLL in generator 2022-05-22 15:21:27 -04:00
Jack Huey
12a2d7967c Use revisions for NLL in various directories 2022-05-22 15:21:27 -04:00
Jack Huey
99daba2a4a Use revisions for NLL in object-lifetime 2022-05-22 15:21:27 -04:00
Jack Huey
8220be5240 Use revisions for NLL in borrowck 2022-05-22 15:21:26 -04:00
Jack Huey
1e435e332e Use revisions for NLL in const-generics and match 2022-05-22 15:21:26 -04:00
Jack Huey
f1a7f9ab40 Use revisions for NLL in closures 2022-05-22 15:21:26 -04:00
Jack Huey
eb222bf943 Use revisions for NLL in associated-types 2022-05-22 15:21:26 -04:00
Jack Huey
cc97875d26 Use revisions for NLL in nll 2022-05-22 15:21:26 -04:00
Jack Huey
b9f241d407 Use revisions for NLL in impl-trait 2022-05-22 15:21:26 -04:00
Jack Huey
707d2ebb5b Use revisions for NLL (consistently) in higher-ranked-trait-bounds 2022-05-22 15:21:26 -04:00
Jack Huey
dc435ee762 For hr-subtype test, use check-pass instead of rustc_error and split nll differences to separate test 2022-05-22 15:21:26 -04:00
Jack Huey
b392cdf7de
Rollup merge of #97280 - yue4u:quote-replace-target-in-bootstrap-configure, r=Mark-Simulacrum
Quote replace target in bootstrap configure

close #97263
2022-05-22 11:37:43 -04:00
Jack Huey
b4c17d43a6
Rollup merge of #97277 - jyn514:no-unstable-for-bootstrap, r=Mark-Simulacrum
Avoid accidentally enabling unstable features in compilers (take 2)

This allows rustbuild to control whether crates can use nightly features or not.
It also prevents rustbuild from using nightly features itself.

This is #92261, but I fixed the CI error.
2022-05-22 11:37:42 -04:00
Jack Huey
4f97de8dc5
Rollup merge of #97206 - jackh726:issue-73154, r=nikomatsakis
Do leak check after function pointer coercion

cc #73154

I still need to clean diagnostics just a tad, but figured I would put this up anyways.

This change is made in order to make match arm coercion order-independent.

Basically, any time we do function pointer coercion, we follow it by doing a leak check. This is necessary because the LUB code doesn't handler higher-ranked things correctly, leading us to "coerce", but use the wrong type. A proper fix is to actually fix that code (so the type returned by `unify_and` is a supertype of both `a` and `b` if `Ok`). However, that requires a more in-depth fix, likely heavily overlapping with the new subtyping changes.

Here, I've been conservative and error early if we generate unsatisfiable constraints. Note, this should *mostly* only affect NLL, since migrate mode falls back to the LUB implementation (followed by leak check), whereas NLL only does sub.

There could be other coercion code that has an order-dependence where a leak check in the coercion code might be useful. However, this is more of a spot-fix for #73154 than a "permanent" fix, since we likely want to go the other way long-term, and allow this pattern without error.

r? `@nikomatsakis`
2022-05-22 11:37:40 -04:00
Jack Huey
41994470de
Rollup merge of #97043 - c410-f3r:z-errors, r=petrochenkov
Move some tests to more reasonable directories

r? `@petrochenkov`
2022-05-22 11:37:39 -04:00
Jack Huey
683a9c8391 Do leak check after function ptr coercion 2022-05-22 11:18:36 -04:00
Joshua Nelson
751ad4a0e9 Disable unstable features in bootstrap tools
This statically prevents issues like https://github.com/rust-lang/rust/issues/59264,
where tools can only be built with the in-tree compiler and not beta.
2022-05-22 09:44:23 -05:00
yue4u
1532fd8cd0 Quote replace target in bootstrap configure 2022-05-22 23:17:44 +09:00
Joshua Nelson
b0ea4e74cb Avoid accidentally enabling unstable features in compilers (take 2)
This allows rustbuild to control whether crates can use nightly features or not.
It also prevents rustbuild from using nightly features itself.
2022-05-22 08:31:50 -05:00
bors
653463731a Auto merge of #95563 - dingxiangfei2009:dxf-rfc66-refactor, r=nikomatsakis
Move the extended lifetime resolution into typeck context

Related to #15023

This PR is based on the [idea](https://github.com/rust-lang/rust/issues/15023#issuecomment-1070931433) of #15023 by `@nikomatsakis.`

This PR specifically proposes to
- Delay the resolution of scopes of rvalues to a later stage, so that enough type information is available to refine those scopes based on relationships of lifetimes.
- Highlight relevant parts that would help future reviews on the next installments of works to fully implement a solution to RFC 66.
2022-05-22 09:00:30 +00:00
Ding Xiang Fei
6044fbe462
factor out the rvalue lifetime rule
remove region_scope_tree from RegionCtxt

Apply suggestions from code review

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-05-22 16:46:50 +08:00
bors
acfd327fd4 Auto merge of #97177 - oli-obk:const-stability, r=davidtwco
Implement proper stability check for const impl Trait, fall back to unstable const when undeclared

Continuation of #93960

`@jhpratt` it looks to me like the test was simply not testing for the failure you were looking for? Your checks actually do the right thing for const traits?
2022-05-22 06:47:36 +00:00
Yuki Okushi
6ef4911b99
Rollup merge of #97236 - cjgillot:recover-lifetime-res, r=jackh726
Recover when resolution did not resolve lifetimes.

This can happen for items inside a foreign fn's body, which are not visited at all.

Fixes https://github.com/rust-lang/rust/issues/97193
Fixes https://github.com/rust-lang/rust/issues/97194
2022-05-22 11:53:07 +09:00
Yuki Okushi
c7c5980e90
Rollup merge of #97228 - jonhoo:patch-1, r=bjorn3
Omit stdarch workspace from rust-src

The path `library/stdarch/crates/Cargo.toml` does not exist.

In Rust 1.61.0, `rust-src` still includes `src/rust/library/stdarch/Cargo.toml` (but not `stdarch-verify`), which includes
```toml
[workspace]
members = [
  "crates/stdarch-verify"
```

This didn't show up when testing with `-Zbuild-std` in https://github.com/rust-lang/rust/pull/94907 since the [standard list of crates](f624095e1c/src/cargo/core/compiler/standard_lib.rs (L26-L30)) to include when building `std` does not include `stdarch`, but it will show up if a user explicitly requests `stdarch`. Or, perhaps more importantly, because of https://github.com/rust-lang/rust/issues/95736, many editors (like IntelliJ) won't treat the root of `rust-src` as a workspace, and will instead recurse into all the sub-crates directly, which then includes `stdarch`.

Also related to https://github.com/rust-lang/rust/issues/94906.
2022-05-22 11:53:06 +09:00
bors
e52e7115c7 Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis
correctly deal with user type ascriptions in pat

supersedes #93856

`thir::PatKind::AscribeUserType` previously resulted in `CanonicalUserTypeAnnotations` where the inferred type already had a subtyping relation according to `variance` to the `user_ty`.

The bug can pretty much be summarized as follows:

- during mir building
  - `user_ty -> inferred_ty`: considers variance
  - `StatementKind::AscribeUserType`: `inferred_ty` is the type of the place, so no variance needed
- during mir borrowck
  - `user_ty -> inferred_ty`: does not consider variance
  - `StatementKind::AscribeUserType`: applies variance

This mostly worked fine. The lifetimes in `inferred_ty` were only bound by its relation to `user_ty` and to the `place` of `StatementKind::AscribeUserType`, so it doesn't matter where exactly the subtyping happens.

It does however matter when having higher ranked subtying. At this point the place where the subtyping happens is forced, causing this mismatch between building and borrowck to result in unintended errors.

cc #96514 which is pretty much the same issue

r? `@nikomatsakis`
2022-05-21 23:34:30 +00:00
Jacob Pratt
7b987e34c0
Merge crate and restricted visibilities 2022-05-21 17:02:55 -04:00
Jacob Pratt
8cece636b2
Remove feature: crate visibility modifier 2022-05-21 14:22:06 -04:00
bors
bb4781aa27 Auto merge of #97248 - xFrednet:clippyup, r=Manishearth
Clippyup

This direction was simpler. All test Clippy pass locally 🙃

r? `@Manishearth`
2022-05-21 17:25:49 +00:00
bors
74b13691aa Auto merge of #97247 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/97204
r? `@ghost`
2022-05-21 14:09:31 +00:00
lcnr
76370084fa update nll tests 2022-05-21 14:01:04 +02:00
xFrednet
6e87c2490e
Fix lint registration 2022-05-21 13:50:11 +02:00
bors
3b9cf893d0 Auto merge of #97246 - GuillaumeGomez:rollup-btcok8x, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #97190 (Add implicit call to from_str via parse in documentation)
 - #97218 (Add eslint checks)
 - #97219 (make ptr::invalid not the same as a regular int2ptr cast)
 - #97223 (Remove quadratic behaviour from -Zunpretty=hir-tree.)
 - #97232 (typo)
 - #97237 (Add some more weird-exprs)
 - #97238 (Bump LLVM fetched from CI to fix run-make)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-21 11:28:48 +00:00
xFrednet
13cc27b445
Merge 'rust-clippy/master' into clippyup 2022-05-21 13:24:00 +02:00
Ralf Jung
cb4d79a304 update Miri 2022-05-21 11:58:36 +02:00
Guillaume Gomez
28730acdbe
Rollup merge of #97238 - Mark-Simulacrum:bump-ci-llvm, r=jyn514
Bump LLVM fetched from CI to fix run-make

cc `@yaahc,` who found this while testing locally

Ideally we'd detect this in CI and catch it, but at least we have a comment now which should hopefully prevent this from happening in the future.

r? `@pietroalbini` or `@jyn514`
2022-05-21 11:39:54 +02:00
Guillaume Gomez
b659266b88
Rollup merge of #97237 - oberien:patch-1, r=Dylan-DPC
Add some more weird-exprs

Continuing from https://github.com/rust-lang/rust/pull/86713 (which stalled due to a thinking emoji), I'd like to "improve" the `weird-exprs.rs`-file (as I can't reopen that PR).
2022-05-21 11:39:53 +02:00
Guillaume Gomez
e5c7b21f39
Rollup merge of #97218 - GuillaumeGomez:eslint-checks, r=notriddle
Add eslint checks

The first check is to ensure that `=>` is always surrounded with whitespaces.

The second is to ensure that the dict objects looks like this: `{"a": 2}` and not `{"a" : 2}` or `{"a":2}`.

r? ``@notriddle``
2022-05-21 11:39:49 +02:00
bors
5f33adce1b Auto merge of #93963 - GuillaumeGomez:reduce-clean-type-size, r=notriddle
rustdoc: Reduce clean::Type size

There is no need to keep the `DefId` around since it's allow used to compute if we should show a cast or not. As such, we can simply directly store the boolean.

I think it's not what you had in mind `@camelid` but I guess it's still an improvement? 😉

It was discussed in https://github.com/rust-lang/rust/pull/93941.

r? `@camelid`
2022-05-21 09:04:05 +00:00
Camille GILLOT
075429f76b Recover when resolution did not resolve lifetimes. 2022-05-21 09:39:41 +02:00