Commit Graph

10425 Commits

Author SHA1 Message Date
Oli Scherer 7f292f41a0 Allow defining opaque types during trait object upcasting.
No stable code is affected, as this requires the `trait_upcasting` feature gate.
2024-05-23 16:02:20 +00:00
Oli Scherer 29a630eb72 When checking whether an impl applies, constrain hidden types of opaque types.
We already handle this case this way on the coherence side, and it matches the new solver's behaviour. While there is some breakage around type-alias-impl-trait (see new "type annotations needed" in tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs), no stable code breaks, and no new stable code is accepted.
2024-05-23 15:52:10 +00:00
Oli Scherer dc8d1bc373 Add more tests 2024-05-23 15:48:06 +00:00
Mohammad Omidvar 6743fc7704 Add conversion from IntrinsicDef to FnDef 2024-05-23 15:35:18 +00:00
bors 9c8a58fdb8 Auto merge of #116123 - joboet:rewrite_native_tls, r=m-ou-se
Rewrite native thread-local storage

(part of #110897)

The current native thread-local storage implementation has become quite messy, uses indescriptive names and unnecessarily adds code to the macro expansion. This PR tries to fix that by using a new implementation that also allows more layout optimizations and potentially increases performance by eliminating unnecessary TLS accesses.

This does not change the recursive initialization behaviour I described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525705682), so it should be a library-only change. Changing that behaviour should be quite easy now, however.

r? `@m-ou-se`
`@rustbot` label +T-libs
2024-05-23 14:53:41 +00:00
Matthias Krüger eb1b9b0048
Rollup merge of #125421 - Oneirical:bundle-them-yet-again, r=jieyouxu
Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

The test which is now called `non-pie-thread-local` has an unexplained "only-linux" flag. Could it be worth trying to remove it and changing the CI to test non-Linux platforms on it?
2024-05-23 14:09:25 +02:00
Matthias Krüger e713b2a00c
Rollup merge of #125416 - compiler-errors:param-env-missing-copy, r=lcnr
Use correct param-env in `MissingCopyImplementations`

We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses.

fixes #125394
2024-05-23 14:09:25 +02:00
Matthias Krüger 337987bf63
Rollup merge of #125210 - fmease:fix-up-some-diags, r=davidtwco
Cleanup: Fix up some diagnostics

Several diagnostics contained their error code inside their primary message which is no bueno.
This PR moves them out of the message and turns them into structured error codes.

Also fixes another occurrence of `->` after a selector in a Fluent message which is not correct. I've fixed two other instances of this issue in #104345 (2022) but didn't update all instances as I've noted here: https://github.com/rust-lang/rust/pull/104345#issuecomment-1312705977 (“the future is now!”).
2024-05-23 14:09:24 +02:00
Matthias Krüger eda4a35f36
Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from https://github.com/rust-lang/rust/pull/121167.
2024-05-23 14:09:23 +02:00
Matthias Krüger eb6b35b5bc
Rollup merge of #124516 - oli-obk:taint_const_eval, r=RalfJung
Allow monomorphization time const eval failures if the cause is a type layout issue

r? `@RalfJung`

fixes  #124348
2024-05-23 14:09:23 +02:00
Matthias Krüger abcf400a28
Rollup merge of #124297 - oli-obk:define_opaque_types13, r=jackh726
Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type

r? `@compiler-errors`

This accepts more code on stable. It is now possible to have match arms return a function item `foo` and a different function item `bar` in another, and that will constrain OpaqueTypeInDefiningScope to have the hidden type ConcreteType and make the type of the match arms a function pointer that matches the signature. So the following function will now compile, but on master it errors with a type mismatch on the second match arm

```rust
fn foo<T>(t: T) -> T {
    t
}

fn bar<T>(t: T) -> T {
    t
}

fn k() -> impl Sized {
    fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F {
        f
    }
    let x = match true {
        true => {
            let f = foo;
            bind(k(), f)
        }
        false => bar::<()>,
    };
    todo!()
}
```

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

This is very similar to https://github.com/rust-lang/rust/pull/123794, and with the same rationale:

