Commit Graph

255852 Commits

Author SHA1 Message Date
Guillaume Gomez de644626c3 Migrate `run-make/rustdoc-with-short-out-dir-option` to `rmake.rs` 2024-05-23 12:28:51 +02:00
Nicholas Nethercote e9a59dbed8 Remove `#[macro_use] extern crate tracing` from `rustc_middle`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote 8ae0694fcb Remove `#[macro_use] extern crate tracing` from `rustc_codegen_ssa`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote 8e94226e61 Remove `#[macro_use] extern crate tracing` from `rustc_codegen_llvm`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote 9287aede31 Remove `#[macro_use] extern crate tracing` from `rustc_mir_dataflow`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote bb364fe950 Remove `#[macro_use] extern crate tracing` from `rustc_parse`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote 2539364053 Remove `#[macro_use] extern crate tracing` from `rustc_mir_build`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote d787fb062c Remove `#[macro_use] extern crate tracing` from `rustc_metadata`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote 70e964afe3 Remove `#[macro_use] extern crate tracing` from `rustc_monomorphize`. 2024-05-23 18:02:40 +10:00
Nicholas Nethercote 7a5d814a04 Remove `#[macro_use] extern crate tracing` from `rustc_const_eval`. 2024-05-23 18:02:38 +10:00
Nicholas Nethercote c7da1a5bb8 Remove `#[macro_use] extern crate tracing` from `rustc_lint`. 2024-05-23 18:02:17 +10:00
Nicholas Nethercote c4bdd298fe Remove `#[macro_use] extern crate tracing` from `rustc_incremental`. 2024-05-23 18:02:17 +10:00
Nicholas Nethercote a7cd7bb829 Remove `#[macro_use] extern crate tracing` from `rustc_interface`. 2024-05-23 18:02:17 +10:00
Nicholas Nethercote 725292315e Remove `#[macro_use] extern crate tracing` from `rustc_passes`. 2024-05-23 18:02:17 +10:00
Nicholas Nethercote 448fc75232 Remove `#[macro_use] extern crate tracing` from `rustc_error_messages`. 2024-05-23 18:02:17 +10:00
Nicholas Nethercote bbe4efdb47 Remove `#[macro_use] extern crate tracing` from `rustc_ty_utils`. 2024-05-23 18:02:17 +10:00
bors 39d2f2affd Auto merge of #125436 - matthiaskrgr:rollup-uijo2ga, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #122665 (Add some tests for public-private dependencies.)
 - #123623 (Fix OutsideLoop's error suggestion: adding label `'block` for `if` block.)
 - #125054 (Handle `ReVar` in `note_and_explain_region`)
 - #125156 (Expand `for_loops_over_fallibles` lint to lint on fallibles behind references.)
 - #125222 (Migrate `run-make/issue-46239` to `rmake`)
 - #125316 (Tweak `Spacing` use)
 - #125392 (Wrap Context.ext in AssertUnwindSafe)
 - #125417 (self-contained linker: retry linking without `-fuse-ld=lld` on CCs that don't support it)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-23 06:14:03 +00:00
Tobias Bucher 3ac1a804d1 Remove unneeded string conversion 2024-05-23 08:09:52 +02:00
Matthias Krüger 748647f8b8
Rollup merge of #125417 - lqd:lld-retry, r=petrochenkov
self-contained linker: retry linking without `-fuse-ld=lld` on CCs that don't support it

