Commit Graph

255434 Commits

Author SHA1 Message Date
许杰友 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
bors
c00957a3e2 Auto merge of #125254 - matthiaskrgr:rollup-ukvsxbc, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #125117 (Improve parser)
 - #125184 (Fix ICE in non-operand `aggregate_raw_ptr` intrinsic codegen)
 - #125240 (Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable)
 - #125248 (Migrate `run-make/rustdoc-scrape-examples-invalid-expr` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-18 17:20:48 +00:00
Jon Gjengset
0beba9699c Clarify how String::leak and into_boxed_str differ 2024-05-18 19:17:43 +02: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
fd90910f5f
Rollup merge of #125240 - lnicola:rustc-abi-nonzerousize, r=fee1-dead
Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable

rust-analyzer uses an auto-published version of `rustc-abi`, but `NonZero` isn't yet stable. This prevents us from updating the RA subtree, which is quite old already.

I can file a revert PR after the release.
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
beetrees
827711d087
Add #[inline] to float Debug fallback used by cfg(no_fp_fmt_parse) 2024-05-18 16:25:55 +01:00
bors
cf2baaa835 Auto merge of #125244 - RalfJung:android-alloc, r=workingjubilee
android: use posix_memalign for aligned allocations

Our target page says
> Rust will support the most recent Long Term Support (LTS) Android Native Development Kit (NDK). By default Rust will support all API levels supported by the NDK, but a higher minimum API level may be required if deemed necessary.

According to [this](https://github.com/android/ndk/wiki/Changelog-r26), the minimum API level of the current LTS NDK is 21. According to [this](https://stackoverflow.com/questions/44852378/android-ndk-r15b-posix-memalign-undeclared-identifier), posix_memalign exists since API level 16. So I think we should be able to use it here?
2024-05-18 15:13:33 +00: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
David Carlier
5ea21ca486
support aligned_alloc for unixes support. 2024-05-18 12:45:34 +01:00
onur-ozkan
f2b61d808a keep the STAGE0_MISSING_TARGETS list updated
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-05-18 14:02:34 +03: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
Ralf Jung
dde1134c6d android: use posix_memalign for aligned allocations 2024-05-18 12:49:01 +02: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
Laurențiu Nicola
8ec5a3d7b4 Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable 2024-05-18 11:27:29 +03: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
bors
143661a7f0 Auto merge of #17250 - adaszko:patch-1, r=lnicola
Correct Neovim 0.10 inlay hints config example

This change is what I had to do to make inlay hints work on Neovim 0.10.  The current example produces errors about wrong argument type to `.enable()`.
2024-05-18 05:37:17 +00:00
bors
7b06810691 Auto merge of #125237 - weihanglo:update-cargo, r=weihanglo
Update cargo

6 commits in 4de0094ac78743d2c8ff682489e35c8a7cafe8e4..0de7f2ec6c39d68022e6b97a39559d2f4dbf3930
2024-05-09 16:09:22 +0000 to 2024-05-17 16:54:54 +0000
- Add special `check-cfg` lint config for the `unexpected_cfgs` lint (rust-lang/cargo#13913)
- refactor: more comments and variable rename (rust-lang/cargo#13924)
- test: set safe.directory for git repo in apache container (rust-lang/cargo#13920)
- refactor: misc refactors for `ops::resolve` (rust-lang/cargo#13917)
- Preserve file permissions on unix during `write_atomic` (rust-lang/cargo#13898)
- Update benchmark formatting for new nightly (rust-lang/cargo#13901)

r? ghost
2024-05-18 04:25:19 +00:00
Weihang Lo
ad115a5397
Update cargo 2024-05-17 23:56:00 -04:00
Scott McMurray
d83c65e987 Fix clippy 2024-05-17 20:33:02 -07:00
Scott McMurray
95c0e5c6a8 Remove Rvalue::CheckedBinaryOp 2024-05-17 20:33:02 -07:00
bors
94be5ab448 Auto merge of #125232 - coolreader18:inline-duration-new, r=jhpratt
Inline Duration construction into `Duration::from_{secs,millis,micros,nanos}`

The millis/micros/nanos cases I don't feel as strongly about, but I see no reason why `Duration::from_secs` should call into `Duration::new` - that's just creating unnecessary work for the inlining and DCE passes.
2024-05-18 02:13:28 +00: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
Noa
53b317710d
Inline Duration construction into Duration::from_{millis,micros,nanos} 2024-05-17 18:37:59 -05:00
David Koloski
1e1143c491 Add source for mutually-exclusive list 2024-05-17 23:29:25 +00:00
Mads Marquart
74012d5200 Update libc to 0.2.155 2024-05-18 00:48:57 +02:00
bors
421538c9fa Auto merge of #3611 - marc0246:helix-ignore, r=saethlin
Ignore the Helix configuration directory

For us Helix users.
2024-05-17 22:12:45 +00:00
Waffle Lapkin
a02db8660c Make NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE into an FCW and report it ext macros 2024-05-18 00:08:52 +02:00
Waffle Lapkin
83acddc766 Remove fixme
(libs team decided not to add `absurd` to std)
2024-05-18 00:08:11 +02:00
Waffle Lapkin
956e5c18b9 Move lint_never_type_fallback_flowing_into_unsafe_code into a separate fn 2024-05-18 00:01:32 +02: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
marc0246
318a0fe586
Ignore the Helix configuration directory 2024-05-17 22:58:25 +02: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
Mads Marquart
8f18e4fe4b Use _NSGetArgc/_NSGetArgv on iOS/tvOS/watchOS/visionOS
If we're comfortable using `_NSGetEnviron` from `crt_externs.h`, there shouldn't be an issue with using these either, and then we can merge with the macOS implementation.

This also fixes two test cases on Mac Catalyst:
- `tests/ui/command/command-argv0.rs`, maybe because `[[NSProcessInfo processInfo] arguments]` somehow converts the name of the first argument?
- `tests/ui/env-funky-keys.rs` since we no longer link to Foundation.
2024-05-17 22:11:51 +02:00