> this is for consistency with `-Znext-solver`. the new solver does not have the concept of "non-defining use of opaque" right now and we would like to ideally keep it that way. Moving to `DefineOpaqueTypes::Yes` in more cases removes subtlety from the type system. Right now we have to be careful when relating `Opaque` with another type as the behavior changes depending on whether we later use the `Opaque` or its hidden type directly (even though they are equal), if that later use is with `DefineOpaqueTypes::No`*
2024-05-23 14:09:22 +02:00
joboet 60bf1ab466
delete UI tests that only check internal implementation details of thread-locals 2024-05-23 13:44:56 +02:00
Oli Scherer 4cf34cb752 Allow const eval failures if the cause is a type layout issue 2024-05-23 10:51:52 +00:00
Oli Scherer 301c8decce Add regression tests 2024-05-23 10:48:39 +00:00
Guillaume Gomez de644626c3 Migrate `run-make/rustdoc-with-short-out-dir-option` to `rmake.rs` 2024-05-23 12:28:51 +02: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
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 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
León Orell Valerian Liehr 06bc4fc671
Remove `LintDiagnostic::msg`
* instead simply set the primary message inside the lint decorator functions
* it used to be this way before [#]101986 which introduced `msg` to prevent
  good path delayed bugs (which no longer exist) from firing under certain
  circumstances when lints were suppressed / silenced
* this is no longer necessary for various reasons I presume
* it shaves off complexity and makes further changes easier to implement
2024-05-23 04:08:35 +02: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 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 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
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
Oneirical d4e5426256 rewrite and rename `issue-24445` to rmake 2024-05-22 15:25:43 -04:00
Urgau 1c7859e117 Don't suggest adding the unexpected cfgs the build-script it-self 2024-05-22 20:58:57 +02:00
Oneirical c24d1c7ff8 Rewrite `core-no-oom-handling` as rmake.rs 2024-05-22 14:40:41 -04:00
León Orell Valerian Liehr 44c7a2dbff
Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obk
An async closure may implement `FnMut`/`Fn` if it has no self-borrows

There's no reason that async closures may not implement `FnMut` or `Fn` if they don't actually borrow anything with the closure's env lifetime. Specifically, #123660 made it so that we don't always need to borrow captures from the closure's env.

See the doc comment on `should_reborrow_from_env_of_parent_coroutine_closure`:

c00957a3e2/compiler/rustc_hir_typeck/src/upvar.rs (L1777-L1823)

If there are no such borrows, then we are free to implement `FnMut` and `Fn` as permitted by our closure's inferred `ClosureKind`.

As far as I can tell, this change makes `async || {}` work in precisely the set of places they used to work before #120361.
Fixes #125247.

r? oli-obk
2024-05-22 19:04:45 +02:00
León Orell Valerian Liehr 5b485f04de
Rollup merge of #125049 - dtolnay:castbrace, r=compiler-errors
Disallow cast with trailing braced macro in let-else

This fixes an edge case I noticed while porting #118880 and #119062 to syn.

Previously, rustc incorrectly accepted code such as:

```rust
let foo = &std::ptr::null as &'static dyn std::ops::Fn() -> *const primitive! {
    8
} else {
    return;
};
```

even though a right curl brace `}` directly before `else` in a `let...else` statement is not supposed to be valid syntax.
2024-05-22 19:04:44 +02:00
León Orell Valerian Liehr b3604de1df
Rollup merge of #125015 - fmease:pat-tys-proh-gen-args-on-ct-params, r=spastorino
Pattern types: Prohibit generic args on const params

Addresses https://github.com/rust-lang/rust/pull/123689/files#r1562676629.

NB: Technically speaking, *not* prohibiting generics args on const params is not a bug as `pattern_types` is an *internal* feature and as such any uncaught misuses of it are considered to be the fault of the user. However, permitting this makes me slightly uncomfortable esp. since we might want to make pattern types available to the public at some point and I don't want this oversight to be able to slip into the language (for comparison, ICEs triggered by the use of internal features are like super fine).

Furthermore, this is an ad hoc fix. A more general fix would be changing the representation of the pattern part of pattern types in such a way that it can reuse preexisting lowering routines for exprs / anon consts. See also this [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/pattern.20type.20HIR.20nodes/near/432410768) and #124650.

Also note that we currently don't properly typeck the pattern of pat tys. This however is out of scope for this PR.

cc ``@oli-obk``
r? ``@spastorino`` as discussed
2024-05-22 19:04:44 +02:00
Michael Goulet 8369dbba43 Use correct param-env in MissingCopyImplementations 2024-05-22 12:46:08 -04:00
Vadim Petrochenkov 711338bd9f rustc: Use `tcx.used_crates(())` more
And explain when it should be used.
2024-05-22 18:02:51 +03:00
bors 5d328a1f62 Auto merge of #117329 - RalfJung:offset-by-zero, r=oli-obk,scottmcm
offset: allow zero-byte offset on arbitrary pointers

As per prior `@rust-lang/opsem` [discussion](https://github.com/rust-lang/opsem-team/issues/10) and [FCP](https://github.com/rust-lang/unsafe-code-guidelines/issues/472#issuecomment-1793409130):

- Zero-sized reads and writes are allowed on all sufficiently aligned pointers, including the null pointer
- Inbounds-offset-by-zero is allowed on all pointers, including the null pointer
- `offset_from` on two pointers derived from the same allocation is always allowed when they have the same address

This removes surprising UB (in particular, even C++ allows "nullptr + 0", which we currently disallow), and it brings us one step closer to an important theoretical property for our semantics ("provenance monotonicity": if operations are valid on bytes without provenance, then adding provenance can't make them invalid).

The minimum LLVM we require (v17) includes https://reviews.llvm.org/D154051, so we can finally implement this.

The `offset_from` change is needed to maintain the equivalence with `offset`: if `let ptr2 = ptr1.offset(N)` is well-defined, then `ptr2.offset_from(ptr1)` should be well-defined and return N. Now consider the case where N is 0 and `ptr1` dangles: we want to still allow offset_from here.

I think we should change offset_from further, but that's a separate discussion.

Fixes https://github.com/rust-lang/rust/issues/65108
[Tracking issue](https://github.com/rust-lang/rust/issues/117945) | [T-lang summary](https://github.com/rust-lang/rust/pull/117329#issuecomment-1951981106)

Cc `@nikic`
2024-05-22 13:04:14 +00:00
surechen 8fde7e3b64 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-22 19:47:32 +08:00
bors f0038a7c8f Auto merge of #124227 - compiler-errors:hack-check-method-res, r=estebank
Make sure that the method resolution matches in `note_source_of_type_mismatch_constraint`

`note_source_of_type_mismatch_constraint` is a pile of hacks that I implemented to cover up another pile of hacks.

It does a bunch of re-confirming methods, but it wasn't previously checking that the methods it was looking (back) up were equal to the methods we previously had. This PR adds those checks.

Fixes #118185
2024-05-22 10:57:59 +00:00
Guillaume Gomez fc76015dcb Migrate `run-make/rustdoc-scrape-examples-macros` to `rmake.rs` 2024-05-22 11:49:21 +02:00
Michael Howell b5923a95a8 Move tests into appropriate subdirectories 2024-05-21 21:21:26 -07:00
bors b54dd08a84 Auto merge of #125326 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors
Move `#[do_not_recommend]` to the `#[diagnostic]` namespace

This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires
`#![feature(do_not_recommend)]` to work.

r? `@compiler-errors`
2024-05-22 04:14:08 +00:00
Jubilee Young 3a21fb5cec Wrap Context.ext in AssertUnwindSafe 2024-05-21 19:05:37 -07:00
bors 791adf759c Auto merge of #124417 - Xiretza:translate-early-lints, r=fmease
Make early lints translatable

<del>Requires https://github.com/projectfluent/fluent-rs/pull/353.</del> 5134a04eaa

r? diagnostics
2024-05-21 21:36:09 +00:00
Xiretza c4f6502c6d Fix typo in deprecation lint message 2024-05-21 20:16:39 +00:00
Xiretza 8004e6a379 Make early lints translatable 2024-05-21 20:16:39 +00:00
Xiretza 2482f3c17c Convert unexpected_cfg_{name,value} to struct diagnostics 2024-05-21 20:16:39 +00:00
Michael Howell 55bd054a21 rustdoc: rename `issue-\d+.rs` tests to have meaningful names 2024-05-21 12:28:34 -07:00
Michael Howell 4486c24db3 Add URL and crate_name to test cases 2024-05-21 12:28:30 -07:00
Matthias Krüger 639853fea5
Rollup merge of #125357 - GuillaumeGomez:migrate-rustdoc-scrape-examples-multiple, r=jieyouxu
Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? ```@jieyouxu```
2024-05-21 20:28:49 +02:00
Matthias Krüger 1b57ef3207
Rollup merge of #125310 - workingjubilee:muck-out-the-test-stables, r=Nilstrieb
Move ~100 tests from tests/ui to subdirs

new dirs for some, the rest in old
sweep tests up before they turn cold
to stop our code from growing mold
2024-05-21 20:28:48 +02:00
Matthias Krüger bfa98d318f
Rollup merge of #125276 - dev-ardi:no-main-diag, r=fmease
Fix parsing of erroneously placed semicolons

This closes https://github.com/rust-lang/rust/issues/124935, is a continuation of https://github.com/rust-lang/rust/pull/125245 after rebasing https://github.com/rust-lang/rust/pull/125117.

Thanks ```@gurry``` for your code and sorry for making it confusing :P

r? fmease
2024-05-21 20:28:47 +02:00
Matthias Krüger 6009cb776a
Rollup merge of #123122 - surechen:fix_122714, r=fmease
Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.

For poly-trait-ref like `for<'a> Trait<T>`   in  `T: for<'a> Trait<T> + 'b { }`.
We should merge the hrtb lifetimes: existed `for<'a>` and suggestion `for<'b>` or will get err: [E0316] nested quantification of lifetimes

fixes #122714
2024-05-21 20:28:46 +02:00
Ralf Jung 37aeb75eb6 don't inhibit random field reordering on repr(packed(1)) 2024-05-21 19:22:04 +02:00
bors 506512391b Auto merge of #124676 - djkoloski:relax_multiple_sanitizers, r=cuviper,rcvalle
Relax restrictions on multiple sanitizers

Most combinations of LLVM sanitizers are legal-enough to enable simultaneously. This change will allow simultaneously enabling ASAN and shadow call stacks on supported platforms.

I used this python script to generate the mutually-exclusive sanitizer combinations:

```python
#!/usr/bin/python3

import subprocess

flags = [
    ["-fsanitize=address"],
    ["-fsanitize=leak"],
    ["-fsanitize=memory"],
    ["-fsanitize=thread"],
    ["-fsanitize=hwaddress"],
    ["-fsanitize=cfi", "-flto", "-fvisibility=hidden"],
    ["-fsanitize=memtag", "--target=aarch64-linux-android", "-march=armv8a+memtag"],
    ["-fsanitize=shadow-call-stack"],
    ["-fsanitize=kcfi", "-flto", "-fvisibility=hidden"],
    ["-fsanitize=kernel-address"],
    ["-fsanitize=safe-stack"],
    ["-fsanitize=dataflow"],
]

for i in range(len(flags)):
    for j in range(i):
        command = ["clang++"] + flags[i] + flags[j] + ["-o", "main.o", "-c", "main.cpp"]
        completed = subprocess.run(command, stderr=subprocess.DEVNULL)
        if completed.returncode != 0:
            first = flags[i][0][11:].replace('-', '').upper()
            second = flags[j][0][11:].replace('-', '').upper()
            print(f"(SanitizerSet::{first}, SanitizerSet::{second}),")
```
2024-05-21 15:35:29 +00:00
Ralf Jung c0b4b454c3 interpret: make overflowing binops just normal binops 2024-05-21 14:50:09 +02:00
bors 6715446db6 Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124570 (Miscellaneous cleanups)
 - #124772 (Refactor documentation for Apple targets)
 - #125011 (Add opt-for-size core lib feature flag)
 - #125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`)
 - #125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS)
 - #125266 (compiler: add simd_ctpop intrinsic)
 - #125348 (Small fixes to `std::path::absolute` docs)

Failed merges:

 - #125296 (Fix `unexpected_cfgs` lint on std)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-21 12:50:09 +00:00
Georg Semmler 2cff3e90bc
Move `#[do_not_recommend]` to the `#[diagnostic]` namespace
This commit moves the `#[do_not_recommend]` attribute to the
`#[diagnostic]` namespace. It still requires
`#![feature(do_not_recommend)]` to work.
2024-05-21 13:14:41 +02:00
Matthias Krüger fd975f75fa
Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikic
compiler: add simd_ctpop intrinsic

Fairly straightforward addition.

cc `@rust-lang/opsem` new (extremely boring) intrinsic
2024-05-21 12:47:06 +02:00
Matthias Krüger 7ef533bce6
Rollup merge of #125218 - Oneirical:easy-test-the-third, r=jieyouxu
Migrate `run-make/no-intermediate-extras` to new `rmake.rs`

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-21 12:47:05 +02:00
bors e8fbd99128 Auto merge of #124097 - compiler-errors:box-into-iter, r=WaffleLapkin
Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints

* Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021.
* Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity).
* Adds some tests.
* Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing.

Based mostly off of #116607.

ACP: rust-lang/libs-team#263
References #59878
Tracking for Rust 2024: https://github.com/rust-lang/rust/issues/123759

Crater run was done here: https://github.com/rust-lang/rust/pull/116607#issuecomment-1770293013
Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.
2024-05-21 10:13:53 +00:00
Guillaume Gomez f8c992f8b4 Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs` 2024-05-21 12:11:17 +02:00
bors e875391458 Auto merge of #123812 - compiler-errors:additional-fixes, r=fmease
Follow-up fixes to `report_return_mismatched_types`

Some renames, simplifications, fixes, etc. Follow-ups to #123804. I don't think it totally disentangles this code, but it does remove some of the worst offenders on the "I am so confused" scale (e.g. `get_node_fn_decl`).
2024-05-21 08:06:41 +00:00
bors 1d0e4afd4c Auto merge of #125298 - tesuji:arrcmp, r=nikic
Add codegen test for array comparision opt

Fixed since rust 1.55
closes #62531
2024-05-21 05:55:39 +00:00
Jubilee Young d89500843c Move 100 entries from tests/ui into subdirs
- Move super-fast-paren-parsing test into ui/parser
- Move stmt_expr_attrs test into ui/feature-gates
- Move macro tests into ui/macros
- Move global_asm tests into ui/asm
- Move env tests into ui/process
- Move xcrate tests into ui/cross-crate
- Move unop tests into ui/unop
- Move backtrace tests into ui/backtrace
- Move check-static tests into ui/statics
- Move expr tests into ui/expr
- Move optimization fuel tests into ui/fuel
- Move ffi attribute tests into ui/ffi-attrs
- Move suggestion tests into ui/suggestions
- Move main tests into ui/fn-main
- Move lint tests into ui/lint
- Move repr tests into ui/repr
- Move intrinsics tests into ui/intrinsics
- Move tool lint tests into ui/tool-attributes
- Move return tests into ui/return
- Move pattern tests into ui/patttern
- Move range tests into ui/range
- Move foreign-fn tests into ui/foreign
- Move orphan-check tests into ui/coherence
- Move inference tests into ui/inference
- Reduce ROOT_ENTRY_LIMIT
2024-05-20 19:55:59 -07:00
Oneirical 95c47d3396 simplify 2024-05-20 21:30:48 -04:00
Michael Goulet a2a6fe7e51 Inline get_node_fn_decl into get_fn_decl, simplify/explain logic in report_return_mismatched_types 2024-05-20 20:16:29 -04:00
Lzu Tao e7d6da3676 Add codegen test for array comparision opt 2024-05-21 00:09:25 +00:00
Michael Goulet bc6b70f1d1 Adjust the method ambiguity lint too 2024-05-20 19:21:38 -04:00
Michael Goulet a502e7ac1d Implement BOXED_SLICE_INTO_ITER 2024-05-20 19:21:30 -04:00
Michael Goulet c86a4aa5ca Backticks 2024-05-20 19:16:36 -04:00
Matthias Krüger e97103ff6c
Rollup merge of #125308 - lcnr:search-graph-5, r=compiler-errors
track cycle participants per root

The search graph may have multiple roots, e.g. in
```
A :- B
B :- A, C
C :- D
D :- C
```
we first encounter the `A -> B -> A` cycle which causes `A` to be a root. We then later encounter the `C -> D -> C` cycle as a nested goal of `B`. This cycle is completely separate and `C` will get moved to the global cache. This previously caused us to use `[B, D]` as the `cycle_participants` for `C` and `[]` for `A`.

split off from #125167 as I would like to merge this change separately and will rebase that PR on top of this one. There is no test for this issue and I don't quite know how to write one. It is probably worth it to generalize the search graph to enable us to write unit tests for it.

r? `@compiler-errors`
2024-05-21 00:47:02 +02:00
Matthias Krüger 4b26045b92
Rollup merge of #125158 - Nilstrieb:block-indent, r=compiler-errors
hir pretty: fix block indent

before:
```rust
fn main() {
        {
                {
                        ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"]));
                    };
            }
    }
```
after:
```rust
fn main() {
    {
        {
            ::std::io::_print(format_arguments::new_const(&["Hello, world!\n"]));
        };
    }
}
```

AST pretty does the same.
2024-05-21 00:47:02 +02:00
Matthias Krüger e275d2dad6
Rollup merge of #124283 - surechen:fix_123558, r=estebank
Note for E0599 if shadowed bindings has the method.

implement #123558

Use a visitor to find earlier shadowed bingings which has the method.

r? ``@estebank``
2024-05-21 00:47:01 +02:00
Matthias Krüger 8903de31ca
Rollup merge of #124050 - saethlin:less-sysroot-libc, r=ChrisDenton
Remove libc from MSVC targets

``@ChrisDenton`` started working on a project to remove libc from Windows MSVC targets. I'm completing that work here.

The primary change is to cfg out the dependency in `library/`. And then there's a lot of test patching. Happy to separate this more if people want.
2024-05-21 00:47:00 +02:00
lcnr f99c9ffd88 track cycle participants per entry 2024-05-20 20:57:14 +00:00
bors b92758a9ae Auto merge of #125219 - Urgau:check-cfg-cargo-config, r=fmease
Update `unexpected_cfgs` lint for Cargo new `check-cfg` config

This PR updates the diagnostics output of the `unexpected_cfgs` lint for Cargo new `check-cfg` config.

It's a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction.

```toml
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] }
```

This PR also adds a Cargo specific section regarding check-cfg and Cargo inside rustc's book (motivation is described inside the file, but mainly check-cfg is a rustc feature not a Cargo one, Cargo only enabled the feature, it does not own it; T-cargo even considers the `check-cfg` lint config to be an implementation detail).

This PR also updates the links to refer to that sub-page when using Cargo from rustc.

As well as updating the lint doc to refer to the check-cfg docs.

~**Not to be merged before https://github.com/rust-lang/cargo/pull/13913 reaches master!**~ (EDIT: merged in https://github.com/rust-lang/rust/pull/125237)

`@rustbot` label +F-check-cfg
r? `@fmease` *(feel free to roll)*
Fixes https://github.com/rust-lang/rust/issues/124800
cc `@epage` `@weihanglo`
2024-05-20 20:14:09 +00:00
ardi 972633f530 Fix parsing of erroneously placed semicolons 2024-05-20 21:36:20 +02:00
Nilstrieb 7b1527ff5f hir pretty: fix block indent 2024-05-20 20:30:44 +02:00
Mohammad Omidvar 56ad5453f6 Extend tests for intrinsic definitions 2024-05-20 18:12:06 +00:00
Matthias Krüger 1640225b9d
Rollup merge of #125318 - GuillaumeGomez:migrate-rustdoc-examples-whitespaces, r=jieyouxu
Migrate `run-make/rustdoc-scrape-examples-whitespace` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
2024-05-20 18:13:49 +02:00
Matthias Krüger a79737c3f0
Rollup merge of #125314 - jdonszelmann:global-registration-feature-gate, r=pnkfelix
Add an experimental feature gate for global registration

See #125119 for the tracking issue.
2024-05-20 18:13:49 +02:00
Matthias Krüger 83cceeaf37
Rollup merge of #125305 - jwong101:120493-codegen-test, r=the8472
add some codegen tests for issue 120493

I forgot to add these in https://github.com/rust-lang/rust/pull/123878.
2024-05-20 18:13:48 +02:00
Matthias Krüger 9987e900c0
Rollup merge of #125173 - scottmcm:never-checked, r=davidtwco
Remove `Rvalue::CheckedBinaryOp`

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996>
cc `@RalfJung`

While it's a draft,
r? ghost
2024-05-20 18:13:48 +02:00
Matthias Krüger e0d922842d
Rollup merge of #125106 - Zalathar:expressions, r=davidtwco
coverage: Memoize and simplify counter expressions

When creating coverage counter expressions as part of coverage instrumentation, we often end up creating obviously-redundant expressions like `c1 + (c0 - c1)`, which is equivalent to just `c0`.

To avoid doing so, this PR checks when we would create an expression matching one of 5 patterns, and uses the simplified form instead:
- `(a - b) + b` → `a`.
- `(a + b) - b` → `a`.
- `(a + b) - a` → `b`.
- `a + (b - a)` → `b`.
- `a - (a - b)` → `b`.

Of all the different ways to combine 3 operands and 2 operators, these are the patterns that allow simplification.

(Some of those patterns currently don't occur in practice, but are included anyway for completeness, to avoid having to add them later as branch coverage and MC/DC coverage support expands.)

---

This PR also adds memoization for newly-created (or newly-simplified) counter expressions, to avoid creating duplicates.

This currently makes no difference to the final mappings, but is expected to be useful for MC/DC coverage of match expressions, as proposed by https://github.com/rust-lang/rust/pull/124278#issuecomment-2106754753.
2024-05-20 18:13:47 +02:00
Matthias Krüger ba1bb80b6b
Rollup merge of #124917 - cardigan1008:issue-124819, r=pnkfelix
Check whether the next_node is else-less if in get_return_block

Fix #124819
2024-05-20 18:13:47 +02:00
Matthias Krüger 29c603c1fa
Rollup merge of #124682 - estebank:issue-40990, r=pnkfelix
Suggest setting lifetime in borrowck error involving types with elided lifetimes

```
error: lifetime may not live long enough
  --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5
   |
LL | fn foo(mut x: Ref, y: Ref) {
   |        -----       - has type `Ref<'_, '1>`
   |        |
   |        has type `Ref<'_, '2>`
LL |     x.b = y.b;
   |     ^^^^^^^^^ assignment requires that `'1` must outlive `'2`
   |
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: Ref<'a, 'a>) {
   |       ++++           ++++++++        ++++++++
```

As can be seen above, it currently doesn't try to compare the `ty::Ty` lifetimes that diverged vs the `hir::Ty` to correctly suggest the following

```
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'_, 'a>, y: Ref<'_, 'a>) {
   |       ++++           ++++++++        ++++++++
```

but I believe this to still be an improvement over the status quo.

Fix #40990.
2024-05-20 18:13:46 +02:00
Ben Kimock 39ef149a29 Undo accidental change to tests/ui/sanitizer/thread.rs 2024-05-20 11:13:33 -04:00
Ben Kimock 30379f9bcc Update tests/incremental/foreign.rs 2024-05-20 11:13:10 -04:00
Ben Kimock f45a7a291c Fix feature-gates/rustc-private.rs 2024-05-20 11:13:10 -04:00
Ben Kimock 7a906e1af7 Port stdout-during-shutdown 2024-05-20 11:13:10 -04:00
Ben Kimock 70147cd3ab Patch up foreign-fn-linkname.rs 2024-05-20 11:13:10 -04:00
Ben Kimock 281178de42 Add a Windows version of foreign2.rs 2024-05-20 11:13:10 -04:00
Ben Kimock 18b0a07d49 Handle a few more simple tests 2024-05-20 11:13:10 -04:00
Ben Kimock e0632d7cec Add only-unix to sigpipe tests 2024-05-20 11:13:10 -04:00
Ben Kimock 8d3bc55904 Fix up a few more tests 2024-05-20 11:13:10 -04:00
Joshua Wong a4efe6fe27 add codegen test for issue 120493 2024-05-20 09:21:09 -05:00
surechen 4ebbb5f048 Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.
fixes #122714
2024-05-20 20:28:57 +08:00
Matthias Krüger e45fd0686f
Rollup merge of #125309 - nnethercote:fix-strings-and-strs, r=Mark-Simulacrum
Fix `tests/debuginfo/strings-and-strs`.

It fails on my machine because it embeds pointer addresses in the expected output.

This commit replaces the addresses with `0x[...]`.

r? ```@Mark-Simulacrum```
2024-05-20 14:26:54 +02:00
Matthias Krüger 3a503157a0
Rollup merge of #125300 - compiler-errors:dont-strip-inherited-viz, r=fmease
rustdoc: Don't strip items with inherited visibility in `AliasedNonLocalStripper`

Enum variants return `None` in `Item::visibility`, which fails the comparison to `Some(Visibility::Public)`. This means that all enums in type aliases are being stripped, leading to this in the `rustc_middle` docs:

<img width="474" alt="image" src="https://github.com/rust-lang/rust/assets/3674314/83704d94-a571-4c28-acbd-ca51c4efd46e">

This regressed in https://github.com/rust-lang/rust/pull/124939#discussion_r1606130566.

This switches the `AliasedNonLocalStripper` to not strip items with `None` as their visibility.
2024-05-20 14:26:53 +02:00
surechen b092b5d02b Note for E0599 if shadowed bindings has the method.
implement #123558
2024-05-20 18:53:17 +08:00
Guillaume Gomez 7b0fd3b931 Migrate `run-make/rustdoc-scrape-examples-whitespace` to `rmake.rs` 2024-05-20 12:09:11 +02:00
Urgau ccd3e99a1a Fix quote escaping inside check-cfg value 2024-05-20 11:44:09 +02:00
jdonszelmann 1d9757cd84
add todo test for feature gate 2024-05-20 09:18:49 +02:00
Matthias Krüger ecbd110c7e
Rollup merge of #125302 - workingjubilee:prefer-my-stack-neat, r=compiler-errors
defrost `RUST_MIN_STACK=ice rustc hello.rs`

I didn't think too hard about testing my previous PR rust-lang/rust#122847 which makes our stack overflow handler assist people in discovering the `RUST_MIN_STACK` variable (which apparently is surprisingly useful for Really Big codebases). After it was merged, some useful comments left in a drive-by review led me to discover I had added an ICE. This reworks the code a bit to explain the rationale, remove the ICE that I introduced, and properly test one of the diagnostics.
2024-05-20 08:31:42 +02:00
Matthias Krüger 199d3bf3e4
Rollup merge of #125301 - jwong101:fix-static-coro-suggest, r=compiler-errors
fix suggestion in E0373 for !Unpin coroutines

Coroutines can be prefixed with the `static` keyword to make them
`!Unpin`.
However, given the following function:

```rust

fn check() -> impl Sized {
    let x = 0;
    #[coroutine]
    static || {
        yield;
        x
    }
}
```

We currently suggest prefixing `move` before `static`, which is
syntactically incorrect:

```
error[E0373]: coroutine may outlive the current function, but it borrows
...
 --> src/main.rs:6:5
  |
6 |     static || {
  |     ^^^^^^^^^ may outlive borrowed value `x`
7 |         yield;
8 |         x
  |         - `x` is borrowed here
  |
note: coroutine is returned here
 --> src/main.rs:6:5
  |
6 | /     static || {
7 | |         yield;
8 | |         x
9 | |     }
  | |_____^
help: to force the coroutine to take ownership of `x` (and any other
referenced variables), use the `move` keyword
  |     // this is syntactically incorrect, it should be `static move ||`
6 |     move static || {
  |     ++++

```

This PR suggests adding `move` after `static` for these coroutines.

I also added a UI test for this case.
2024-05-20 08:31:42 +02:00
Matthias Krüger 88552615e8
Rollup merge of #125282 - WaffleLapkin:never-type-unsafe-improvements, r=compiler-errors
Never type unsafe lint improvements

- Move linting code to a separate method
- Remove mentions of `core::convert::absurd` (#124311 was rejected)
- Make the lint into FCW

The last thing is a bit weird though. On one hand it should be `EditionSemanticsChange(2024)`, but on the other hand it shouldn't, because we also plan to break it on all editions some time later. _Also_, it's weird that we don't have `FutureReleaseSemanticsChangeReportInDeps`, IMO "this might cause UB in a future release" is important enough to be reported in deps...

IMO we ought to have three enums instead of [`FutureIncompatibilityReason`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.FutureIncompatibilityReason.html#):

```rust
enum IncompatibilityWhen {
     FutureRelease,
     Edition(Edition),
}

enum IncompatibilyWhat {
    Error,
    SemanticChange,
}

enum IncompatibilityReportInDeps {
    No,
    Yes,
}
```

Tracking:
- https://github.com/rust-lang/rust/issues/123748
2024-05-20 08:31:41 +02:00
Nicholas Nethercote 4654e87d4c Fix `tests/debuginfo/strings-and-strs`.
It fails on my machine because it embeds pointer addresses in the
expected output.

This commit replaces the addresses with `0x[...]`.
2024-05-20 15:01:59 +10:00
Michael Goulet 6b3058204a Force the inner coroutine of an async closure to `move` if the outer closure is `move` and `FnOnce` 2024-05-19 23:46:52 -04:00
Jubilee Young b6d0d6da55 note value of RUST_MIN_STACK and explain unsetting 2024-05-19 20:09:03 -07:00
Jubilee Young 9985821b2f defrost RUST_MIN_STACK=ice rustc hello.rs
An earlier commit included the change for a suggestion here.
Unfortunately, it also used unwrap instead of dying properly.
Roll out the ~~rice paper~~ EarlyDiagCtxt before we do anything that
might leave a mess.
2024-05-19 18:28:14 -07:00
Jubilee Young def6b99b4a move rustc-rust-log test into ui/rustc-env 2024-05-19 18:27:53 -07:00
Joshua Wong 371de042d9 add ui tests for E0373 suggestion 2024-05-19 19:23:38 -05:00
Michael Goulet dbfed2c43e Add failing test for cross-crate enum in type alias 2024-05-19 20:13:18 -04:00
Matthias Krüger d5bef41ee5
Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errors
chore: Remove repeated words (extension of #124924)

When I saw #124924 I thought "Hey, I'm sure that there are far more than just two typos of this nature in the codebase". So here's some more typo-fixing.

Some found with regex, some found with a spellchecker. Every single one manually reviewed by me (along with hundreds of false negatives by the tools)
2024-05-19 22:50:55 +02:00
Urgau 3b47f4c60c Refer to the Cargo specific doc in the check-cfg diagnostics 2024-05-19 20:12:41 +02:00
Urgau 7cb84fbf14 Prefer suggesting string-literal for Cargo `check-cfg` lint config 2024-05-19 20:04:32 +02:00
Waffle Lapkin 434221ba45 bless tests 2024-05-19 19:10:04 +02:00
Michael Goulet e959fd6634
Rollup merge of #125275 - GuillaumeGomez:migrate-rustdoc-scrape-examples-test, r=jieyouxu
Migrate `run-make/rustdoc-scrape-examples-test` to new `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? ``@jieyouxu``
2024-05-19 11:04:10 -04:00
Michael Goulet 0fd615f70e
Rollup merge of #125261 - matthiaskrgr:from_ashes_to_crashes, r=jieyouxu
crashes: add more

r? ``@jieyouxu``
2024-05-19 11:04:09 -04:00
Michael Goulet e940ca7d4f
Rollup merge of #124708 - weiznich:implement_do_not_recommend, r=compiler-errors,estebank
Actually use the `#[do_not_recommend]` attribute if present

This change tweaks the error message generation to actually use the `#[do_not_recommend]` attribute if present by just skipping the marked trait impl in favour of the parent impl. It also adds a compile test for this behaviour. Without this change the test would output the following error:

```
error[E0277]: the trait bound `&str: Expression` is not satisfied
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15
   |
LL |     SelectInt.check("bar");
   |               ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>`
   |
   = help: the following other types implement trait `Expression`:
             Bound<T>
             SelectInt
note: required for `&str` to implement `AsExpression<Integer>`
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13
   |
LL | impl<T, ST> AsExpression<ST> for T
   |             ^^^^^^^^^^^^^^^^     ^
LL | where
LL |     T: Expression<SqlType = ST>,
   |        ------------------------ unsatisfied trait bound introduced here
```

Note how that mentions `&str: Expression` before and now mentions `&str: AsExpression<Integer>` instead which is much more helpful for users.

Open points for further changes before stabilization:

* We likely want to move the attribute to the `#[diagnostic]` namespace to relax the guarantees given?
* How does it interact with the new trait solver?

r? `@estebank`
2024-05-19 11:04:08 -04:00
Guillaume Gomez 2f8b98c664 Migrate `run-make/rustdoc-scrape-examples-test` to new `rmake.rs` 2024-05-19 15:02:30 +02:00
Georg Semmler 9b45cfdbdd
Actually use the `#[do_not_recommend]` attribute if present
This change tweaks the error message generation to actually use the
`#[do_not_recommend]` attribute if present by just skipping the marked
trait impl in favour of the parent impl. It also adds a compile test for
this behaviour. Without this change the test would output the following
error:

```
error[E0277]: the trait bound `&str: Expression` is not satisfied
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15
   |
LL |     SelectInt.check("bar");
   |               ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>`
   |
   = help: the following other types implement trait `Expression`:
             Bound<T>
             SelectInt
note: required for `&str` to implement `AsExpression<Integer>`
  --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13
   |
LL | impl<T, ST> AsExpression<ST> for T
   |             ^^^^^^^^^^^^^^^^     ^
LL | where
LL |     T: Expression<SqlType = ST>,
   |        ------------------------ unsatisfied trait bound introduced here
```

Note how that mentions `&str: Expression` before and now mentions `&str:
AsExpression<Integer>` instead which is much more helpful for users.

Open points for further changes before stabilization:

* We likely want to move the attribute to the `#[diagnostic]` namespace
to relax the guarantees given?
* How does it interact with the new trait solver?
2024-05-19 08:29:27 +02:00
bors 6579ed89f0 Auto merge of #124500 - VladimirMakaev:lldb-str-formatters, r=Mark-Simulacrum
lldb-formatters: Use StdSliceSyntheticProvider for &str

&str has associated summary provider which correctly displays string values in debugger, but while working on https://github.com/rust-lang/rust/pull/124458 I've noticed that a &str inside an enum displays a blob of memory until a 0 is reached (as a c-string) which makes a very bizarre experience when debugging

However there is already StdSliceSyntheticProvider which we use for other slices. This PR enables the same synthetic provider to be used for &str, however the summary provider is still fixed to return the string value

I've added a test `debuginfo/strings-and-strs.rs` which prior to this PR would output the following in LLDB:
```
* thread #1, name = 'a', stop reason = breakpoint 1.1
    frame #0: 0x0000555555556383 a`strings_and_strs::main::h1d2b5f9227b8767d at strings-and-strs.rs:47:5
   44  	    let plain_str = "Hello";
   45  	    let str_in_struct = Foo { inner: "Hello" };
   46  	    let str_in_tuple = ("Hello", "World");
-> 47  	    zzz(); // #break
   48  	}
   49
   50  	fn zzz() {
(lldb) frame var
(alloc::string::String) plain_string = "Hello" {
  vec = size=5 {
    [0] = 'H'
    [1] = 'e'
    [2] = 'l'
    [3] = 'l'
    [4] = 'o'
  }
}
(&str) plain_str = "Hello" {
  data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py"
  length = 5
}
(strings_and_strs::Foo) str_in_struct = {
  inner = "Hello" {
    data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py"
    length = 5
  }
}
((&str, &str)) str_in_tuple = {
  0 = "Hello" {
    data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py"
    length = 5
  }
  1 = "World" {
    data_ptr = 0x0000555555557268 "World\U00000001gdb_load_rust_pretty_printers.py"
    length = 5
  }
}
```
After this PR it would look the following way:

```
* thread #1, name = 'a', stop reason = breakpoint 1.1
    frame #0: 0x0000555555556383 a`strings_and_strs::main::h1d2b5f9227b8767d at strings-and-strs.rs:47:5
   44  	    let plain_str = "Hello";
   45  	    let str_in_struct = Foo { inner: "Hello" };
   46  	    let str_in_tuple = ("Hello", "World");
-> 47  	    zzz(); // #break
   48  	}
   49
   50  	fn zzz() {
(lldb) frame var
(alloc::string::String) plain_string = "Hello" {
  vec = size=5 {
    [0] = 'H'
    [1] = 'e'
    [2] = 'l'
    [3] = 'l'
    [4] = 'o'
  }
}
(&str) plain_str = "Hello" {
  [0] = 'H'
  [1] = 'e'
  [2] = 'l'
  [3] = 'l'
  [4] = 'o'
}
(strings_and_strs::Foo) str_in_struct = {
  inner = "Hello" {
    [0] = 'H'
    [1] = 'e'
    [2] = 'l'
    [3] = 'l'
    [4] = 'o'
  }
}
((&str, &str)) str_in_tuple = {
  0 = "Hello" {
    [0] = 'H'
    [1] = 'e'
    [2] = 'l'
    [3] = 'l'
    [4] = 'o'
  }
  1 = "World" {
    [0] = 'W'
    [1] = 'o'
    [2] = 'r'
    [3] = 'l'
    [4] = 'd'
  }
}
```
2024-05-19 04:18:52 +00:00
Jubilee Young 1914c722b5 compiler: add simd_ctpop intrinsic 2024-05-18 18:11:20 -07:00
Matthias Krüger 734e216b35 crashes: add more 2024-05-18 23:56:57 +02:00
bors b1ec1bd65f Auto merge of #125257 - jieyouxu:rollup-11evnm9, r=jieyouxu
Rollup of 3 pull requests

Successful merges:

 - #125214 (Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability)
 - #125236 (Add tests for `-Zunpretty=expanded` ported from stringify's tests)
 - #125251 (Clarify how String::leak and into_boxed_str differ )

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-18 21:45:06 +00:00
许杰友 Jieyou Xu (Joe) ffc04dfcc6
Rollup merge of #125236 - dtolnay:expandtest, r=nnethercote
Add tests for `-Zunpretty=expanded` ported from stringify's tests

This PR adds a new set of tests for the AST pretty-printer.

Previously, pretty-printer edge cases were tested by way of `stringify!` in [tests/ui/macros/stringify.rs](https://github.com/rust-lang/rust/blob/1.78.0/tests/ui/macros/stringify.rs), such as the tests added by 419b26931b and 527e2eac17.

Those tests will no longer provide effective coverage of the AST pretty-printer after #124141. `Nonterminal` and `TokenKind::Interpolated` are being removed, and a consequence is that `stringify!` will perform token stream pretty printing, instead of AST pretty printing, in all of the `stringify!` cases including $:expr and all other interpolations.

This PR adds 2 new ui tests with `compile-flags: -Zunpretty=expanded`:

- **tests/ui/unpretty/expanded-exhaustive.rs** &mdash; this test aims for exhaustive coverage of all the variants of `ExprKind`, `ItemKind`, `PatKind`, `StmtKind`, `TyKind`, and `VisibilityKind`. Some parts could use being fleshed out further, but the current state is roughly on par with what exists in the old stringify-based tests.

- **tests/ui/unpretty/expanded-interpolation.rs** &mdash; this test covers tricky macro metavariable edge cases that require the AST pretty printer to synthesize parentheses in order for the printed code to be valid Rust syntax.

r? `@nnethercote`
2024-05-18 20:38:05 +01:00
许杰友 Jieyou Xu (Joe) f08746a95d
Rollup merge of #125214 - compiler-errors:gat-guide, r=lcnr
Only make GAT ambiguous in `match_projection_projections` considering shallow resolvability

In #123537, I tweaked the hack from #93892 to use `resolve_vars_if_possible` instead of `shallow_resolve`. This considers more inference guidance ambiguous. This resulted in crater regressions in #125196.

I've effectively reverted the change to the old behavior. That being said, I don't *like* this behavior, but I'd rather keep it for now since #123537 was not meant to make any behavioral changes. See the attached example.

This also affects the new solver, for the record, which doesn't have any rules about not guiding inference from param-env candidates which may constrain GAT args as a side-effect.

r? `@lcnr` or `@jackh726`
2024-05-18 20:38:04 +01:00
bors eb1a5c9bb3 Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726
Rename Unsafe to Safety

Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks.

This leaves us today with:

```rust
enum ast::Safety {
    Unsafe(Span),
    Default,
    // Safe (going to be added for unsafe extern blocks)
}

enum hir::Safety {
    Unsafe,
    Safe,
}
```

We would convert from `ast::Safety::Default` into the right Safety level according the context.
2024-05-18 19:35:24 +00:00
David Tolnay 3e05be5466
Add tests for -Zunpretty=expanded ported from stringify's tests 2024-05-18 10:36:02 -07:00
Michael Goulet 5ee4db4e05 Warn/error on self ctor from outer item in inner item 2024-05-18 13:08:34 -04:00
Michael Goulet 2e97dae8d4 An async closure may implement FnMut/Fn if it has no self-borrows 2024-05-18 12:47:59 -04:00
Matthias Krüger cd1ca14c48
Rollup merge of #125248 - GuillaumeGomez:migrate-rustdoc-scrape-examples-invalid-expr, r=jieyouxu
Migrate `run-make/rustdoc-scrape-examples-invalid-expr` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
2024-05-18 18:44:15 +02:00
Matthias Krüger e4e75688c2
Rollup merge of #125184 - scottmcm:fix-thin-ptr-ice, r=jieyouxu
Fix ICE in non-operand `aggregate_raw_ptr` intrinsic codegen

Introduced in #123840
Found in #121571, cc `@clarfonthey`
2024-05-18 18:44:14 +02:00
Matthias Krüger f9bf759e83
Rollup merge of #125117 - dev-ardi:improve-parser, r=wesleywiser,fmease
Improve parser

Fixes #124935.

- Add a few more help diagnostics to incorrect semicolons
- Overall improved that function
- Addded a few comments
- Renamed diff_marker fns to git_diff_marker
2024-05-18 18:44:14 +02:00
blyxyas c5c820e7fb Fix typos (taking into account review comments) 2024-05-18 18:12:18 +02:00
Guillaume Gomez 14ae96470f Migrate `run-make/rustdoc-scrape-examples-invalid-expr` to `rmake.rs` 2024-05-18 15:35:00 +02:00
bors 685a80f7a0 Auto merge of #125180 - mu001999-contrib:improve/macro-diag, r=fee1-dead
Improve error message: missing `;` in macro_rules

Fixes #124968
2024-05-18 13:02:48 +00:00
r0cky c2be1342b7 Improve error message: missing `;` in macro_rules 2024-05-18 18:56:12 +08:00
bors bb97203e37 Auto merge of #124611 - Urgau:rustdoc-stdin, r=GuillaumeGomez
Add `-` (stdin) support in rustdoc

This PR adds support for the special `-` input which threats the input as coming from *stdin* instead of being a filepath.

Doing this also makes `rustdoc` consistent with `rustc` and ~~every~~ other tools. Full [motivation](https://github.com/rust-lang/rust/pull/124611#issuecomment-2094234876).

Fixes https://github.com/rust-lang/rust/issues/123671
r? `@fmease`
2024-05-18 10:53:47 +00:00
bors 1c90b9fe6e Auto merge of #125004 - pymongo:issue-125002, r=estebank
Fix println! ICE when parsing percent prefix number

This PR fixes #125002 ICE occurring, for example, with `println!("%100000", 1)` or `println!("%    100000", 1)`.

## Test Case/Change Explanation

The return type of `Num::from_str` has been changed to `Option<Self>` to handle errors when parsing large integers fails.

1. The first `println!` in the test case covers the change of the first `Num::from_str` usage in `format_foreign.rs:426`.
2. The second `println!` in the test case covers the change of the second `Num::from_str` usage in line 460.
3. The 3rd to 5th `Num::from_str` usages behave the same as before.

The 3rd usage would cause an ICE when `num > u16::MAX` in the previous version, but this commit does not include a fix for the ICE in `println!("{:100000$}")`. I think we need to emit an error in the compiler and have more discussion in another issue/PR.
2024-05-18 08:44:01 +00:00
bors 36c0a6d40f Auto merge of #125105 - nnethercote:rustc_resolve-cleanups, r=estebank
`rustc_resolve` cleanups

Some improvements I found while looking through this code.

r? `@estebank`
2024-05-18 06:36:44 +00:00
Scott McMurray 95c0e5c6a8 Remove `Rvalue::CheckedBinaryOp` 2024-05-17 20:33:02 -07:00
wuaoxiang 582fd1fb53 Fix println! ICE when parsing percent prefix number 2024-05-18 01:05:56 +00:00
bors 8e78d16804 Auto merge of #125233 - jieyouxu:rollup-76hk8qu, r=jieyouxu
Rollup of 3 pull requests

Successful merges:

 - #125213 (Migrate `run-make/static-unwinding` to `rmake`)
 - #125215 (Migrate `run-make/issue64319` to `rmake` and rename)
 - #125221 (Migrate `run-make/issue-28766` to `rmake`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-18 00:04:01 +00:00
许杰友 Jieyou Xu (Joe) 650bbb5a77
Rollup merge of #125221 - Oneirical:fourth, r=jieyouxu
Migrate `run-make/issue-28766` 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-18 00:49:18 +01:00
许杰友 Jieyou Xu (Joe) d7498c2dbf
Rollup merge of #125215 - Oneirical:easy-test-the-second, r=jieyouxu
Migrate `run-make/issue64319` to `rmake` and rename

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

~~I noticed that the Makefile was not listed in `allowed-run-makefiles` in Tidy. Does this mean the test was being ignored?~~ EDIT: No, it was there, just not in its expected alphabetical order.

EDIT2: Perhaps it could be interesting to clean this test visually by looping over the `rustc` calls, like in #125227.
2024-05-18 00:49:17 +01:00
许杰友 Jieyou Xu (Joe) cb90c0a1d3
Rollup merge of #125213 - Oneirical:easy-test, r=jieyouxu
Migrate `run-make/static-unwinding` 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).

An easy one after the last one, though the explanatory comment could use some clarification.
2024-05-18 00:49:17 +01:00
bors 9b75a43881 Auto merge of #123865 - eholk:expr_2021, r=fmease
Update `expr` matcher for Edition 2024 and add `expr_2021` nonterminal

This commit adds a new nonterminal `expr_2021` in macro patterns, and `expr_fragment_specifier_2024` feature flag.

This change also updates `expr` so that on Edition 2024 it will also match `const { ... }` blocks, while `expr_2021` preserves the current behavior of `expr`, matching expressions without `const` blocks.

Joint work with `@vincenzopalazzo.`

Issue #123742
2024-05-17 21:54:14 +00:00
Santiago Pastorino 6b46a919e1
Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
Esteban Küber cf5702ee91 Detect when a lifetime is being reused in suggestion 2024-05-17 21:23:47 +00:00
Esteban Küber 1775e7b93d Tweak suggested lifetimes to modify return type instead of `&self` receiver
Do not suggest constraining the `&self` param, but rather the return type.
If that is wrong (because it is not sufficient), a follow up error will tell the
user to fix it. This way we lower the chances of *over* constraining, but still
get the cake of "correctly" contrained in two steps.

This is a correct suggestion:

```
error: lifetime may not live long enough
  --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:9
   |
LL |     fn foo<'a>(&self, x: &i32) -> &i32 {
   |                -         - let's call the lifetime of this reference `'1`
   |                |
   |                let's call the lifetime of this reference `'2`
LL |         x
   |         ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
   |
help: consider introducing a named lifetime parameter and update trait if needed
   |
LL |     fn foo<'a>(&self, x: &'a i32) -> &'a i32 {
   |                           ++          ++
```

While this is incomplete because it should suggestino `&'a self`

```
error: lifetime may not live long enough
  --> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19
   |
LL |     fn foo<'a>(&self, x: &Foo) -> &Foo {
   |                -         - let's call the lifetime of this reference `'1`
   |                |
   |                let's call the lifetime of this reference `'2`
LL |         if true { x } else { self }
   |                   ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
   |
help: consider introducing a named lifetime parameter and update trait if needed
   |
LL |     fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
   |                           ++          ++
```

but the follow up error is

```
error: lifetime may not live long enough
 --> tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs:7:30
  |
6 |     fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
  |            --  - let's call the lifetime of this reference `'1`
  |            |
  |            lifetime `'a` defined here
7 |         if true { x } else { self }
  |                              ^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
  |
help: consider introducing a named lifetime parameter and update trait if needed
  |
6 |     fn foo<'a>(&'a self, x: &'a Foo) -> &'a Foo {
  |                 ++
```
2024-05-17 20:31:13 +00:00
Esteban Küber ee5a157b4a Run `rustfmt` on modified tests 2024-05-17 20:31:13 +00:00
Esteban Küber d1d585d039 Account for owning item lifetimes in suggestion and annotate tests as `run-rustfix`
```
error: lifetime may not live long enough
  --> $DIR/lt-ref-self.rs:12:9
   |
LL |     fn ref_self(&self, f: &u32) -> &u32 {
   |                 -         - let's call the lifetime of this reference `'1`
   |                 |
   |                 let's call the lifetime of this reference `'2`
LL |         f
   |         ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
   |
help: consider introducing a named lifetime parameter and update trait if needed
   |
LL |     fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 {
   |                ++++  ++           ++          ++
```
2024-05-17 20:31:13 +00:00
Esteban Küber 120049fab4 Always constrain the return type in lifetime suggestion
```
error: lifetime may not live long enough
 --> f205.rs:8:16
  |
7 |     fn resolve_symbolic_reference(&self, reference: Option<Reference>) -> Option<Reference> {
  |                                   -      --------- has type `Option<Reference<'1>>`
  |                                   |
  |                                   let's call the lifetime of this reference `'2`
8 |         return reference;
  |                ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
  |
help: consider introducing a named lifetime parameter
  |
7 |     fn resolve_symbolic_reference<'a>(&'a self, reference: Option<Reference<'a>>) -> Option<Reference<'a>> {
  |                                  ++++  ++                                  ++++                      ++++
```

The correct suggestion would be

```
help: consider introducing a named lifetime parameter
  |
7 |     fn resolve_symbolic_reference<'a>(&self, reference: Option<Reference<'a>>) -> Option<Reference<'a>> {
  |                                  ++++                                   ++++                      ++++
```

but we are not doing the analysis to detect that yet. If we constrain `&'a self`, then the return type with a borrow will implicitly take its lifetime from `'a`, it is better to make it explicit in the suggestion, in case that `&self` *doesn't* need to be `'a`, but the return does.
2024-05-17 20:31:13 +00:00
Esteban Küber 9f730e92f2 Suggest setting lifetime in borrowck error involving types with elided lifetimes
```
error: lifetime may not live long enough
  --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5
   |
LL | fn foo(mut x: Ref, y: Ref) {
   |        -----       - has type `Ref<'_, '1>`
   |        |
   |        has type `Ref<'_, '2>`
LL |     x.b = y.b;
   |     ^^^^^^^^^ assignment requires that `'1` must outlive `'2`
   |
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: Ref<'a, 'a>) {
   |       ++++           ++++++++        ++++++++
```

As can be seen above, it currently doesn't try to compare the `ty::Ty` lifetimes that diverged vs the `hir::Ty` to correctly suggest the following

```
help: consider introducing a named lifetime parameter
   |
LL | fn foo<'a>(mut x: Ref<'_, 'a>, y: Ref<'_, 'a>) {
   |       ++++           ++++++++        ++++++++
```

but I believe this to still be an improvement over the status quo.

CC #40990.
2024-05-17 20:31:13 +00:00
Oneirical 8c43e54ad9 fix: swap the error codes 2024-05-17 15:42:33 -04:00
Julien 9d0b75f75e
missing import 2024-05-17 14:55:14 -04:00
Oneirical e9edced096 rewrite and rename issue-28766 2024-05-17 14:44:21 -04:00
Oneirical abdaed2fa9 tidy fix 2024-05-17 14:06:38 -04:00
Oneirical f0b8da4430 rewrite no-intermediate-extras 2024-05-17 13:29:43 -04:00
Michael Goulet fa829feb2f Only make GAT ambiguous in match_projection_projections considering shallow resolvability 2024-05-17 12:51:21 -04:00
Oneirical 14a031fdf6 rewrite issue64319 and rename 2024-05-17 11:49:20 -04:00
Oneirical 760b505c9a Rewrite static-unwinding as rmake.rs 2024-05-17 11:06:21 -04:00
Guillaume Gomez 272fc89a1c Use common `scrape.rs` file 2024-05-17 14:04:22 +02:00
Guillaume Gomez e509c24fbf Migrate `run-make/rustdoc-scrape-examples-remap` to `rmake.rs` 2024-05-17 14:04:22 +02:00
bors a5c37eea5a Auto merge of #125178 - GuillaumeGomez:migrate-rustdoc-with-out-dir, r=jieyouxu
Migrate `run-make/rustdoc-with-out-dir-option` to new `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
2024-05-17 08:51:06 +00:00
Matthias Krüger 3695449a89
Rollup merge of #125191 - compiler-errors:wf, r=lcnr
Report better WF obligation leaf obligations in new solver

r? lcnr
2024-05-17 07:20:59 +02:00
Matthias Krüger e62688eb96
Rollup merge of #123694 - Xiretza:expand-diagnostics, r=compiler-errors
expand: fix minor diagnostics bug

The error mentions `///`, when it's actually `//!`:

```
error[E0658]: attributes on expressions are experimental
 --> test.rs:4:9
  |
4 |         //! wah
  |         ^^^^^^^
  |
  = note: see issue https://github.com/rust-lang/rust/issues/15701 <https://github.com/rust-lang/rust/issues/15701> for more information
  = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
  = help: `///` is for documentation comments. For a plain comment, use `//`.
```
2024-05-17 07:20:56 +02:00
bors 8af67ba01a Auto merge of #124129 - lqd:enable-lld, r=Mark-Simulacrum
Enable `rust-lld` on nightly `x86_64-unknown-linux-gnu`

We believe we have done virtually all the internal work and tests we could to prepare for using `lld` as the default linker (at least on Linux). We're IMHO at a point where we'd need to expand testing and coverage in order to make progress on this effort.

Therefore, for further testing and gathering real-world feedback, unexpected issues and use-cases, this PR enables `rust-lld` as the default linker:
- on nightly only (and dev channel)
- on `x86_64-unknown-linux-gnu` only
- when not using an external LLVM (except `download-ci-llvm`), so that distros are not impacted

as described in more detail in this [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Enabling.20.60rust-lld.60.20on.20nightly.20.60x86_64-unknown-linux-gnu.60/near/433709343).

In case any issues happen to users, as e.g. lld is not bug-for-bug compatible with GNU ld, it's easy to disable with `-Zlinker-features=-lld` to revert to using the system's default linker.

---

I don't know who should review this kind of things, as it's somewhat of a crosscutting effort. Compiler contributor, compiler performance WG and infra member sounds perfect, so r? `@Mark-Simulacrum.`

The last crater run encountered a low number (44) of mainly avoidable issues, like small incompatibilities, user errors, and a difference between the two linkers about which default to use with `--gc-sections`. [Here's the triage report](https://hackmd.io/OAJxlxc6Te6YUot9ftYSKQ?view), categorizing the issues, with some analyses and workarounds. I'd appreciate another set of eyes looking at these results.

The changes in this PR have been test-driven for CI changes, try builds with tests enabled, rustc-perf with bootstrapping, in PR #113382.

For infra, about the CI change: this PR forces `rust.lld` to false on vanilla LLVM builders, just to make sure we have coverage without `rust-lld`. Though to be clear, just using an external LLVM is already enough to keep `rust.lld` to false, in turn reverting everything to using the system's default linker.

cc `@rust-lang/bootstrap` for the bootstrap and config change
cc `@petrochenkov` for the small compiler change
cc `@rust-lang/wg-compiler-performance`

The blog post announcing the change, that we expect to merge around the same time as we merge this PR, is open [on the blog repo](https://github.com/rust-lang/blog.rust-lang.org/pull/1319).

Bootstrap change history: this PR changes the default of a config option on `x86_64-unknown-linux-gnu`. It's, however, not expected to cause issues, or require any changes to existing configurations. It's a big enough change that people should at least know about it, in case it causes unexpected problems. If that happens, set `rust.lld = false` in your `config.toml` (and open an issue).
2024-05-17 02:12:10 +00:00
Michael Goulet 119c7bbef7 Report better WF obligation leaf obligations in new solver 2024-05-16 21:08:42 -04:00
Guillaume Gomez d594c9ceea Add missing assert! calls 2024-05-17 00:47:18 +02:00
Guillaume Gomez 8124a5e74d Migrate `run-make/rustdoc-with-out-dir-option` to new `rmake.rs` 2024-05-17 00:46:21 +02:00
Urgau 05f77d1b79 Update `unexpected_cfgs` lint for Cargo new `check-cfg` config 2024-05-16 20:58:22 +02:00
Scott McMurray f60f2e8cb0 Fix ICE in non-operand `aggregate_raw_ptr` instrinsic codegen 2024-05-16 09:43:42 -07:00
Rémy Rakic 4d280de47c test rust-lld is on by default on the x64 linux target 2024-05-16 16:08:07 +00:00
Matthias Krüger e3864db418
Rollup merge of #125172 - tgross35:f16-f128-as-casting, r=compiler-errors
Fix assertion when attempting to convert `f16` and `f128` with `as`

These types are currently rejected for `as` casts by the compiler. Remove this incorrect check and add codegen tests for all conversions involving these types.
2024-05-16 16:22:46 +02:00
Michael Goulet d3e510eb9d Don't ICE because recomputing overflow goals during find_best_leaf_obligation causes inference side-effects 2024-05-16 10:00:11 -04:00
cardigan1008 c811acb1f3 feat: add unit test 2024-05-16 21:10:07 +08:00
Trevor Gross 488ddd3bbc Fix assertion when attempting to convert `f16` and `f128` with `as`
These types are currently rejected for `as` casts by the compiler.
Remove this incorrect check and add codegen tests for all conversions
involving these types.
2024-05-16 04:07:02 -05:00
bors b71e8cbaf2 Auto merge of #124987 - workingjubilee:macro-metavar-expr-with-a-shorter-len, r=c410-f3r,joshtriplett,joshtriplett
Rename `${length()}` to `${len()}`

Implements the rename suggested in https://github.com/rust-lang/rust/pull/122808#issuecomment-2047722187
> I brought this up in the doc PR but it belongs here – `length` should probably be renamed `len` before stabilization. The latter is de facto standard in the standard library, whereas the former is only used in a single unstable API. These metafunctions aren’t library items of course, but should presumably still be consistent with established names.

r? `@c410-f3r`
2024-05-16 00:26:20 +00:00
León Orell Valerian Liehr 09156291e5
Rollup merge of #125146 - Oneirical:panic-impl, r=jieyouxu
Migrate `run-make/panic-impl-transitive` 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).

The test itself is quite simple, but the "handle panics by entering infinite loop" part is strange.
2024-05-15 22:01:19 +02:00
León Orell Valerian Liehr 80f991e09b
Rollup merge of #125142 - GuillaumeGomez:migrate-rustdoc-themes, r=jieyouxu
Migrate `run-make/rustdoc-themes` to new rmake.rs

Part of https://github.com/rust-lang/rust/issues/121876.

r? `@jieyouxu`
2024-05-15 22:01:19 +02:00
Zachary S 6b818ddac6 Fix article in test 2024-05-15 13:17:11 -05:00
Zachary S ea549fd176 Add tests for 'Also apply `warn(for_loops_over_fallibles)` to &T and &mut T, not just T = Result/Option.' 2024-05-15 11:53:40 -05:00
David Koloski 1b934f3e8c Sort mutually-exclusive pairs, update fixed tests 2024-05-15 15:40:52 +00:00
bors b21b74b5e6 Auto merge of #125134 - compiler-errors:negative-traits-are-not-notable, r=fmease
rustdoc: Negative impls are not notable

In #124097, we add `impl !Iterator for [T]` for coherence reasons, and since `Iterator` is a [notable trait](8387315ab3/library/core/src/iter/traits/iterator.rs (L40)), this means that all `-> &[_]` now are tagged with a `!Iterator` impl as a notable trait.

I "fixed" the failing tests in that PR with 6cbbb8b709a43482847243484ed67131e372ba71, where I just blessed the tests, since I didn't want to mix these changes with that PR; however, don't believe negative impls are notable, and this PR aims to prevent these impls from being mentioned.

In the standard library, we use negative impls purely to guide coherence. They're not really a signal of anything useful to the end-user. If there ever is a case that we want negative impls to be mentioned as notable, this really should be an opt-in feature.
2024-05-15 14:52:49 +00:00
Oneirical a7484d2e49 fix tidy 2024-05-15 10:09:19 -04:00
Oneirical cae17ff42b rewrite panic-impl-transitive 2024-05-15 09:58:47 -04:00
bors ade234d574 Auto merge of #125144 - fmease:rollup-4uft293, r=fmease
Rollup of 6 pull requests

Successful merges:

 - #124307 (Optimize character escaping.)
 - #124975 (Use an helper to move the files)
 - #125027 (Migrate `run-make/c-link-to-rust-staticlib` to `rmake`)
 - #125038 (Invert comparison in `uN::checked_sub`)
 - #125104 (Migrate `run-make/no-cdylib-as-rdylib` to `rmake`)
 - #125137 (MIR operators: clarify Shl/Shr handling of negative offsets)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-15 12:43:34 +00:00
León Orell Valerian Liehr 2659ff3882
Rollup merge of #125104 - Oneirical:test6, r=jieyouxu
Migrate `run-make/no-cdylib-as-rdylib` 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).

> "the test will fail if the cdylib is picked, because it doesn't export any rust symbols"

Is that true? Is there a way to verify?

I suggest maybe extending the test with: (after cleaning the directory)

```rust
    rustc()
        .input("bar.rs")
        .crate_type("cdylib")
        .run();
    rustc()
        .input("foo.rs")
        .prefer_dynamic()
        .run();
    fail();
```

to make sure we're actually testing something here.
2024-05-15 14:21:39 +02:00
León Orell Valerian Liehr 2804d4223b
Rollup merge of #125027 - Oneirical:c-test-with-remove, r=jieyouxu
Migrate `run-make/c-link-to-rust-staticlib` to `rmake`

Part of #121876.

r? `@jieyouxu`
2024-05-15 14:21:38 +02:00