Commit Graph

15352 Commits

Author SHA1 Message Date
Michael Goulet
54e33bbdec Account for C string literals in HiddenUnicodeCodepoints lint 2024-12-31 04:53:00 +00:00
Stuart Cook
a93bef6161
Rollup merge of #134933 - compiler-errors:async-fn-future-sized, r=lqd
Make sure we check the future type is `Sized` in `AsyncFn*`

Fixes #134817
2024-12-31 14:12:47 +11:00
Chris Denton
dc1f2be449
Add comments to -Zlink-* tests 2024-12-31 02:25:35 +00:00
Michael Goulet
f28e13b055 Fix span for IndexMut method call on HashMap/BTreeMap 2024-12-31 02:21:17 +00:00
Michael Goulet
6a3474e653 Use if-let in structured suggestion instead of Option::map 2024-12-31 02:21:17 +00:00
Michael Goulet
b994124778 Explain how to mutate a HashMap/BTreeMap with more nuance 2024-12-31 01:20:53 +00:00
Michael Goulet
aac741a465 Unsafe binder support in rustdoc 2024-12-31 01:08:43 +00:00
Michael Goulet
ed9a4cfdeb Make sure we check the future type is Sized in AsyncFn* 2024-12-31 00:46:46 +00:00
bors
4e5fec2f1e Auto merge of #134757 - RalfJung:const_swap, r=scottmcm
stabilize const_swap

libs-api FCP passed in https://github.com/rust-lang/rust/issues/83163.

However, I only just realized that this actually involves an intrinsic. The intrinsic could be implemented entirely with existing stable const functionality, but we choose to make it a primitive to be able to detect more UB. So nominating for `@rust-lang/lang`  to make sure they are aware; I leave it up to them whether they want to FCP this.

While at it I also renamed the intrinsic to make the "nonoverlapping" constraint more clear.

Fixes #83163
2024-12-30 23:46:42 +00:00
Chris Denton
7d5ff8b8bd
Windows: Enable issue 70093 link tests 2024-12-30 22:52:23 +00:00
Matthias Krüger
4b9e3daa0b
Rollup merge of #134911 - HigherOrderLogic:master, r=onur-ozkan
chore: fix typos

This PR fixes typos errors in docstring only, so functionality wise, it should stay the same.
2024-12-30 19:34:56 +01:00
Matthias Krüger
6c12546dc0
Rollup merge of #134871 - clubby789:test-63646, r=compiler-errors
Add codegen test for issue 63646

Closes #63646
2024-12-30 19:34:55 +01:00
bors
93722f7ed5 Auto merge of #134906 - jieyouxu:multi-crate-type, r=lqd,fmease
tests: add basic test coverage for stable `--crate-type` flag

I experimented locally with making the compiler panic if multiple crate types are passed to a single `--crate-type` flag, and it turns out not only does the compiler successfully bootstrap, only two ui tests failed:

```
failures:
    [ui] tests/ui/sepcomp/sepcomp-lib.rs
    [ui] tests/ui/sepcomp/sepcomp-lib-lto.rs

test result: FAILED. 4 passed; 2 failed; 18181 ignored; 0 measured; 0 filtered out; finished in 364.55ms
```

These are not specific tests for the `--crate-type` flag, only their auxiliary *happens* to use a `--crate-type` with two crate types:

```rs
//@ compile-flags: -C codegen-units=3 --crate-type=rlib,dylib -g
```

I was not able to find a specific test in run-make test suite either.

So this PR tries to add some basic test coverage for the stable `--crate-type` flag's interface (including to check that `--crate-type` accepts multiple crate types), since I imagine it might be slightly awkward if we accidentally regressed this.

r? compiler
2024-12-30 15:44:03 +00:00
Davis Muro
62c3c9a5ae
add suggestion for wrongly ordered format parameters 2024-12-30 06:14:26 -08:00
许杰友 Jieyou Xu (Joe)
92e8e84e7d tests: add basic test coverage for cli flag --crate-type 2024-12-30 19:10:43 +08:00
Horu
4c279fb7af chore: fix typos 2024-12-30 14:56:21 +07:00
Alex Gaynor
dab1c57723 Added codegen test for elidings bounds check when indexes are manually checked
Closes #55147
2024-12-29 08:02:40 -06:00
bors
fd19773d2f Auto merge of #134627 - estebank:issue-133252, r=jackh726
Avoid ICE in borrowck

Provide a fallback in `best_blame_constraint` when `find_constraint_paths_between_regions` doesn't have a result. This code is due a rework to avoid the letf-over `unwrap()`, but avoids the ICE caused by the repro.

Fix #133252.
2024-12-29 07:23:59 +00:00
clubby789
71e3ea35b1 Add codegen test for issue 63646 2024-12-29 03:31:37 +00:00
Guillaume Gomez
00bf8717e3 Add GUI test for item info elements color 2024-12-28 20:54:00 +01:00
Alex Gaynor
d6c73ebbf3 Added a codegen test for optimization with const arrays
Closes #107208
2024-12-28 13:28:35 -06:00
bors
4e0bc490c6 Auto merge of #131244 - clubby789:match-branches-unreachable, r=DianQK
Consider empty-unreachable otherwise branches in MatchBranchSimplification

