Commit Graph

263155 Commits

Author SHA1 Message Date
Matthias Krüger
3158a86b67
Rollup merge of #128718 - jieyouxu:check-cfg_attr, r=nnethercote
Consider `cfg_attr` checked by `CheckAttrVisitor`

I forgor about `cfg_attr` in #128581, it should be treated like `cfg`.

Fixes #128716.
2024-08-07 00:34:14 +02:00
Matthias Krüger
f9325b72d9
Rollup merge of #128710 - ChrisDenton:null, r=jieyouxu
Don't ICE when getting an input file name's stem fails

Fixes #128681

The file stem is only used as a user-friendly prefix on intermediary files. While nice to have, it's not the end of the world if it fails so there's no real reason to emit an error here. We can continue with a fixed name as we do when an anonymous string is used.
2024-08-07 00:34:14 +02:00
Matthias Krüger
03fabc033d
Rollup merge of #128692 - tgross35:update-triagebot, r=Mark-Simulacrum
Add a triagebot mention for `library/Cargo.lock`

Since [1], `Cargo.lock` was split into `Cargo.lock` and `library/Cargo.lock`. Update Triagebot to give the same warning for both.

[1]: https://github.com/rust-lang/rust/pull/128534
2024-08-07 00:34:14 +02:00
Matthias Krüger
52c365b731
Rollup merge of #128687 - RalfJung:interpret-call-refactor, r=WaffleLapkin
interpret: refactor function call handling to be better-abstracted

Add a new function `init_stack_frame` that pushes a stack frame and passes the arguments, and use that basically everywhere that the raw underlying `push_stack_frame` used to be called. This splits the previous monster function `eval_fn_call` into two parts: figuring out the MIR to call and the arguments to pass, and then actually setting up the stack frame.

Also re-organize the files a bit:
- The previous `terminator.rs` is split into a new `call.rs` with all the argument-passing logic, and the rest goes into `step.rs` where the other main dispatcher functions already live (in particular, `eval_statement`).
- All the stack frame handling from `eval_context.rs` is moved to a new `stack.rs`.
2024-08-07 00:34:13 +02:00
Matthias Krüger
f00a55188f
Rollup merge of #128539 - biabbas:deny_unsafe, r=workingjubilee
Forbid unused unsafe in vxworks-specific std modules

Tracking issue #127747
Adding deny(unsafe_op_in_unsafe_fn) in VxWorks specific files did not cause any error.
Most of VxWorks falls back on Unix libraries. So we'll have to wait for Unix changes.

r? ```@workingjubilee```
2024-08-07 00:34:12 +02:00
Matthias Krüger
7e1360b1e1
Rollup merge of #128406 - lolbinarycat:bufreader_peek, r=Mark-Simulacrum
implement BufReader::peek

Part of https://github.com/rust-lang/rust/issues/128405
2024-08-07 00:34:12 +02:00
Matthias Krüger
16b251be10
Rollup merge of #125048 - dingxiangfei2009:stable-deref, r=amanieu
PinCoerceUnsized trait into core

cc ``@Darksonn`` ``@wedsonaf`` ``@ojeda``

This is a PR to introduce a `PinCoerceUnsized` trait in order to make trait impls generated by the proc-macro `#[derive(SmartPointer)]`, proposed by [RFC](e17e19ac7a/text/3621-derive-smart-pointer.md (pincoerceunsized-1)), sound. There you may find explanation, justification and discussion about the alternatives.

Note that we do not seek stabilization of this `PinCoerceUnsized` trait in the near future. The stabilisation of this trait does not block the eventual stabilization process of the `#[derive(SmartPointer)]` macro. Ideally, use of `DerefPure` is more preferrable except this will actually constitute a breaking change. `PinCoerceUnsized` emerges as a solution to the said soundness hole while avoiding the breaking change. More details on the `DerefPure` option have been described in this [section](e17e19ac7a/text/3621-derive-smart-pointer.md (derefpure)) of the RFC linked above.