For the self-contained linker, this PR applies [the strategy](https://github.com/rust-lang/rust/issues/125330#issuecomment-2125119838) of retrying the linking step when the driver doesn't support `-fuse-ld=lld`, but with the option removed. This is the same strategy we already use of retrying when e.g. `-no-pie` is not supported.

Fixes #125330
r? `@petrochenkov`

I have no idea how we could add a test here, much like we don't have one for `-no-pie` or `-static-pie` -- let me know if you have ideas -- but I tested on a CentOS7 image:

```console
[root@d25b38376ede tmp]# ../build/host/stage1/bin/rustc helloworld.rs
 WARN rustc_codegen_ssa:🔙:link The linker driver does not support `-fuse-ld=lld`. Retrying without it.

[root@d25b38376ede tmp]# readelf -p .comment helloworld

String dump of section '.comment':
  [     0]  GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-44)
  [    2d]  rustc version 1.80.0-dev
```

I wasn't able to test with `cross` as the issue describes: I wasn't able to reproduce that behavior locally.
2024-05-23 07:41:19 +02:00
Matthias Krüger 5126d4b87b
Rollup merge of #125392 - workingjubilee:unwind-a-problem-in-context, r=Amanieu
Wrap Context.ext in AssertUnwindSafe

Fixes https://github.com/rust-lang/rust/issues/125193

Alternative to https://github.com/rust-lang/rust/pull/125377

Relevant to https://github.com/rust-lang/rust/issues/123392

I believe this approach is justifiable due to the fact that this function is unstable API and we have been considering trying to dispose of the notion of "unwind safety". Making a more long-term decision should be considered carefully as part of stabilizing `fn ext`, if ever.

r? `@Amanieu`
2024-05-23 07:41:19 +02:00
Matthias Krüger 3c79f0cd69
Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkov
Tweak `Spacing` use

Some clean-up precursors to #125174.

r? ``@petrochenkov``
2024-05-23 07:41:18 +02:00
Matthias Krüger f131ee6561
Rollup merge of #125222 - Oneirical:fifth, r=jieyouxu
Migrate `run-make/issue-46239` to `rmake`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-05-23 07:41:18 +02:00
Matthias Krüger 4af1c31fcf
Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, r=Nilstrieb
Expand `for_loops_over_fallibles` lint to lint on fallibles behind references.

Extends the scope of the (warn-by-default) lint `for_loops_over_fallibles` from just `for _ in x` where `x: Option<_>/Result<_, _>` to also cover `x: &(mut) Option<_>/Result<_>`

```rs
fn main() {
    // Current lints
    for _ in Some(42) {}
    for _ in Ok::<_, i32>(42) {}

    // New lints
    for _ in &Some(42) {}
    for _ in &mut Some(42) {}
    for _ in &Ok::<_, i32>(42) {}
    for _ in &mut Ok::<_, i32>(42) {}

    // Should not lint
    for _ in Some(42).into_iter() {}
    for _ in Some(42).iter() {}
    for _ in Some(42).iter_mut() {}
    for _ in Ok::<_, i32>(42).into_iter() {}
    for _ in Ok::<_, i32>(42).iter() {}
    for _ in Ok::<_, i32>(42).iter_mut() {}
}
```

<details><summary><code>cargo build</code> diff</summary>

```diff
diff --git a/old.out b/new.out
index 84215aa..ca195a7 100644
--- a/old.out
+++ b/new.out
`@@` -1,33 +1,93 `@@`
 warning: for loop over an `Option`. This is more readably written as an `if let` statement
  --> src/main.rs:3:14
   |
 3 |     for _ in Some(42) {}
   |              ^^^^^^^^
   |
   = note: `#[warn(for_loops_over_fallibles)]` on by default
 help: to check pattern in a loop use `while let`
   |
 3 |     while let Some(_) = Some(42) {}
   |     ~~~~~~~~~~~~~~~ ~~~
 help: consider using `if let` to clear intent
   |
 3 |     if let Some(_) = Some(42) {}
   |     ~~~~~~~~~~~~ ~~~

 warning: for loop over a `Result`. This is more readably written as an `if let` statement
  --> src/main.rs:4:14
   |
 4 |     for _ in Ok::<_, i32>(42) {}
   |              ^^^^^^^^^^^^^^^^
   |
 help: to check pattern in a loop use `while let`
   |
 4 |     while let Ok(_) = Ok::<_, i32>(42) {}
   |     ~~~~~~~~~~~~~ ~~~
 help: consider using `if let` to clear intent
   |
 4 |     if let Ok(_) = Ok::<_, i32>(42) {}
   |     ~~~~~~~~~~ ~~~

-warning: `for-loops-over-fallibles` (bin "for-loops-over-fallibles") generated 2 warnings
-    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
+warning: for loop over a `&Option`. This is more readably written as an `if let` statement
+ --> src/main.rs:7:14
+  |
+7 |     for _ in &Some(42) {}
+  |              ^^^^^^^^^
+  |
+help: to check pattern in a loop use `while let`
+  |
+7 |     while let Some(_) = &Some(42) {}
+  |     ~~~~~~~~~~~~~~~ ~~~
+help: consider using `if let` to clear intent
+  |
+7 |     if let Some(_) = &Some(42) {}
+  |     ~~~~~~~~~~~~ ~~~
+
+warning: for loop over a `&mut Option`. This is more readably written as an `if let` statement
+ --> src/main.rs:8:14
+  |
+8 |     for _ in &mut Some(42) {}
+  |              ^^^^^^^^^^^^^
+  |
+help: to check pattern in a loop use `while let`
+  |
+8 |     while let Some(_) = &mut Some(42) {}
+  |     ~~~~~~~~~~~~~~~ ~~~
+help: consider using `if let` to clear intent
+  |
+8 |     if let Some(_) = &mut Some(42) {}
+  |     ~~~~~~~~~~~~ ~~~
+
+warning: for loop over a `&Result`. This is more readably written as an `if let` statement
+ --> src/main.rs:9:14
+  |
+9 |     for _ in &Ok::<_, i32>(42) {}
+  |              ^^^^^^^^^^^^^^^^^
+  |
+help: to check pattern in a loop use `while let`
+  |
+9 |     while let Ok(_) = &Ok::<_, i32>(42) {}
+  |     ~~~~~~~~~~~~~ ~~~
+help: consider using `if let` to clear intent
+  |
+9 |     if let Ok(_) = &Ok::<_, i32>(42) {}
+  |     ~~~~~~~~~~ ~~~
+
+warning: for loop over a `&mut Result`. This is more readably written as an `if let` statement
+  --> src/main.rs:10:14
+   |
+10 |     for _ in &mut Ok::<_, i32>(42) {}
+   |              ^^^^^^^^^^^^^^^^^^^^^
+   |
+help: to check pattern in a loop use `while let`
+   |
+10 |     while let Ok(_) = &mut Ok::<_, i32>(42) {}
+   |     ~~~~~~~~~~~~~ ~~~
+help: consider using `if let` to clear intent
+   |
+10 |     if let Ok(_) = &mut Ok::<_, i32>(42) {}
+   |     ~~~~~~~~~~ ~~~
+
+warning: `for-loops-over-fallibles` (bin "for-loops-over-fallibles") generated 6 warnings
+    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s

```

</details>

-----

Question:

* ~~Currently, the article `an` is used for `&Option`, and `&mut Option` in the lint diagnostic, since that's what `Option` uses. Is this okay or should it be changed? (likewise, `a` is used for `&Result` and `&mut Result`)~~ The article `a` is used for `&Option`, `&mut Option`, `&Result`, `&mut Result` and (as before) `Result`. Only `Option` uses `an` (as before).

`@rustbot` label +A-lint
2024-05-23 07:41:17 +02:00
Matthias Krüger 72fd85c617
Rollup merge of #125054 - nnethercote:fix-124973, r=compiler-errors
Handle `ReVar` in `note_and_explain_region`

PR #124918 made this path abort. The added test, from fuzzing, identified that it is reachable.

r? `@lcnr`
2024-05-23 07:41:17 +02:00
Matthias Krüger 96134e15f6
Rollup merge of #123623 - surechen:fix_123261, r=estebank
Fix OutsideLoop's error suggestion: adding label `'block` for `if` block.

For OutsideLoop we should not suggest add `'block` label in `if` block, or we wiil get another err: block label not supported here.

fixes #123261
2024-05-23 07:41:16 +02:00
Matthias Krüger 5ee8267241
Rollup merge of #122665 - ehuss:pub-priv-tests, r=davidtwco
Add some tests for public-private dependencies.

This adds some tests to show more scenarios for the `exported_private_dependencies` lint. Several of these illustrate that the lint is not working as expected, and I have annotated those places with `FIXME`.

Note also that this includes some diamond dependency structures which compiletest doesn't exactly support. However, I don't think it should be a problem, it just results in the common dependency being built twice.
2024-05-23 07:41:16 +02:00
bors 5293c6adb7 Auto merge of #125359 - RalfJung:interpret-overflowing-ops, r=oli-obk
interpret: make overflowing binops just normal binops

Follow-up to https://github.com/rust-lang/rust/pull/125173 (Cc `@scottmcm)`
2024-05-23 04:03:14 +00:00
Oneirical 1f17e27ae3 Rewrite and rename `issue-38237` to rmake 2024-05-22 22:49:00 -04:00
Oneirical ddb81ce680 rewrite and rename issue-46239 2024-05-22 22:43:21 -04:00
Nicholas Nethercote 5f4424bfaf Handle `ReVar` in `note_and_explain_region`.
PR #124918 made this path abort. The added test, from fuzzing,
identified that it is reachable.
2024-05-23 12:16:49 +10:00
r0cky 96968350e1 Detect unused structs which implement private traits 2024-05-23 09:07:59 +08:00
bors 9cdfe285ca Auto merge of #125423 - fmease:rollup-ne4l9y4, r=fmease
Rollup of 7 pull requests

Successful merges:

 - #125043 (reference type safety invariant docs: clarification)
 - #125306 (Force the inner coroutine of an async closure to `move` if the outer closure is `move` and `FnOnce`)
 - #125355 (Use Backtrace::force_capture instead of Backtrace::capture in rustc_log)
 - #125382 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 7))
 - #125391 (Minor serialize/span tweaks)
 - #125395 (Remove unnecessary `.md` from the documentation sidebar)
 - #125399 (Stop using `to_hir_binop` in codegen)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-22 21:51:26 +00:00
León Orell Valerian Liehr 412c46cc14
Rollup merge of #125399 - scottmcm:less-hir-in-cg_ssa, r=compiler-errors
Stop using `to_hir_binop` in codegen

This came up in https://github.com/rust-lang/rust/pull/125359#discussion_r1609401311 , and looking into it we can just use the `mir::BinOp`s directly instead of `hir::BinOpKind`s.

(AKA rather than going `mir::BinOp` → `hir::BinOpKind` → `IntPredicate`, just go `mir::BinOp` → `IntPredicate`.)
2024-05-22 23:41:14 +02:00
León Orell Valerian Liehr 5f62a35bae
Rollup merge of #125395 - madsmtm:fix-doc-summary, r=lqd
Remove unnecessary `.md` from the documentation sidebar

Oversight from https://github.com/rust-lang/rust/pull/124772, caught in https://github.com/rust-lang/rust/pull/124772#discussion_r1609227398.

r? weihanglo
2024-05-22 23:41:14 +02:00
León Orell Valerian Liehr 0646c7d066
Rollup merge of #125391 - nnethercote:serialize-rs-tweaks, r=compiler-errors
Minor serialize/span tweaks

r? ``@jackh726``
2024-05-22 23:41:13 +02:00
León Orell Valerian Liehr d98c47011a
Rollup merge of #125382 - notriddle:notriddle/issue-d, r=fmease
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 7)

