Commit Graph

264479 Commits

Author SHA1 Message Date
Matthias Krüger
a08a2ef1b7
Rollup merge of #129231 - onur-ozkan:improve-submodule-updates, r=Mark-Simulacrum
improve submodule updates

During config parsing, some bootstrap logic (e.g., `download-ci-llvm`) checks certain sources (for `download-ci-llvm`, it's `src/llvm-project`) and acts based on their state. This means that if path is a git submodule, bootstrap needs to update it before checking its state. Otherwise it may make incorrect assumptions by relying on outdated sources. To enable submodule updates during config parsing, we need to move the `update_submodule` function from the `Build` to `Config`, so we can access to it during the parsing process.

Closes #122787
2024-08-21 19:35:13 +02:00
Matthias Krüger
9fd8a2c3af
Rollup merge of #129187 - jieyouxu:squeaky-clean-windows-symlinks, r=Kobzol
bootstrap: fix clean's remove_dir_all implementation

It turns out bootstrap's `clean.rs`'s hand-rolled `rm_rf` (which probably comes before `std::fs::remove_dir_all` was stable) is very broken on native Windows around both read-only files/directories and especially symbolic links. So instead of rolling our own, just use `std::fs::remove_dir_all`.

This is a blocker for compiletest's own `rm_rf` implementation #129155 which happens to be also buggy, which in turn is a blocker for the rmake.rs test port #128562 that heavily exercises symlinks (I was reviewing #128562 and testing it on native Windows which is how I found out).

I also left a FIXME for `detect_src_and_out` due to a failing assertion on native Windows (opened #129188):

```
---- core::config::tests::detect_src_and_out stdout ----
thread 'core::config::tests::detect_src_and_out' panicked at src\core\config\tests.rs:72:13:
assertion `left == right` failed
  left: "E:\\tmp"
 right: "C:\\tmp"
```

Fixes #112544 (because now we handle Windows symlinks properly).

try-job: x86_64-msvc
try-job: i686-mingw
try-job: test-various
try-job: armhf-gnu
try-job: aarch64-apple
try-job: aarch64-gnu
2024-08-21 19:35:12 +02:00
Matthias Krüger
ffdbd9d6c8
Rollup merge of #129070 - estebank:static-trait, r=davidtwco
Point at explicit `'static` obligations on a trait

Given `trait Any: 'static` and a `struct` with a `Box<dyn Any + 'a>` field, point at the `'static` bound in `Any` to explain why `'a: 'static`.

```
error[E0478]: lifetime bound not satisfied
   --> f202.rs:2:12
    |
2   |     value: Box<dyn std::any::Any + 'a>,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: lifetime parameter instantiated with the lifetime `'a` as defined here
   --> f202.rs:1:14
    |
1   | struct Hello<'a> {
    |              ^^
note: but lifetime parameter must outlive the static lifetime
   --> /home/gh-estebank/rust/library/core/src/any.rs:113:16
    |
113 | pub trait Any: 'static {
    |                ^^^^^^^
```

Partially address #33652.
2024-08-21 19:35:12 +02:00
Matthias Krüger
47af700fe6
Rollup merge of #128941 - GrigorenkoPV:internal-diagnostic-lints, r=davidtwco
Improve diagnostic-related lints: `untranslatable_diagnostic` & `diagnostic_outside_of_impl`

Summary:
- Made `untranslatable_diagnostic` point to problematic arguments instead of the function call
  (I found this misleading while working on some `A-translation` PRs: my first impression was that
  the methods themselves were not translation-aware and needed to be changed,
  while in reality the problem was with the hardcoded strings passed as arguments).
- Made the shared pass of `untranslatable_diagnostic` & `diagnostic_outside_of_impl` more efficient.

`@rustbot` label D-imprecise-spans A-translation
2024-08-21 19:35:11 +02:00
Matthias Krüger
65386c045e
Rollup merge of #127945 - tgross35:debug-more-non-exhaustive, r=Noratrieb
Implement `debug_more_non_exhaustive`

This implements the ACP at https://github.com/rust-lang/libs-team/issues/248, adding `.finish_non_exhaustive()` for `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`.

Also used this as an opportunity to make some documentation and tests more readable by using raw strings instead of escaped quotes.

Tracking issue: https://github.com/rust-lang/rust/issues/127942
2024-08-21 19:35:10 +02:00
Matthias Krüger
221b53c9b0
Rollup merge of #127279 - bvanjoi:fix-112680, r=petrochenkov
use old ctx if has same expand environment during decode span

Fixes #112680

The root reason why #112680 failed with incremental compilation on the second attempt is the difference in `opaque` between the span of the field [`ident`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_typeck/src/expr.rs#L2348) and the span in the incremental cache at `tcx.def_ident_span(field.did)`.

-  Let's call the span of `ident` as `span_a`, which is generated by [`apply_mark_internal`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/hygiene.rs#L553-L554). Its content is similar to:

```rs
span_a_ctx -> SyntaxContextData {
      opaque: span_a_ctx,
      opaque_and_semitransparent: span_a_ctx,
      // ....
}
```

- And call the span of `tcx.def_ident_span` as `span_b`, which is generated by [`decode_syntax_context`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/hygiene.rs#L1390). Its content is:

```rs
span_b_ctx -> SyntaxContextData {
      opaque: span_b_ctx,
      // note `span_b_ctx` is not same as `span_a_ctx`
      opaque_and_semitransparent: span_b_ctx,
      // ....
}
```

Although they have the same `parent` (both refer to the root) and `outer_expn`, I cannot find the specific connection between them. Therefore, I chose a solution that may not be the best: give up the incremental compile cache to ensure we can use `span_a` in this case.

r?  `@petrochenkov` Do you have any advice on this? Or perhaps this solution is acceptable?
2024-08-21 19:35:10 +02:00
bors
6b678c57b6 Auto merge of #129359 - matthiaskrgr:rollup-nyre44t, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #128627 (Special case DUMMY_SP to emit line 0/column 0 locations on DWARF platforms.)
 - #128843 (Minor Refactor: Remove a Redundant Conditional Check)
 - #129179 (CFI: Erase regions when projecting ADT to its transparent non-1zst field)
 - #129281 (Tweak unreachable lint wording)
 - #129312 (Fix stability attribute of `impl !Error for &str`)
 - #129332 (Avoid extra `cast()`s after `CStr::as_ptr()`)
 - #129339 (Make `ArgAbi::make_indirect_force` more specific)
 - #129344 (Use `bool` in favor of `Option<()>` for diagnostics)
 - #129345 (Use shorthand field initialization syntax more aggressively in the compiler)
 - #129355 (fix comment on PlaceMention semantics)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-21 17:18:07 +00:00
Urgau
b6909ce61e Force LC_ALL=C for all run-make tests 2024-08-21 19:09:25 +02:00
bors
ecfc7d906f Auto merge of #13244 - Jarcho:get_src_display, r=Alexendoo
Start removing `snippet_opt` in favor of `get_source_text`

Continuing the job of removing unnecessary allocations.

changelog: none
2024-08-21 17:08:49 +00:00
Esteban Küber
f5bae722be Point at explicit 'static obligations on a trait
Given `trait Any: 'static` and a `struct` with a `Box<dyn Any + 'a>` field, point at the `'static` bound in `Any` to explain why `'a: 'static`.

```
error[E0478]: lifetime bound not satisfied
   --> f202.rs:2:12
    |
2   |     value: Box<dyn std::any::Any + 'a>,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: lifetime parameter instantiated with the lifetime `'a` as defined here
   --> f202.rs:1:14
    |
1   | struct Hello<'a> {
    |              ^^
note: but lifetime parameter must outlive the static lifetime
   --> /home/gh-estebank/rust/library/core/src/any.rs:113:16
    |
113 | pub trait Any: 'static {
    |                ^^^^^^^
```

Partially address #33652.
2024-08-21 16:40:15 +00:00
Krasimir Georgiev
b509b4226b llvm-wrapper: adapt for LLVM 20 API changes
No functional changes intended.

Adapts llvm-wrapper for the LLVM commits 0f22d47a7a and d6d8243dcd.
2024-08-21 16:27:31 +00:00
Jason Newcomb
8a4c34a5b7 Start removing snippet_opt 2024-08-21 12:25:10 -04:00
Matthias Krüger
9fd2832a7e
Rollup merge of #129355 - RalfJung:PlaceMention, r=compiler-errors
fix comment on PlaceMention semantics

It seems this was simply missed in https://github.com/rust-lang/rust/pull/114330.
2024-08-21 18:15:06 +02:00
Matthias Krüger
4137f3bc15
Rollup merge of #129345 - compiler-errors:scratch4, r=jieyouxu
Use shorthand field initialization syntax more aggressively in the compiler

Caught these when cleaning up #129344 and decided to run clippy to find the rest
2024-08-21 18:15:06 +02:00
Matthias Krüger
937a18daf9
Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostics, r=jieyouxu
Use `bool` in favor of `Option<()>` for diagnostics

We originally only supported `Option<()>` for optional notes/labels, but we now support `bool`. Let's use that, since it usually leads to more readable code.

I'm not removing the support from the derive macro, though I guess we could error on it... 🤔
2024-08-21 18:15:05 +02:00
Matthias Krüger
be80216d2c
Rollup merge of #129339 - beetrees:make-indirect-from-ignore, r=RalfJung
Make `ArgAbi::make_indirect_force` more specific

As the method is only needed for making ignored ZSTs indirect on some ABIs, rename and add a doc-comment and `self.mode` check to make it harder to accidentally misuse. Addresses review feedback from https://github.com/rust-lang/rust/pull/125854#discussion_r1721047899.

r? ``@RalfJung``
2024-08-21 18:15:04 +02:00
Matthias Krüger
e961d6b204
Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors
Avoid extra `cast()`s after `CStr::as_ptr()`

These used to be `&str` literals that did need a pointer cast, but that
became a no-op after switching to `c""` literals in #118566.
2024-08-21 18:15:04 +02:00
Matthias Krüger
349f29992b
Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=Noratrieb
Fix stability attribute of `impl !Error for &str`

It was introduced in bf7611d55e (#99917), which was included in Rust 1.65.0.
2024-08-21 18:15:03 +02:00
Matthias Krüger
9bb17d345a
Rollup merge of #129281 - Nadrieril:tweak-unreachable-lint-wording, r=estebank
Tweak unreachable lint wording

Some tweaks to the notes added in https://github.com/rust-lang/rust/pull/128034.

r? `@estebank`
2024-08-21 18:15:03 +02:00
Matthias Krüger
7da4b2d82a
Rollup merge of #129179 - compiler-errors:cfi-erase-transparent, r=davidtwco
CFI: Erase regions when projecting ADT to its transparent non-1zst field

The output from `FieldDef::ty` (or `TyCtxt::type_of`) may have free regions (well, `'static`) -- erase it.

Fixes #129169
Fixes #123685
2024-08-21 18:15:02 +02:00
Matthias Krüger
48c9864a05
Rollup merge of #128843 - veera-sivarajan:small-cleanup, r=davidtwco
Minor Refactor: Remove a Redundant Conditional Check

The existing code checks `where_bounds.is_empty()` twice when
it can be combined into one. Now, after combining, the refactored code reads
better and feels straightforward.

The diff doesn't make it clear. So, the current code looks like this:
``` rust
    if !where_bounds.is_empty() {
        err.help(format!(
            "consider introducing a new type parameter `T` and adding `where` constraints:\
             \n    where\n        T: {qself_str},\n{}",
            where_bounds.join(",\n"),
        ));
    }
    let reported = err.emit();
    if !where_bounds.is_empty() {
        return Err(reported);
    }
```
The proposed changes:
``` rust
    if !where_bounds.is_empty() {
        err.help(format!(
            "consider introducing a new type parameter `T` and adding `where` constraints:\
             \n    where\n        T: {qself_str},\n{}",
            where_bounds.join(",\n"),
        ));
        let reported = err.emit();
        return Err(reported);
    }
    err.emit();

```
2024-08-21 18:15:01 +02:00
Matthias Krüger
dea325e583
Rollup merge of #128627 - khuey:DUMMY_SP-line-no, r=nnethercote
Special case DUMMY_SP to emit line 0/column 0 locations on DWARF platforms.

Line 0 has a special meaning in DWARF. From the version 5 spec:

    The compiler may emit the value 0 in cases
    where an instruction cannot be attributed to any
    source line.

DUMMY_SP spans cannot be attributed to any line. However, because rustc internally stores line numbers starting at zero, lookup_debug_loc() adjusts every line number by one. Special casing DUMMY_SP to actually emit line 0 ensures rustc communicates to the debugger that there's no meaningful source code for this instruction, rather than telling the debugger to jump to line 1 randomly.
2024-08-21 18:15:01 +02:00
bors
a83146aea9 Auto merge of #13295 - waywardmonkeys:fix-2-typos, r=xFrednet
Fix a couple of typos.

changelog: none
2024-08-21 14:54:43 +00:00
Bruce Mitchener
3f97261fba Fix a couple of typos. 2024-08-21 21:42:57 +07:00
Tobias Bucher
123bb585f8 Fix stability attribute of impl !Error for &str
It was introduced in bf7611d55e (#99917),
which was included in Rust 1.65.0.
2024-08-21 16:21:40 +02:00
Ralf Jung
9010708d9f fix comment on PlaceMention semantics 2024-08-21 15:52:06 +02:00
bors
41c65e6350 Auto merge of #3831 - RalfJung:zero-sized-protector, r=RalfJung
borrow tracking: add a test for zero-sized protectors
2024-08-21 13:17:24 +00:00
Ralf Jung
13b02e3d86 add a test for zero-sized protectors 2024-08-21 15:15:18 +02:00
bors
982c6f8721 Auto merge of #126556 - saethlin:layout-precondition, r=joboet
Add a precondition check for Layout::from_size_align_unchecked

Ran into this while looking into https://github.com/rust-lang/miri/issues/3679. This is of course not the cause of the ICE, but the reproducer doesn't encounter a precondition check and it ought to.
2024-08-21 12:50:05 +00:00
bors
59a74db37d Auto merge of #128866 - scottmcm:update-stdarch, r=tgross35
Update stdarch submodule

To pick up https://github.com/rust-lang/stdarch/pull/1624 and unblock removing support for non-array-based-simd (https://github.com/rust-lang/compiler-team/issues/621).
2024-08-21 08:18:36 +00:00
Scott McMurray
210f603651 Update stdarch submodule 2024-08-21 00:20:27 -07:00
bors
4d7c095832 Auto merge of #129331 - matthiaskrgr:rollup-rxv463w, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #128662 (Lint on tail expr drop order change in Edition 2024)
 - #128932 (skip updating when external binding is existed)
 - #129270 (Don't consider locals to shadow inner items' generics)
 - #129277 (Update annotate-snippets to 0.11)
 - #129294 (Stabilize `iter::repeat_n`)
 - #129308 (fix: simple typo in compiler directory)
 - #129309 (ctfe: make CompileTimeInterpCx type alias public)
 - #129314 (fix a broken link in `mir/mod.rs`)
 - #129318 (Remove unneeded conversion to `DefId` for `ExtraInfo`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-21 05:40:46 +00:00
Michael Goulet
0b2525c787 Simplify some redundant field names 2024-08-21 01:31:42 -04:00
Michael Goulet
25ff9b6bcb Use bool in favor of Option<()> for diagnostics 2024-08-21 01:31:11 -04:00
beetrees
0f5c6eaccc
Make ArgAbi::make_indirect_force more specific 2024-08-21 02:43:12 +01:00
Ben Kimock
e6b0f27e00 Try to golf down the amount of code in Layout 2024-08-20 18:41:07 -04:00
Josh Stone
e424e7fcaa Avoid extra cast()s after CStr::as_ptr()
These used to be `&str` literals that did need a pointer cast, but that
became a no-op after switching to `c""` literals in #118566.
2024-08-20 14:04:48 -07:00
bors
5aea14073e Auto merge of #128252 - EtomicBomb:pre-rfc, r=notriddle
modularize rustdoc's write_shared

Refactor src/librustdoc/html/render/write_shared.rs to reduce code duplication, adding unit tests

* Extract + unit test code for sorting and rendering JSON, which is duplicated 9 times in the current impl
* Extract + unit test code for encoding JSON as single quoted strings, which is duplicated twice in the current impl
* Unit tests for cross-crate information file formats
* Generic interface to add new kinds of cross-crate information files in the future
* Intended to match current behavior exactly, except for a merge info comment it adds to the bottom of cci files
* This PR is intended to reduce the review burden from my [mergeable rustdoc rfc](https://github.com/rust-lang/rfcs/pull/3662) implementation PR, which is a [small commit based on this branch](https://github.com/EtomicBomb/rust/tree/rfc). This code is agnostic to the RFC and does not include any of the flags discussed there, but cleanly enables the addition of these flags in the future because it is more modular
2024-08-20 20:23:29 +00:00
Matthias Krüger
f6312870a5
Rollup merge of #129318 - GuillaumeGomez:rm-unneeded-defid-conversion, r=notriddle
Remove unneeded conversion to `DefId` for `ExtraInfo`

I'm working on adding support for "unit test doctests" and this first cleanup came up so just sending it ahead of the rest.

r? ``@notriddle``
2024-08-20 22:22:00 +02:00
Matthias Krüger
71df480bcb
Rollup merge of #129314 - kyoto7250:fix_link_in_mir_mod, r=compiler-errors
fix a broken link in `mir/mod.rs`

I discovered that the internal link in mir/mod.rs is broken, so I will fix it. The AddCallGuards is now located under rustc_mir_transform.

The PR at that time is as follows.
c5fc2609f0
2024-08-20 22:21:59 +02:00
Matthias Krüger
b1f19caa59
Rollup merge of #129309 - RalfJung:CompileTimeInterpCx, r=compiler-errors
ctfe: make CompileTimeInterpCx type alias public

`CompileTimeMachine` is already public so there is no good reason to not also make this public.

Also add comment explaining why `CompileTimeMachine` is public.
2024-08-20 22:21:59 +02:00
Matthias Krüger
ef9fba2232
Rollup merge of #129308 - c8ef:typo, r=jieyouxu
fix: simple typo in compiler directory
2024-08-20 22:21:58 +02:00
Matthias Krüger
aced570e53
Rollup merge of #129294 - scottmcm:stabilize-repeat-n, r=Noratrieb
Stabilize `iter::repeat_n`

ACP completed in https://github.com/rust-lang/rust/issues/104434#issuecomment-2296993685
2024-08-20 22:21:58 +02:00
Matthias Krüger
43a1ca5156
Rollup merge of #129277 - Xiretza:update-annotate-snippets, r=fee1-dead
Update annotate-snippets to 0.11
2024-08-20 22:21:57 +02:00
Matthias Krüger
d502b1c8e4
Rollup merge of #129270 - compiler-errors:inner-generics-shadowing, r=petrochenkov
Don't consider locals to shadow inner items' generics

We don't want to consider the bindings from a `RibKind::Module` itself, because for an inner item that module will contain the local bindings from the function body or wherever else the inner item is being defined.

Fixes #129265

r? petrochenkov
2024-08-20 22:21:57 +02:00
Matthias Krüger
2e58d62fec
Rollup merge of #128932 - bvanjoi:issue-128813, r=petrochenkov
skip updating when external binding is existed

Fixes #128813

For following code:

```rs
extern crate core;

fn f() {
    use ::core;
}

macro_rules! m {
    () => {
        extern crate std as core;
    };
}

m!();

fn main() {}
```

- In the first loop, we define `extern crate core` and `use ::core` will be referred to `core` (yes, it does not consider if there are some macros that are not expanded. Ideally, this should be delayed if there are some unexpanded macros in the root, but I didn't change it like that because it seems like a huge change).
- Then `m` is expanded, which makes `extern_prelude('core')` return `std` rather than `core`, causing the inconsistency.

r? `@petrochenkov`
2024-08-20 22:21:56 +02:00
Matthias Krüger
552b5c73fb
Rollup merge of #128662 - dingxiangfei2009:lint-tail-expr-drop-order, r=jieyouxu
Lint on tail expr drop order change in Edition 2024

This lint warns users to consider extra discretion on the effect of a transposed drop order arising from Edition 2024, which involves temporaries in tail expression location with significant drop implementation.

cc `@traviscross`

Tracking:

- https://github.com/rust-lang/rust/issues/123739
2024-08-20 22:21:56 +02:00
Nadrieril
f30392a985 Move the "matches no value" note to be a span label 2024-08-20 21:53:47 +02:00
bors
e5a1ef0795 Auto merge of #13290 - Jarcho:interior_mut_quick, r=Alexendoo
`declare_interior_mutable_const`: Ignore pointer types.

fixes #12951
fixes #13233

changelog: `declare_interior_mutable_const`: Ignore pointer types.
2024-08-20 18:04:47 +00:00
Urgau
4325ac9652 Implement ptr::fn_addr_eq 2024-08-20 19:27:29 +02:00