Earlier discussion can be found in this [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Pin.20and.20soundness.20of.20unsizing.20coercions) and [rust-for-linux thread](https://rust-lang.zulipchat.com/#narrow/stream/425075-rust-for-linux/topic/.23.5Bderive.28SmartPointer.29.5D.20and.20pin.20unsoundness.20rfc.233621).

try-job: dist-various-2
2024-08-07 00:34:11 +02:00
Matthias Krüger
38e631ee04
Rollup merge of #124944 - estebank:multiple-crate-versions, r=fee1-dead
On trait bound mismatch, detect multiple crate versions in dep tree

When encountering an E0277, if the type and the trait both come from a crate with the same name but different crate number, we explain that there are multiple crate versions in the dependency tree.

If there's a type that fulfills the bound, and it has the same name as the passed in type and has the same crate name, we explain that the same type in two different versions of the same crate *are different*.

```
error[E0277]: the trait bound `Type: dependency::Trait` is not satisfied
 --> src/main.rs:4:18
  |
4 |     do_something(Type);
  |     ------------ ^^^^ the trait `dependency::Trait` is not implemented for `Type`
  |     |
  |     required by a bound introduced by this call
  |
help: you have multiple different versions of crate `dependency` in your dependency graph
 --> src/main.rs:1:5
  |
1 | use bar::do_something;
  |     ^^^ one version of crate `dependency` is used here, as a dependency of crate `bar`
2 | use dependency::Type;
  |     ^^^^^^^^^^ one version of crate `dependency` is used here, as a direct dependency of the current crate
note: two types coming from two different versions of the same crate are different types even if they look the same
 --> /home/gh-estebank/crate_versions/baz-2/src/lib.rs:1:1
  |
1 | pub struct Type;
  | ^^^^^^^^^^^^^^^ this type doesn't implement the required trait
  |
 ::: /home/gh-estebank/crate_versions/baz/src/lib.rs:1:1
  |
1 | pub struct Type;
  | ^^^^^^^^^^^^^^^ this type implements the required trait
2 | pub trait Trait {}
  | --------------- this is the required trait
note: required by a bound in `bar::do_something`
 --> /home/gh-estebank/crate_versions/baz/src/lib.rs:4:24
  |
4 | pub fn do_something<X: Trait>(_: X) {}
  |                        ^^^^^ required by this bound in `do_something`
```

Address #22750.
2024-08-07 00:34:11 +02:00
bors
0ddead30f0 Auto merge of #128748 - matthiaskrgr:rollup-dzvi5f7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #128369 (rustc_lint: make `let-underscore-lock` translatable)
 - #128377 (Fix ICE Caused by Incorrectly Delaying E0107)
 - #128517 (Fallback to string formatting if source is not available for lint)
 - #128685 (Remove the root Cargo.lock from the rust-src component)
 - #128693 (rustdoc-search: account for numeric disambiguators on impls)
 - #128720 (Pass the right `ParamEnv` to `might_permit_raw_init_strict`)
 - #128736 (Fix rustdoc missing handling of remap-path-prefix option)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-06 22:12:39 +00:00
Oneirical
0149ba33bb rewrite pgo-gen-lto to rmake 2024-08-06 16:35:08 -04:00
Jane Losare-Lusby
b174cf827b Integrate crlf directly into related test file instead via of .gitattributes 2024-08-06 13:19:48 -07:00
David Carlier
b9e8e99198
std:🧵 set_name implementation proposal for vxWorks. 2024-08-06 21:10:12 +01:00
Folkert
201ca3f65c
changes after review 2024-08-06 22:08:28 +02:00
Michael Goulet
c656ce7aeb Don't arbitrarily choose one upper bound for hidden captured region 2024-08-06 15:43:41 -04:00
Esteban Küber
034b73ba54 fix test 2024-08-06 19:09:52 +00:00
bors
5ead90f13a Auto merge of #12150 - ithinuel:add_misleading_use_of_ok, r=y21
Add lint for `unused_result_ok`

This PR adds a lint to capture the use of `expr.ok();` when the result is not _really_ used.

This could be interpreted as the result being checked (like it is with `unwrap()` or `expect`) but
it actually only ignores the result.

`let _ = expr;` expresses that intent better.

This was also mentionned in #8994 (although not being the main topic of that issue).

changelog: [`misleading_use_of_ok`]: Add new lint to capture `.ok();` when the result is not _really_ used.
2024-08-06 19:01:41 +00:00
Matthias Krüger
47a2f14e49
Rollup merge of #128736 - GuillaumeGomez:fix-remap-path-prefix, r=notriddle
Fix rustdoc missing handling of remap-path-prefix option

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

cc `@weihanglo`
r? `@notriddle`
2024-08-06 20:23:42 +02:00
Matthias Krüger
8912318a4c
Rollup merge of #128720 - y21:issue119620, r=compiler-errors
Pass the right `ParamEnv` to `might_permit_raw_init_strict`

Fixes #119620

`might_permit_raw_init_strict` currently passes an empty `ParamEnv` to the `InterpCx`, instead of the actual `ParamEnv` that was passed in to `check_validity_requirement` at callsite.

This leads to ICEs such as the linked issue where for `UnsafeCell<*mut T>` we initially get the layout with the right `ParamEnv` (which suceeds because it can prove that `T: Sized` and therefore `UnsafeCell<*mut T>` has a known layout) but then do the rest with an empty `ParamEnv` where `T: Sized` is not known to hold so getting the layout for `*mut T` later fails.

This runs into an assertion in other layout code where it's making the (valid) assumption that, when we already have a layout for a struct (`UnsafeCell<*mut T>`), getting the layout of one of its fields (`*mut T`) should also succeed, which wasn't the case here due to using the wrong `ParamEnv`.

So, this PR changes it to just use the same `ParamEnv` all the way throughout.
2024-08-06 20:23:41 +02:00
Matthias Krüger
4b29f42ffc
Rollup merge of #128693 - notriddle:notriddle/impl-disambiguator-2024, r=GuillaumeGomez
rustdoc-search: account for numeric disambiguators on impls

Fixes #128676
2024-08-06 20:23:40 +02:00
Matthias Krüger
fb54b45c3f
Rollup merge of #128685 - bjorn3:rust_src_remove_leftover, r=onur-ozkan
Remove the root Cargo.lock from the rust-src component

The Cargo.lock in library/ should be used instead. Including the Cargo.lock for the root workspace is both unnecessary and confusing.

Missed in https://github.com/rust-lang/rust/pull/128534
2024-08-06 20:23:40 +02:00
Matthias Krüger
5f9ebb5d26
Rollup merge of #128517 - clubby789:overflowing-lit-span, r=petrochenkov
Fallback to string formatting if source is not available for lint

Fixes #128445
2024-08-06 20:23:39 +02:00
Matthias Krüger
333c63b9fc
Rollup merge of #128377 - veera-sivarajan:fix-128249, r=davidtwco
Fix ICE Caused by Incorrectly Delaying E0107

Fixes  #128249

For the following code:
```rust
trait Foo<T> {}
impl Foo<T: Default> for u8 {}
```
#126054 added some logic to delay emitting E0107 as the names of associated type `T` in the impl header and generic parameter `T` in `trait Foo` match.

But it failed to ensure whether such unexpected associated type bounds are coming from a impl block header. This caused an ICE as the compiler was delaying E0107 for code like:
```rust
trait Trait<Type> {
    type Type;

    fn method(&self) -> impl Trait<Type: '_>;
}
```
because it assumed the associated type bound `Type: '_` is for the generic parameter `Type` in `trait Trait` since the names are same.

This PR adds a check to ensure that E0107 is delayed only in the context of impl block header.
2024-08-06 20:23:39 +02:00
Matthias Krüger
d3d9aae960
Rollup merge of #128369 - GrigorenkoPV:let-underscore-translatable, r=davidtwco
rustc_lint: make `let-underscore-lock` translatable
2024-08-06 20:23:38 +02:00
Esteban Küber
5e26c8d3c9 Move test to be make instead of ui 2024-08-06 17:58:12 +00:00
Esteban Küber
f4bad4fa39 Change test to be only-linux and ignore-wasm32 2024-08-06 17:54:39 +00:00
Esteban Küber
edd4162393 fix rebase 2024-08-06 17:54:39 +00:00
Esteban Küber
d8b07718f4 Add help about using cargo tree 2024-08-06 17:54:39 +00:00
Esteban Küber
ba32673215 Add test for mixing types from two incompatible crate versions 2024-08-06 17:54:39 +00:00
Esteban Küber
4868680ee9 On trait bound mismatch, detect multiple crate versions in dep tree
When encountering an E0277, if the type and the trait both come from a crate with the same name but different crate number, we explain that there are multiple crate versions in the dependency tree.

If there's a type that fulfills the bound, and it has the same name as the passed in type and has the same crate name, we explain that the same type in two different versions of the same crate *are different*.

```
error[E0277]: the trait bound `Type: dependency::Trait` is not satisfied
 --> src/main.rs:4:18
  |
4 |     do_something(Type);
  |     ------------ ^^^^ the trait `dependency::Trait` is not implemented for `Type`
  |     |
  |     required by a bound introduced by this call
  |
help: you have multiple different versions of crate `dependency` in your dependency graph
 --> src/main.rs:1:5
  |
1 | use bar::do_something;
  |     ^^^ one version of crate `dependency` is used here, as a dependency of crate `bar`
2 | use dependency::Type;
  |     ^^^^^^^^^^ one version of crate `dependency` is used here, as a direct dependency of the current crate
note: two types coming from two different versions of the same crate are different types even if they look the same
 --> /home/gh-estebank/crate_versions/baz-2/src/lib.rs:1:1
  |
1 | pub struct Type;
  | ^^^^^^^^^^^^^^^ this type doesn't implement the required trait
  |
 ::: /home/gh-estebank/crate_versions/baz/src/lib.rs:1:1
  |
1 | pub struct Type;
  | ^^^^^^^^^^^^^^^ this type implements the required trait
2 | pub trait Trait {}
  | --------------- this is the required trait
note: required by a bound in `bar::do_something`
 --> /home/gh-estebank/crate_versions/baz/src/lib.rs:4:24
  |
4 | pub fn do_something<X: Trait>(_: X) {}
  |                        ^^^^^ required by this bound in `do_something`
```

Address #22750.
2024-08-06 17:54:39 +00:00
Esteban Küber
db6c05f9b9 Maintain highlighting in note and help even when they have a span 2024-08-06 17:54:37 +00:00
Oneirical
fe4cd9aa8d rewrite long-linker-command-lines-cmd-exe to rmake 2024-08-06 11:03:18 -04:00
Oneirical
fe6feb8c6e rewrite long-linker-command-lines to rmake 2024-08-06 11:03:17 -04:00
Oneirical
342b807e1a rewrite cross-lang-lto-upstream-rlibs to rmake 2024-08-06 11:03:17 -04:00
Oneirical
608b322f49 rewrite staticlib-dylib-linkage to rmake 2024-08-06 10:59:14 -04:00
bors
9d9a0dcb64 Auto merge of #13225 - Jarcho:warnings, r=flip1995
Use `-D warnings` instead of `deny-warnings` feature.

r? `@flip1995`
changelog: none
2024-08-06 14:58:50 +00:00
Guillaume Gomez
f43e92b4df Add regression test for #69264 2024-08-06 16:56:48 +02:00
Guillaume Gomez
fd89197d1b Fix rustdoc missing handling of remap-path-prefix option 2024-08-06 16:47:47 +02:00
Jason Newcomb
4e57b2c46f Use -D warnings instead of deny-warnings feature. 2024-08-06 10:46:39 -04:00
Michael Howell
3a183256ad rustdoc-search: account for numeric disambiguators on impls
Fixes #128676
2024-08-06 07:36:12 -07:00
Ralf Jung
1c2705c622 various cleanups based on review 2024-08-06 13:49:26 +02:00
bors
60d146580c Auto merge of #128245 - Oneirical:total-linkage-ownage, r=jieyouxu
Migrate `cdylib-dylib-linkage` `run-make` test 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).