Follow up

* https://github.com/rust-lang/rust/pull/116214
* https://github.com/rust-lang/rust/pull/116432
* https://github.com/rust-lang/rust/pull/116824
* https://github.com/rust-lang/rust/pull/118105
* https://github.com/rust-lang/rust/pull/119561
* https://github.com/rust-lang/rust/pull/123574

As always, it's easier to review the commits one at a time. Don't use the Files Changed tab. It's confusing.
2024-05-22 23:41:13 +02:00
León Orell Valerian Liehr c7d4c54cc8
Rollup merge of #125355 - michaelwoerister:rust_log_force_capture, r=nnethercote
Use Backtrace::force_capture instead of Backtrace::capture in rustc_log

After https://github.com/rust-lang/rust/pull/125063, the compiler and custom drivers won't automatically set the RUST_BACKTRACE environment variable anymore, so we have to call `Backtrace::force_capture` instead of `Backtrace::capture` to unconditionally capture a backtrace.

rustc_log handles enabling backtraces via env vars itself, so we don't want RUST_BACKTRACE to make a difference.
2024-05-22 23:41:12 +02:00
León Orell Valerian Liehr d2f0df7713
Rollup merge of #125306 - compiler-errors:closure-incongruency, r=oli-obk
Force the inner coroutine of an async closure to `move` if the outer closure is `move` and `FnOnce`