Fixes #131219
2024-12-28 11:09:28 +00:00
bors
8b3f7ac526 Auto merge of #134844 - Zalathar:rollup-1225wh9, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - #134737 (Implement `default_overrides_default_fields` lint)
 - #134760 (Migrate `branch-protection-check-IBT` to rmake.rs)
 - #134829 (Migrate `libs-through-symlink` to rmake.rs)
 - #134832 (Update `compiler-builtins` to 0.1.140)
 - #134840 (compiletest: Only pass the post-colon value to `parse_normalize_rule`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-28 08:26:48 +00:00
Stuart Cook
41c74f4fb6
Rollup merge of #134840 - Zalathar:normalize, r=jieyouxu
compiletest: Only pass the post-colon value to `parse_normalize_rule`

Addresses one of the FIXMEs noted in #134759.

I started working on the other FIXME, but it became complex enough that I wanted to split it off from this PR.

r? jieyouxu
2024-12-28 16:50:39 +11:00
Stuart Cook
3048c4adfc
Rollup merge of #134829 - jieyouxu:migrate-libs-through-symlinks, r=lqd
Migrate `libs-through-symlink` to rmake.rs

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

This PR migrates `tests/run-make/libs-through-symlink/` to use rmake.rs.

- Regression test for #13890.
- Original fix PR is #13903.
- Document test intent, backlink to #13890 and fix PR #13903.
- Fix the test logic: the `Makefile` version seems to not actually be exercising the "library search traverses symlink" logic, because the actual symlinked-to-library is present under the `$(TMPDIR)` directory tree when `bar.rs` is compiled, because the `$(RUSTC)` invocation has an implicit `-L $(TMPDIR)`. The symlink itself was actually broken, i.e. it should've been `ln -nsf $(TMPDIR)/outdir/$(NAME) $(TMPDIR)` but it used `ln -nsf outdir/$(NAME) $(TMPDIR)`. The rmake.rs version now explicitly separates the two directory trees and sets the CWD of the `bar.rs` rustc invocation so that the actual library is *not* present under its CWD tree.

I.e. it is now

```
$test_output/           # rustc foo.rs -o actual_lib_dir/libfoo.rlib
    actual_lib_dir/
        libfoo.rlib
    symlink_lib_dir/    # CWD set; rustc -L . bar.rs
        libfoo.rlib --> $test_output/actual_lib_dir/libfoo.rlib
```

Partially supersedes #129011.
This PR is co-authored with `@Oneirical.`

r? compiler
2024-12-28 16:50:38 +11:00
Stuart Cook
dd03fba6dd
Rollup merge of #134760 - jieyouxu:enable-branch-protection-check-IBT, r=lqd
Migrate `branch-protection-check-IBT` to rmake.rs