~~Those sysroot tests are always fun. I'm getting local errors that don't make a lot of sense about my own sysroot not existing, so I am trying this in CI to see what happens.~~

~~EDIT: I am getting the same error here. The strange thing is, when I try to navigate to `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib` on my personal computer, the directory does exist, but the error message is that the directory does not.~~

EDIT 2: The sysroot path just needed to be trimmed!

Please try:

// try-job: x86_64-msvc // passed previously
try-job: x86_64-mingw
try-job: x86_64-gnu-llvm-18
try-job: i686-msvc
try-job: aarch64-apple
2024-08-06 11:15:31 +00:00
Jonathan Pallant
99579f3ec1
Apparently library/std is now part of a workspace at library/ 2024-08-06 12:12:57 +01:00
Jonathan Pallant
4e24e9b1ad
Update to rinja 0.3 2024-08-06 12:03:37 +01:00
Jonathan Pallant
5277b67b69
generate-copyright: gather files inside interesting folders 2024-08-06 11:11:09 +01:00
Jonathan Pallant
30ac7c9a81
generate-copyright: Render Node with rinja too. 2024-08-06 11:11:05 +01:00
Jonathan Pallant
37ab09010c
REUSE.toml: Copyright text isn't parsed as Markdown. 2024-08-06 11:04:55 +01:00
Jonathan Pallant
f7e6bf61a9
generate-copyright: use rinja to format the output
I can't find a way to derive rinja::Template for Node - I think because it is a recursive type. So I rendered it manually using html_escape.
2024-08-06 11:04:55 +01:00
Jonathan Pallant
dbab595d78
generate-copyright: use cargo-metadata 2024-08-06 11:04:55 +01:00
Jonathan Pallant
56f84796a4
generate-copyright: Fix typo 2024-08-06 11:04:55 +01:00
Jonathan Pallant
204e3eadf1
generate-copyright: Produce HTML, not Markdown
This format works better with large amounts of structured data.

We also mark which deps are in the stdlib
2024-08-06 11:04:55 +01:00