See the detailed comment in `upvar.rs`.

Fixes #124867.
Fixes #124487.

r? oli-obk
2024-05-22 23:41:11 +02:00
León Orell Valerian Liehr ab9e0a72ef
Rollup merge of #125043 - RalfJung:ref-type-safety-invariant, r=scottmcm
reference type safety invariant docs: clarification

The old text could have been read as saying that you can call a function if these requirements are upheld, which is definitely not true as they are an underapproximation of the actual safety invariant.

I removed the part about functions relaxing the requirements via their documentation... this seems incoherent with saying that it may actually be unsound to ever temporarily violate the requirement. Furthermore, a function *cannot* just relax this for its return value, that would in general be unsound. And the part about "unsafe code in a safe function may assume these invariants are ensured of arguments passed by the caller" also interacts with relaxing things: clearly, if the invariant has been relaxed, unsafe code cannot rely on it any more. There may be a place to give general guidance on what kinds of function contracts can exist, but the reference type is definitely not the right place to write that down.

I also took a clarification from https://github.com/rust-lang/rust/pull/121965 that is orthogonal to the rest of that PR.

Cc ```@joshlf``` ```@scottmcm```
2024-05-22 23:41:11 +02:00
Eric Huss 07b7cd62c7 Add some tests for public-private dependencies. 2024-05-22 13:47:15 -07:00
León Orell Valerian Liehr ae49dbe707
Cleanup: Fix up some diagnostics 2024-05-22 22:40:34 +02:00
Oneirical dd7e68b356 rewrite and rename issue-53964 2024-05-22 16:30:42 -04:00
Oneirical f377ea165f rewrite issue-30063 2024-05-22 16:25:36 -04:00
Nicholas Nethercote 4d513cb4bf Add some comments. 2024-05-23 06:03:17 +10:00
Nicholas Nethercote a1b6d46e04 Use `JointHidden` in a couple of suitable places.
This has no notable effect, but it's appropriate because the relevant
tokens are followed by delimiters.
2024-05-23 06:03:17 +10:00
Nicholas Nethercote c679a55102 Convert some `token_joint_hidden` calls to `token_joint`.
This has no noticeable effect, but it makes these cases follow the
guidelines in the comments on `Spacing`, which say that `Joint` should
be used "for each token that (a) should be pretty-printed without a
space after it, and (b) is followed by a punctuation token".

These two tokens are both followed by a comma, which is a punctuation
token.
2024-05-23 06:03:17 +10:00
Nicholas Nethercote b6de782198 Clarify a comment. 2024-05-23 06:03:17 +10:00
Nicholas Nethercote 3fc8f8998c Clarify `parse` a little.
- Name the colon span as `colon_span` to distinguish it from the other
  `span` local variable.
- Just use basic pattern matching, which is easier to read than `map_or`.
2024-05-23 06:00:57 +10:00
Nicholas Nethercote c8844dfdc0 Clarify the meaning of the span within `mbe::TokenTree::MetaVar`. 2024-05-23 06:00:28 +10:00
bors 93e7cb835a Auto merge of #125415 - fmease:rollup-n2bg7q5, r=fmease
Rollup of 5 pull requests

Successful merges:

 - #124896 (miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec)
 - #125015 (Pattern types: Prohibit generic args on const params)
 - #125049 (Disallow cast with trailing braced macro in let-else)
 - #125259 (An async closure may implement `FnMut`/`Fn` if it has no self-borrows)
 - #125296 (Fix `unexpected_cfgs` lint on std)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-22 19:31:53 +00:00