- The Makefile version *never* ran because of Makefile syntax confusion because `ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86_64)` [compares `x86` to `x86_64`, which always evaluates to false](https://github.com/rust-lang/rust/pull/126720#discussion_r1646808973).
- The test would've always failed because precompiled std is not built with `-Z cf-protection=branch`, but linkers require all input object files to indicate IBT support in order to enable IBT for the executable, which is not the case for std.
- Thus, the test input file is instead changed to a `no_std` program.
- The test is currently limited to only `x86_64-unknown-linux-gnu` host, there are various other problems when the test is cross-compiled that I didn't want to fix atm, and is left as an exercise for the `-Z cf-protection` implementers.

The GNU property note was added by #110304 in order to address #103001.

Partially supersedes #129156.
The rmake.rs port was initially authored by `@Rejyr` in #126720.
This PR is co-authored with `@Oneirical` and `@Rejyr.`

r? `@bjorn3` or reroll

try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
try-job: x86_64-msvc
try-job: x86_64-apple-1
try-job: x86_64-apple-2
2024-12-28 16:50:37 +11:00
Stuart Cook
3e3db73c9b
Rollup merge of #134737 - estebank:deive-lint-default-fields-base, r=compiler-errors
Implement `default_overrides_default_fields` lint

Detect when a manual `Default` implementation isn't using the existing default field values and suggest using `..` instead:

```
error: `Default` impl doesn't use the declared default field values
  --> $DIR/manual-default-impl-could-be-derived.rs:14:1
   |
LL | / impl Default for A {
LL | |     fn default() -> Self {
LL | |         A {
LL | |             y: 0,
   | |                - this field has a default value
...  |
LL | | }
   | |_^
   |
   = help: use the default values in the `impl` with `Struct { mandatory_field, .. }` to avoid them diverging over time
note: the lint level is defined here
  --> $DIR/manual-default-impl-could-be-derived.rs:5:9
   |
LL | #![deny(default_overrides_default_fields)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

r? `@compiler-errors`

This is a simpler version of #134441, detecting the simpler case when a field with a default should have not been specified in the manual `Default::default()`, instead using `..` for it. It doesn't provide any suggestions, nor the checks for "equivalences" nor whether the value used in the imp being used would be suitable as a default field value.
2024-12-28 16:50:36 +11:00
bors
7cb084932e Auto merge of #134842 - jieyouxu:disable-flaky-test, r=ibraheemdev
Disable `backtrace-debuginfo.rs` on windows-gnu

This test appears still flaky cf. #117097 on `i686-mingw` as observed in https://github.com/rust-lang/rust/pull/131244#issuecomment-2564086577.

r? compiler (or anyone, really)
2024-12-28 05:48:39 +00:00
许杰友 Jieyou Xu (Joe)
b32591e580 tests: migrate branch-protection-check-IBT to rmake.rs
- The Makefile version *never* ran because of Makefile syntax confusion.
- The test would've always failed because precompiled std is not built
  with `-Z cf-protection=branch`, but linkers require all input object
  files to indicate IBT support in order to enable IBT for the
  executable, which is not the case for std.
- Thus, the test input file is instead changed to a `no_std` + `no_core`
  program.

Co-authored-by: Jerry Wang <jerrylwang123@gmail.com>
Co-authored-by: Oneirical <manchot@videotron.ca>
2024-12-28 11:58:32 +08:00
许杰友 Jieyou Xu (Joe)
b77ab2dd90 tests: migrate libs-through-symlink to rmake.rs
- Document test intent, backlink to #13890 and fix PR #13903.
- Fix the test logic: the `Makefile` version seems to not actually be
  exercising the "library search traverses symlink" logic, because the
  actual symlinked-to-library is present under the directory tree when
  `bar.rs` is compiled, because the `$(RUSTC)` invocation has an
  implicit `-L $(TMPDIR)`. The symlink itself was actually broken, i.e.
  it should've been `ln -nsf $(TMPDIR)/outdir/$(NAME) $(TMPDIR)` but it
  used `ln -nsf outdir/$(NAME) $(TMPDIR)`.

Co-authored-by: Oneirical <manchot@videotron.ca>
2024-12-28 11:53:01 +08:00
许杰友 Jieyou Xu (Joe)
378dc0357d Disable backtrace-debuginfo.rs on windows-gnu 2024-12-28 11:19:16 +08:00
Zalathar
ef19017f7c compiletest: Self-test for normalize-* with revisions 2024-12-28 13:57:13 +11:00
David Tolnay
0a09252866
Rollup merge of #134834 - dtolnay:unnamedcall, r=compiler-errors
Skip parenthesis around tuple struct field calls

The pretty-printer previously did not distinguish between named vs unnamed fields when printing a function call containing a struct field. It would print the call as `(self.fun)()` for a named field which is correct, and `(self.0)()` for an unnamed field which is redundant.

This PR changes function calls of tuple struct fields to print without parens.

**Before:**

```rust
struct Tuple(fn());

fn main() {
    let tuple = Tuple(|| {});
    (tuple.0)();
}
```

**After:**

```rust
struct Tuple(fn());

fn main() {
    let tuple = Tuple(|| {});
    tuple.0();
}
```
2024-12-27 18:43:05 -08:00
David Tolnay
3fc0f08b89
Rollup merge of #134833 - dtolnay:leftmostwithdot, r=compiler-errors
Skip parenthesis if `.` makes statement boundary unambiguous

There is a rule in the parser that statements and match-arms never end in front of a `.` or `?` token (except when the `.` is really `..` or `..=` or `...`). So some of the leading subexpressions that need parentheses inserted when followed by some other operator like `-` or `+`, do not need parentheses when followed by `.` or `?`.

Example:

```rust
fn main() {
    loop {}.to_string() + "";
    match () {
        _ => loop {}.to_string() + "",
    };
}
```

`-Zunpretty=expanded` before:

```console
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
fn main() {
    (loop {}).to_string() + "";
    match () { _ => (loop {}).to_string() + "", };
}
```

After:

```console
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
fn main() {
    loop {}.to_string() + "";
    match () { _ => loop {}.to_string() + "", };
}
```
2024-12-27 18:43:05 -08:00
David Tolnay
26bb4e6464
Skip parenthesis around tuple struct field calls 2024-12-27 14:33:56 -08:00
David Tolnay
c95f9f50de
Add pretty-printer test of tuple field function call 2024-12-27 14:18:39 -08:00
David Tolnay
e67fe3698b
Skip parenthesis if . makes statement boundary unambiguous 2024-12-27 13:53:02 -08:00
David Tolnay
fef8ec5ad9
Add test of dot after eager statement boundary expr 2024-12-27 13:41:46 -08:00
Matthias Krüger
26fb78a891
Rollup merge of #134798 - compiler-errors:err-auto, r=jackh726
Make `ty::Error` implement all auto traits

I have no idea what's up with the crashes test I fixed--I really don't want to look into it since it has to do something with borrowck and multiple layers of opaques. I think the underlying idea of allowing error types to implement all auto traits is justified though.

Fixes #134796
Fixes #131050

r? lcnr
2024-12-27 19:47:10 +01:00
Matthias Krüger
95e66ff8b4
Rollup merge of #133663 - scottmcm:carrying_mul_add, r=Amanieu
Add a compiler intrinsic to back `bigint_helper_methods`

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

This adds a new `carrying_mul_add` intrinsic, to implement `wide_mul` and `carrying_mul`.

It has fallback MIR for all types -- including `u128`, which isn't currently supported on nightly -- so that it'll continue to work on all backends, including CTFE.

Then it's overridden in `cg_llvm` to use wider intermediate types, including `i256` for `u128::carrying_mul`.
2024-12-27 19:47:09 +01:00
Scott McMurray
4669c0d756 Override carrying_mul_add in cg_llvm 2024-12-27 08:17:40 -08:00
许杰友 Jieyou Xu (Joe)
d419cc7c6a
Rollup merge of #134806 - notriddle:notriddle/parent-path-is-better, r=GuillaumeGomez
rustdoc: use shorter paths as preferred canonical paths

This is a solution to [the `std::sync::poison` linking problem](https://github.com/rust-lang/rust/pull/134692#issuecomment-2560373308), and, in general, makes intra-doc links shorter and clearer.

> Done. This helped with the search, but not with the things like `MutexGuard`'s doc's reference to `Mutex::lock` being converted to the absolute (unstable) `std::sync::poison::Mutex` path.

cc `@tgross35`

r? `@GuillaumeGomez`
2024-12-27 20:44:13 +08:00
许杰友 Jieyou Xu (Joe)
72ef16f519
Rollup merge of #134787 - fmease:spruce-up-queries, r=compiler-errors
Spruce up the docs of several queries related to the type/trait system and const eval

- Editorial
  - Proper rustdoc summary/synopsis line by making use of extra paragraphs: Leads to better rendered output on module pages, in search result lists and overall, too
  - Use rustdoc warning blocks for admonitions of the form "do not call / avoid calling this query directly"
  - Use intra-doc links of the form ``[`Self::$query`]`` to cross-link queries. Indeed, such links are generally a bit brittle due to the existence of `TyCtxtFeed` which only contains a subset of queries. Therefore the docs of `feedable` queries cannot cross-link to non-`feedable` ones. I'd say it's fine to use intra-doc links despite the potential/unlikely occasional future breakage (if a query with the aforementioned characteristics becomes `feedable`). `Self::` is nicer than `TyCtxt::` (which would be more stable) since it accounts for other contexts like `TyCtxt{Feed,At,Ensure{,WithValue}}`
- Informative
  - Generally add, flesh out and correct some doc comments
  - Add *Panic* sections (to a few selected queries only). The lists of panics aren't necessarily exhaustive and focus on the more "obvious" or "important" panics.
  - Where applicable add a paragraph calling attention to the relevant [`#[rustc_*]` TEST attribute](https://rustc-dev-guide.rust-lang.org/compiler-debugging.html#rustc_-test-attributes)

The one non-doc change (it's internal and not observable):
Be even more defensive in `query constness`'s impl (spiritual follow-up to #134122) (see self review comment).

Fixes #133494.

r\? **any**(compiler-errors, oli-obk)
2024-12-27 20:44:13 +08:00
许杰友 Jieyou Xu (Joe)
bc3e8917e3
Rollup merge of #134759 - Zalathar:normalize, r=jieyouxu
compiletest: Remove the `-test` suffix from normalize directives

This suffix was an artifact of using the same condition-checking engine as the `ignore-*` and `only-*` directives, but in practice we have only 2 tests that legitimately use a condition, and both of them only care about 32-bit vs 64-bit.

This PR detaches `normalize-*` directives from the condition checker, and replaces it with a much simpler system of four explicit `NormalizeKind` values. It then takes advantage of that simplicity to get rid of the `-test` suffix.

---

Addresses one of the points of #126372.

The new name-checking code is a bit quaint, but I think it's a definite improvement over the status quo.

---

The corresponding dev-guide update is https://github.com/rust-lang/rustc-dev-guide/pull/2172.

r? jieyouxu
2024-12-27 20:44:12 +08:00
clubby789
e32ec45c02 MatchBranchSimplification: Consider empty-unreachable otherwise branch 2024-12-27 10:57:46 +00:00
clubby789
11f7e302e1 Add diff test for MatchBranchSimplification 2024-12-27 10:46:58 +00:00
León Orell Valerian Liehr
454c09e355
Spruce up the docs of several queries related to the type/trait system and const eval 2024-12-27 11:44:23 +01:00
Zalathar
835fbcbcab Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
Jacob Pratt
b919afa70f
Rollup merge of #131522 - c410-f3r:unlock-rfc-2011, r=chenyukang
[macro_metavar_expr_concat] Fix #128346

Fix #128346
Fix #131393

The syntax is invalid in both issues so I guess that theoretically the compiler should have aborted early.

This PR tries to fix a local problem but let me know if there are better options.

cc `@petrochenkov` if you are interested
2024-12-26 21:56:47 -05:00
Zalathar
d997bc998e Simplify or delete normalize directives that don't care about bit-width 2024-12-27 12:42:07 +11:00
Michael Howell
da1c1c33ab Adjust test for slightly changed inlining behavior 2024-12-26 18:31:55 -07:00
Michael Howell
16a4ad7d7b rustdoc: use shorter paths as preferred canonical paths
This is a solution to the `std::sync::poison` linking problem,
and, in general, makes intra-doc links shorter and clearer.
2024-12-26 15:46:36 -07:00
Michael Goulet
f349d720e7 Make ty::Error implement auto traits 2024-12-26 19:21:43 +00:00
Guillaume Gomez
3d50eba781
Rollup merge of #134781 - Zalathar:backtrace, r=SparrowLii,jieyouxu
Add more `begin_panic` normalizations to panic backtrace tests

Since #123244, these tests have started failing locally on some systems (#133997) due to minor variations in how `begin_panic` is printed in the backtrace.

The variation appears to occur on macOS when `rust.debuginfo-level = "line-tables-only"` is set, which is the default in `config.compiler.toml`. It does not occur when the debuginfo level is set to 1.

The variation doesn't seem relevant to these tests, so this PR simply adds another custom normalization rule to account for the variation.

---

Will conflict with #134759.
2024-12-26 19:30:29 +01:00
Guillaume Gomez
88687d4459
Rollup merge of #134664 - estebank:sugg-highlighting, r=jieyouxu
Account for removal of multiline span in suggestion

When highlighting the removed parts of a suggestion, properly account for spans that cover more than one line.

Fix #134485.

![Screenshot of the highlighted output](https://github.com/user-attachments/assets/18bcd9bc-3bec-4b79-a9d7-e4ea4e6289ad)
2024-12-26 19:30:28 +01:00
Guillaume Gomez
c016cd8670
Rollup merge of #134656 - jieyouxu:migrate-incr-add-rust-src-component, r=wesleywiser
Migrate `incr-add-rust-src-component` to rmake

This PR partially supersedes #128562, and ports the Makefile-based `tests/run-make/incr-add-rust-src-component` to use rmake.rs infra.

Part of #121876.

This run-make test is a regression test for https://github.com/rust-lang/rust/issues/70924. It (tries to) checks that if we add the `rust-src` component in between two incremental compiles, that the compiler doesn't ICE on the second invocation.

- Original issue:https://github.com/rust-lang/rust/issues/70924
- Fix PR: https://github.com/rust-lang/rust/pull/72767
- PR adding this regression test: https://github.com/rust-lang/rust/pull/72952

However, the Makefile version of this used `$SYSROOT/lib/rustlib/src/rust/src/libstd/lib.rs`, but that actually got moved around and reorganized over the years. As of Dec 2024, the `rust-src` component is more like (specific for our purposes):

```
$SYSROOT/lib/rustlib/src/rust/
    library/std/src/lib.rs
    src/
```

However, this run-make test is ancient and it exercises incr-comp system logic. I'm not sure if this test would actually catch the original regression.

This PR was co-authored with `@Oneirical.`

r? incremental

try-job: i686-msvc
try-job: x86_64-mingw-1
try-job: x86_64-msvc
try-job: aarch64-apple
2024-12-26 19:30:28 +01:00
Esteban Küber
12d66d9506 Account for removal of multiline span in suggestion
When highlighting the removed parts of a suggestion, properly account for spans that cover more than one line.

Fix #134485.
2024-12-26 17:41:43 +00:00
bors
4ed8cf4237 Auto merge of #134774 - jyn514:rustc-dev-short-backtraces, r=jieyouxu
fix default-backtrace-ice test

when running `tests/ui/panics/default-backtrace-ice.rs locally it gave this error:
```
failures:

---- [ui] tests/ui/panics/default-backtrace-ice.rs stdout ----
Saved the actual stderr to "/home/jyn/src/rust3/build/x86_64-unknown-linux-gnu/test/ui/panics/default-backtrace-ice/default-backtrace-ice.stderr"
diff of stderr:

7
8	aborting due to `-Z treat-err-as-bug=1`
9	stack backtrace:
-	(end_short_backtrace)
-	(begin_short_backtrace)
-	(end_short_backtrace)
-	(begin_short_backtrace)
+	      [... omitted 22 frames ...]
+
```
(note that you must *not* use --bless; we previously did not have an error annotation to verify it was a full backtrace instead of a short backtrace.)

this is a regression from setting RUST_BACKTRACE=1 by default in https://github.com/rust-lang/rust/pull/134743. we need to turn off the new behavior when running UI tests so that they reflect our dist compiler. normally that's done by checking `sess.unstable_opts.ui_testing`, but this happens extremely early in the compiler before we've expanded arg files. do an extremely simple hack that doesn't work in all cases - we don't need it to work in all cases, only when running UI tests.

cc https://github.com/rust-lang/rust/pull/129658#issuecomment-2561988081

r? `@jieyouxu`
2024-12-26 15:41:37 +00:00
Zalathar
1511de3c9e Add more begin_panic normalizations to panic backtrace tests 2024-12-26 18:15:30 +11:00
jyn
801c1d8b90 fix default-backtrace-ice test
when running `tests/ui/panics/default-backtrace-ice.rs locally it gave this error:
```
failures:

---- [ui] tests/ui/panics/default-backtrace-ice.rs stdout ----
Saved the actual stderr to "/home/jyn/src/rust3/build/x86_64-unknown-linux-gnu/test/ui/panics/default-backtrace-ice/default-backtrace-ice.stderr"
diff of stderr:

7
8	aborting due to `-Z treat-err-as-bug=1`
9	stack backtrace:
-	(end_short_backtrace)
-	(begin_short_backtrace)
-	(end_short_backtrace)
-	(begin_short_backtrace)
+	      [... omitted 22 frames ...]
+
```

this is a regression from setting RUST_BACKTRACE=1 by default. we need to turn off the new behavior when running UI tests so that they reflect our dist compiler. normally that's done by checking `sess.unstable_opts.ui_testing`, but this happens extremely early in the compiler before we've expanded arg files. do an extremely simple hack that doesn't work in all cases - we don't need it to work in all cases, only when running UI tests.
2024-12-25 19:47:28 -05:00
Esteban Küber
01307cf03f Implement default_overrides_default_fields lint
Detect when a manual `Default` implementation isn't using the existing default field values and suggest using `..` instead:

```
error: `Default` impl doesn't use the declared default field values
  --> $DIR/manual-default-impl-could-be-derived.rs:14:1
   |
LL | / impl Default for A {
LL | |     fn default() -> Self {
LL | |         A {
LL | |             y: 0,
   | |                - this field has a default value
...  |
LL | | }
   | |_^
   |
   = help: use the default values in the `impl` with `Struct { mandatory_field, .. }` to avoid them diverging over time
note: the lint level is defined here
  --> $DIR/manual-default-impl-could-be-derived.rs:5:9
   |
LL | #![deny(default_overrides_default_fields)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2024-12-25 23:25:45 +00:00
bors
97a56fb4a6 Auto merge of #134736 - jyn514:msvc-backtraces, r=jieyouxu
Run `tests/ui/backtrace/std-backtrace.rs` on MSVC.

The original PR which disabled these, https://github.com/rust-lang/rust/pull/62897, only mentions them being broken on i686. ~~let's still make sure the rest of windows is supported.~~ Let's see if we can enable this for msvc now (32-bit and 64-bit).

r? `@jieyouxu`

try-job: x86_64-msvc
try-job: i686-msvc
try-job: i686-mingw
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
try-job: dist-x86_64-msvc
try-job: dist-i686-msvc
2024-12-25 14:14:47 +00:00
jyn
c880e8bbcb Run tests/ui/backtrace/std-backtrace.rs on MSVC.
The original PR which disabled these only mentions them being broken on
i686 msvc. Let's try to see if we can reenable this test for msvc (both
32-bit and 64-bit).
2024-12-25 20:44:20 +08:00
Ralf Jung
7291b1eaf7 rename typed_swap → typed_swap_nonoverlapping 2024-12-25 10:53:03 +01:00
Ralf Jung
6de3a2e3a9 stabilize const_swap 2024-12-25 10:36:32 +01:00
许杰友 Jieyou Xu (Joe)
db3404a896
Rollup merge of #134750 - Zalathar:coverage-attr-errors, r=jieyouxu
Update `#[coverage(..)]` attribute error messages to match the current implementation

The allowed positions for `#[coverage(..)]` attributes were expanded by #126721, but the corresponding error messages were never updated to reflect the new behaviour.

Part of #134749.
2024-12-25 17:25:58 +08:00
Zalathar
e48fc62ce0 Un-redact one occurrence of "coverage attribute not allowed here" 2024-12-25 19:23:48 +11:00
Zalathar
3996209398 Overhaul error messages for disallowed coverage attributes 2024-12-25 16:17:09 +11:00
Zalathar
9124662da3 Expand the main test for where the coverage attribute is allowed
Some of these cases are also implicitly checked by other tests, but it's
helpful to also explicitly list them in the main test.
2024-12-25 16:01:26 +11:00
Zalathar
5e98118901 Fully redact the [E0788] error message in tests, to make changes easier 2024-12-25 16:00:47 +11:00
DianQK
1d10117445
Rollup merge of #134741 - compiler-errors:coroutine-verbose, r=lqd
Actually print all the relevant parts of a coroutine in verbose mode

I need to actually see these components, idk why we weren't printing them :)
2024-12-25 12:23:07 +08:00
DianQK
a247d7bd8d
Rollup merge of #134735 - compiler-errors:arm-diverges, r=WaffleLapkin
Consider arm to diverge if guard diverges

This is not a fix for #134734, but I discovered it when I was gauging how difficult it would be to fix that. It does fix a really old test though :>

r? `@WaffleLapkin` or reassign
2024-12-25 12:23:07 +08:00
Michael Goulet
9bcd1dee95 Actually print all the relevant parts of a coroutine in verbose mode 2024-12-25 01:08:59 +00:00
Zalathar
d4005b6811 Rename tests/ui/coverage-attr/no-coverage.rs to allowed-positions.rs 2024-12-25 11:40:39 +11:00
bors
e33c428c8c Auto merge of #134729 - oliveredget:typo, r=jieyouxu
chore: fix typos

Fix some typos, thank you very much.
2024-12-25 00:40:23 +00:00
bors
409998c4e8 Auto merge of #134333 - daxpedda:stdarch-bump, r=daxpedda
Bump `stdarch`

This bumps `stdarch` to 684de0d6fe to get in https://github.com/rust-lang/stdarch/pull/1677 (tracked in https://github.com/rust-lang/rust/issues/133908).

From the [commit history](e5e00aab0a...684de0d6fe) I deduced that there shouldn't be any changes to Rust necessary.

From past PRs I'm assuming that bumping `stdarch` like this is fine, but please let me know if this is somehow inappropriate or requires something more to be done!

try-job: arm-android
try-job: armhf-gnu
2024-12-24 19:19:48 +00:00
Michael Goulet
a6a707169d Consider arm to diverge if guard diverges 2024-12-24 19:12:13 +00:00
daxpedda
374800b88d
Bump stdarch 2024-12-24 19:00:57 +01:00
oliveredget
be1d5dd494
chore: fix typos 2024-12-24 23:37:30 +08:00
bors
32c8a9f49d Auto merge of #134513 - fudancoder:master, r=jieyouxu
Fix some typos
2024-12-24 06:12:04 +00:00
fudancoder
e97be25aa9 Fix some typos
Signed-off-by: fudancoder <fudancoder@icloud.com.>
2024-12-24 11:35:38 +08:00
bors
d3e71fd2d3 Auto merge of #134716 - Zalathar:rollup-1h4q8cc, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - #134638 (Fix effect predicates from item bounds in old solver)
 - #134662 (Fix safety docs for `dyn Any + Send {+ Sync}`)
 - #134689 (core: fix const ptr::swap_nonoverlapping when there are pointers at odd offsets)
 - #134699 (Belay new reviews for workingjubilee)
 - #134701 (Correctly note item kind in `NonConstFunctionCall` error message)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-24 03:33:09 +00:00
Stuart Cook
772b95e755
Rollup merge of #134701 - compiler-errors:non-const-def-descr, r=Urgau,fmease
Correctly note item kind in `NonConstFunctionCall` error message

Don't just call everything a "`fn`". This is more consistent with the error message we give for conditionally-const items, which do note the item's def kind.

r? fmease, this is a prerequisite for making those `~const PartialEq` error messages better. Re-roll if you're busy or don't want to review this.
2024-12-24 14:05:24 +11:00
Stuart Cook
bbd30b5476
Rollup merge of #134689 - RalfJung:ptr-swap-test, r=oli-obk
core: fix const ptr::swap_nonoverlapping when there are pointers at odd offsets

Ensure that the pointer gets swapped correctly even if it is not stored at an aligned offset. This rules out implementations that copy things in a `usize` loop -- so our implementation needs to be adjusted to avoid such a loop when running in const context.

Part of https://github.com/rust-lang/rust/issues/133668
2024-12-24 14:05:22 +11:00
Stuart Cook
c2f44cd32c
Rollup merge of #134638 - compiler-errors:fx-item-bounds, r=lcnr
Fix effect predicates from item bounds in old solver

r? lcnr
2024-12-24 14:05:21 +11:00
bors
f3343420c8 Auto merge of #134625 - compiler-errors:unsafe-binders-ty, r=oli-obk
Begin to implement type system layer of unsafe binders

Mostly TODOs, but there's a lot of match arms that are basically just noops so I wanted to split these out before I put up the MIR lowering/projection part of this logic.

r? oli-obk

Tracking:

- https://github.com/rust-lang/rust/issues/130516
2024-12-24 00:51:51 +00:00
Michael Goulet
92f93f6d11 Note def descr in NonConstFunctionCall 2024-12-23 22:15:32 +00:00
Michael Goulet
b893221517 Always run tail_expr_drop_order lint on promoted MIR 2024-12-23 20:25:41 +00:00
Ralf Jung
af1c8da172 core: fix const ptr::swap_nonoverlapping when there are pointers at odd offsets in the type 2024-12-23 16:24:45 +01:00
Matthias Krüger
a16fc10f23
Rollup merge of #134680 - lqd:run-make-cleanup, r=jieyouxu
Clean up a few rmake tests

Now I'm aware it's a bit late to start participating in the Advent of Tests, but here are a few cleanups in the rmake tests to put under the 🎄 anyways. A handful of unused imports, some warnings, and a couple typos.

r? `@jieyouxu` 🎅
2024-12-23 14:44:22 +01:00
Matthias Krüger
cfb7a56676
Rollup merge of #134528 - jieyouxu:fix-rustc-bootstrap-test, r=Kobzol
opt-dist: propagate channel info to bootstrap

Fixes #133503.

Previously, `tests/ui/bootstrap/rustc_bootstap.rs` [sic] failed during [beta bump](https://github.com/rust-lang/rust/pull/133447#issuecomment-2501298794) in opt-dist tests. This is because:

- `opt-dist` tried to run `./x test` against beta-channel dist `rustc` through `bootstrap`.
- The dist build produced during the beta bump produces a `rustc` which correctly thinks that it is a beta compiler based on `src/ci/channel` info.
- `opt-dist` tries to run `./x test` on the beta `rustc` from the dist build, but without specifying channel through a synthetic `config.toml`, so `bootstrap` tells `compiletest` that we're on the `nightly` channel (by default).
- Now there's a channel mismatch: `compiletest` believes the `rustc` under test is a *nightly* rustc, but the `rustc` under test actually considers itself a *beta* rustc. This means that `//@ only-nightly` will be satisfied yet the test will fail as the *beta* rustc is not a *nightly* rustc.

This PR:

- Fixes the test failure during beta bump (i.e. #133503) by having `opt-dist` faithfully report the channel of the dist `rustc` being tested (i.e. "beta" in a beta bump PR). This will properly make the test be ignored during beta bump as the `rustc` under test is not a *nightly* rustc.
- Fixes the test name `rustc_bootstap.rs` -> `rustc_bootstrap.rs`. No more stapping.
- Slightly adjusts the doc comment in the test to make it more clear.

I ran a try-job against the beta branch (explicitly running the opt-dist tests by modifying the job definition) with these changes in #134131, and it appears that the try-job was [successful](https://github.com/rust-lang/rust/pull/134131#issuecomment-2555492215). The two commits in this PR are cherry-picked from #134131, with the test commit slightly modified (to also adjust the test comments).

r? `@Kobzol` (or compiler or bootstrap or infra I guess?)
2024-12-23 14:44:21 +01:00
Eric Huss
5d9f17f58c Add test for coverage on a body-less trait function 2024-12-24 00:09:39 +11:00
Eric Huss
0efa90f246 Add a test for coverage attr on trait function 2024-12-24 00:09:38 +11:00
许杰友 Jieyou Xu (Joe)
7ee520491e tests: migrate incr-add-rust-src-component to rmake.rs
The Makefile version seems to contain a bug. Over the years, the
directory structure of the `rust-src` component changed as the source
tree directory structure changed. `libstd` is no longer a thing directly
under `root/lib/rustlib/src/rust/src/`, it is moved to
`root/lib/rustlib/src/rust/library/std`.

Co-authored-by: Oneirical <manchot@videotron.ca>
2024-12-23 20:23:57 +08:00
Rémy Rakic
6f19bd08b0 fix a few typos in rmake tests' comments 2024-12-23 09:40:38 +00:00
Rémy Rakic
9ca5df692b remove unnecessary mut from dump-ice-to-disk rmake test 2024-12-23 09:40:38 +00:00
Rémy Rakic
1d77a2c677 clean up remove-dir-all-race rmake test
- removes unused variables
- fixes a few typos
2024-12-23 09:40:38 +00:00
Rémy Rakic
d6a9ad6190 remove unused imports from rmake tests 2024-12-23 09:40:25 +00:00
bors
85c39893a7 Auto merge of #134677 - tgross35:rollup-ozoeyop, r=tgross35
Rollup of 4 pull requests

Successful merges:

 - #129220 (Add platform docs for FreeBSD.)
 - #134659 (test-infra: improve compiletest and run-make-support symlink handling)
 - #134668 (Make sure we don't lose default struct value when formatting struct)
 - #134672 (Revert stabilization of the `#[coverage(..)]` attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-23 09:36:29 +00:00
Trevor Gross
8fc4ba2ac1
Rollup merge of #134672 - Zalathar:revert-coverage-attr, r=wesleywiser
Revert stabilization of the `#[coverage(..)]` attribute

Due to a process mixup, the PR to stabilize the `#[coverage(..)]` attribute (#130766) was merged while there are still outstanding concerns. The default action in that situation is to revert, and the feature is not sufficiently urgent or uncontroversial to justify special treatment, so this PR reverts that stabilization.

---

- A key point that came up in offline discussions is that unlike most user-facing features, this one never had a proper RFC, so parts of the normal stabilization process that implicitly rely on an RFC break down in this case.
- As the implementor and de-facto owner of the feature in its current form, I would like to think that I made good choices in designing and implementing it, but I don't feel comfortable proceeding to stabilization without further scrutiny.
- There hasn't been a clear opportunity for T-compiler to weigh in or express concerns prior to stabilization.
- The stabilization PR cites a T-lang FCP that occurred in the tracking issue, but due to the messy design and implementation history (and lack of a clear RFC), it's unclear what that FCP approval actually represents in this case.
  - At the very least, we should not proceed without a clear statement from T-lang or the relevant members about the team's stance on this feature, especially in light of the other concerns listed here.
- The existing user-facing documentation doesn't clearly reflect which parts of the feature are stable commitments, and which parts are subject to change. And there doesn't appear to be a clear consensus anywhere about where that line is actually drawn, or whether the chosen boundary is acceptable to the relevant teams and individuals.
  - For example, the [stabilization report comment](https://github.com/rust-lang/rust/issues/84605#issuecomment-2166514660) mentions that some aspects are subject to change, but that text isn't consistent with my earlier comments, and there doesn't appear to have been any explicit discussion or approval process.
  - [The current reference text](https://github.com/rust-lang/reference/blob/4dfaa4f/src/attributes/coverage-instrumentation.md) doesn't mention this distinction at all, and instead simply describes the current implementation behaviour.
- When the implementation was changed to its current form, the associated user-facing error messages were not updated, so they still refer to the attribute only being allowed on functions and closures.
  - On its own, this might have been reasonable to fix-forward in the absence of other concerns, but the fact that it never came up earlier highlights the breakdown in process that has occurred here.

---

Apologies to everyone who was excited for this stabilization to land, but unfortunately it simply isn't ready yet.
2024-12-23 02:07:32 -05:00