Commit Graph

6556 Commits

Author SHA1 Message Date
Michael Goulet
5daf58ffc1 Fix capturing duplicated lifetimes via parent 2024-04-19 14:12:21 -04:00
Jubilee
f36ca7a75f
Rollup merge of #124110 - beetrees:neg-f16-f128, r=compiler-errors
Fix negating `f16` and `f128` constants

Make `f16` and `f128` constants respect `neg` in `parse_float_into_scalar`.

Tracking issue: #116909

```@rustbot``` label +F-f16_and_f128
2024-04-18 21:38:57 -07:00
Jubilee
f174c310ae
Rollup merge of #123935 - tstsrt:fix-115423, r=oli-obk
Don't inline integer literals when they overflow - new attempt

Basically #116633 but I implemented the suggested changes.
Fixes #115423. Fixes #116631.

This is my first contribution to this repo so please let me know if I'm supposed to change something :)
2024-04-18 21:38:55 -07:00
Jubilee
0a0a5a956c
Rollup merge of #123752 - estebank:emoji-prefix, r=wesleywiser
Properly handle emojis as literal prefix in macros

Do not accept the following

```rust
macro_rules! lexes {($($_:tt)*) => {}}
lexes!(🐛"foo");
```

Before, invalid emoji identifiers were gated during parsing instead of lexing in all cases, but this didn't account for macro pre-expansion of literal prefixes.

Fix #123696.
2024-04-18 21:38:55 -07:00
bors
0e15f5ee8f Auto merge of #124072 - saethlin:less-sysroot-libc-misc, r=jieyouxu
Remove libc from more tests

The goal here is to trim down the number of tests that depend on libc from the sysroot to make https://github.com/rust-lang/rust/pull/123938 more plausible.

This PR is a few simple cases that I missed in https://github.com/rust-lang/rust/pull/123943.
2024-04-18 14:59:36 +00:00
Ben Kimock
8047fadbf3 Add an exception for windows-msvc 2024-04-18 09:52:00 -04:00
Matthias Krüger
90013ff5ad
Rollup merge of #124090 - durin42:llvm-19-riscv-feature, r=cuviper
llvm: update riscv target feature to match LLVM 19

In llvm/llvm-project@9067070d91 they ended up largely reverting
llvm/llvm-project@e817966718. This means the change we did in
rust-lang/rust@b378059e6b is now only corrct for LLVM 18...so we have to adjust again.

``@rustbot`` label: +llvm-main
2024-04-18 08:37:49 +02:00
Matthias Krüger
7add0bdf7e
Rollup merge of #124047 - Jules-Bertholet:match-ergonomics-cleanups, r=Nadrieril
Match ergonomics 2024: miscellaneous code cleanups

- Store `ByRef` instead of `BindingAnnotation` in `PatInfo`
- Rename `BindingAnnotation` to `BindingMode`

r? ``@Nadrieril``

cc #123076

``@rustbot`` label A-patterns
2024-04-18 08:37:48 +02:00
beetrees
cc12a1b511
Fix negating f16 and f128 constants 2024-04-18 06:43:44 +01:00
bors
5260893724 Auto merge of #122684 - oli-obk:delay_interning_errors_to_after_validaiton, r=RalfJung
Delay interning errors to after validation

fixes https://github.com/rust-lang/rust/issues/122398
fixes #122548

This improves diagnostics since validation errors are usually more helpful compared with interning errors that just make broad statements about the entire constant

r? `@RalfJung`
2024-04-18 02:34:04 +00:00
Augie Fackler
22b704bac4 llvm: update riscv target feature to match LLVM 19
In llvm/llvm-project@9067070d91 they ended
up largely reverting
llvm/llvm-project@e817966718. This means
the change we did in
rust-lang/rust@b378059e6b is now only
corrct for LLVM 18...so we have to adjust again.

@rustbot label: +llvm-main
2024-04-17 16:15:24 -04:00
bors
38104f3a88 Auto merge of #123936 - Mark-Simulacrum:zst-no-alloc, r=oli-obk
Codegen ZSTs without an allocation

This makes sure that &[] is equivalent to unsafe code (from_raw_parts(dangling, 0)). No new stable guarantee is intended about whether or not we do this, this is just an optimization.

This regressed in #67000 (no comments I can see about that regression in the PR, though it did change the test modified here). We had previously performed this optimization since #63635.
2024-04-17 18:31:10 +00:00
bors
c45dee5efd Auto merge of #124084 - matthiaskrgr:rollup-h42psbx, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #116957 (meta: notify #t-rustdoc Zulip stream on backport nominations)
 - #122201 (Document overrides of `clone_from()` in core/std)
 - #122723 (Use same file permissions for ar_archive_writer as the LLVM archive writer)
 - #124030 (interpret: pass MemoryKind to adjust_alloc_base_pointer)
 - #124037 (Don't ascend into parent bodies when collecting stmts for possible return suggestion)
 - #124049 (Stabilize `const_io_structs`)
 - #124062 (Add another expression to weird-exprs.rs)
 - #124066 (Don't error on subtyping of equal types)
 - #124073 (Remove libc from rust_get_test_int uses)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-17 16:27:58 +00:00
Matthias Krüger
abbe0d0e47
Rollup merge of #124073 - saethlin:rust-get-test-int, r=wesleywiser
Remove libc from rust_get_test_int uses

`rust_test_helpers.c` has a few unfortunate signatures which have made some of our UI tests _technically_ need the `libc` crate. This is my attempt to evict the need of `libc` for `rust_get_test_int`.

I've deleted `tests/ui/abi/foreign/foreign-no-abi.rs` because the test was originally written to check that `native mod` will compile without an ABI specifier. `native mod` was removed years before 1.0 and the test hasn't checked for anything for a long time.
2024-04-17 18:01:41 +02:00
Matthias Krüger
abac22f485
Rollup merge of #124062 - allgoewer:fish-fight, r=oli-obk
Add another expression to weird-exprs.rs

I'm almost feeling bad for this but I decided I don't.
Feel free to close if you don't approve.
2024-04-17 18:01:40 +02:00
Matthias Krüger
72ff1a3312
Rollup merge of #124037 - compiler-errors:dont-parent-body, r=michaelwoerister
Don't ascend into parent bodies when collecting stmts for possible return suggestion

Fixes #124022
2024-04-17 18:01:39 +02:00
bors
00ed4edb44 Auto merge of #123674 - oli-obk:bogus_note, r=estebank
Silence some follow-up errors on trait impls in case the trait has conflicting or otherwise incoherent impls

fixes #123292

Also removes a bunch of extra diagnostics that were introduced in https://github.com/rust-lang/rust/pull/121154 and https://github.com/rust-lang/rust/pull/120558
2024-04-17 14:25:10 +00:00
Jules Bertholet
2a4624ddd1
Rename BindingAnnotation to BindingMode 2024-04-17 09:34:39 -04:00
Ben Kimock
6298d8f8fa Remove libc from rust_get_test_int uses 2024-04-17 09:18:14 -04:00
Ben Kimock
1567d4d850 Remove libc from more tests 2024-04-17 08:36:49 -04:00
Oli Scherer
77fe9f0a72 Validate before reporting interning errors.
validation produces much higher quality errors and already handles most of the cases
2024-04-17 09:50:44 +00:00
Oli Scherer
8c9cba2be7 Validate nested static items 2024-04-17 09:50:15 +00:00
Matthias Krüger
90af17ddcb
Rollup merge of #123997 - compiler-errors:self-res, r=fmease
Delay span bug when `Self` kw resolves to `DefKind::{Mod,Trait}`

Catch the case where `kw::Self` is recovered in the parser and causes us to subsequently resolve `&self`'s implicit type to something that's not a type.

This check could be made more accurate, though I'm not sure how hard we have to try here.

Fixes #123988
2024-04-17 05:44:53 +02:00
Mark Rousskov
649e80184b Codegen ZSTs without an allocation
This makes sure that &[] is just as efficient as indirecting through
unsafe code (from_raw_parts). No new stable guarantee is intended about
whether or not we do this, this is just an optimization.

Co-authored-by: Ralf Jung <post@ralfj.de>
2024-04-16 21:13:21 -04:00
Guillaume Gomez
4764dceb0f
Rollup merge of #124000 - compiler-errors:sugg-tweaks, r=wesleywiser
Use `/* value */` as a placeholder

The expression `value` isn't a valid suggestion; let's use `/* value */` as a placeholder (which is also invalid) since it more clearly signals to the user that they need to fill it in with something meaningful. This parallels the suggestions we have in a couple other places, like arguments.

We could also print the type name instead of `/* value */`, especially if it's suggestable, but I don't care strongly about that.
2024-04-17 00:00:23 +02:00
Guillaume Gomez
4885ddfa92
Rollup merge of #123675 - oli-obk:static_wf_ice, r=compiler-errors
Taint const qualifs if a static is referenced that didn't pass wfcheck

It is correct to only check the signature here, as the ICE is caused by `USE_WITH_ERROR` trying to allocate memory to store the result of `WITH_ERROR` before evaluating it.

fixes #123153
2024-04-17 00:00:22 +02:00
Guillaume Gomez
4aaa8f964f
Rollup merge of #123673 - oli-obk:sig_wfcheck_ice, r=jieyouxu,estebank
Don't ICE for kind mismatches during error rendering

fixes #123457

also some test suite cleanups to make backtraces easier to read
2024-04-17 00:00:22 +02:00
Maik Allgöwer
20414b8e1f Add another expression to weird-exprs.rs 2024-04-16 23:30:05 +02:00
Michael Goulet
8bbaeee6f9 Don't proceed into parent bodies when collecting stmts for possible return suggestion 2024-04-16 15:56:48 -04:00
Guillaume Gomez
239b3728d5
Rollup merge of #123512 - Jules-Bertholet:ref-pat-eat-one-layer-2024, r=Nadrieril
Match ergonomics 2024: Implement eat-one-layer

r? `@Nadrieril`

cc #123076

`@rustbot` label A-edition-2024 A-patterns
2024-04-16 21:41:24 +02:00
Matthias Krüger
dc40da83e3
Rollup merge of #123535 - Jules-Bertholet:mut_dont_reset_binding_mode_2024, r=Nadrieril
Match ergonomics 2024: `mut` doesn't reset binding mode

r? ``@Nadrieril``

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

``@rustbot`` label A-edition-2024 A-patterns
2024-04-16 17:54:42 +02:00
Matthias Krüger
f54219c473
Rollup merge of #123501 - Urgau:stabilize-check-cfg, r=petrochenkov
Stabilize checking of cfgs at compile-time: `--check-cfg` option

This PR stabilize the `--check-cfg` CLI option of `rustc` (and `rustdoc`) 🎉.

In particular this PR does two things:
  1. it makes the `--check-cfg` option stable
  2. and it moves the documentation to the stable books

FCP: https://github.com/rust-lang/rust/issues/82450#issuecomment-1965328542

Resolves #82450

``@rustbot`` labels +S-blocked +F-check-cfg
r? ``@petrochenkov``
2024-04-16 17:54:41 +02:00
bors
1dea922ea6 Auto merge of #124015 - GuillaumeGomez:rollup-s46ksxa, r=GuillaumeGomez
Rollup of 14 pull requests

Successful merges:

 - #120781 (Correct usage note on OpenOptions::append())
 - #121694 (sess: stabilize `-Zrelro-level` as `-Crelro-level`)
 - #122521 (doc(bootstrap): add top-level doc-comment to utils/tarball.rs)
 - #123491 (Fix ICE in `eval_body_using_ecx`)
 - #123574 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6))
 - #123687 (Update ar_archive_writer to 0.2.0)
 - #123721 (Various visionOS fixes)
 - #123797 (Better graphviz output for SCCs and NLL constraints)
 - #123990 (Make `suggest_deref_closure_return` more idiomatic/easier to understand)
 - #123995 (Make `thir_tree` and `thir_flat` into hooks)
 - #123998 (Opaque types have no namespace)
 - #124001 (Fix docs for unstable_features lint.)
 - #124006 (Move size assertions for `mir::syntax` types into the same file)
 - #124011 (rustdoc: update the module-level docs of `rustdoc::clean`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-16 13:26:03 +00:00
Oli Scherer
0a88339a57 Don't ICE for kind mismatches during error rendering 2024-04-16 11:52:12 +00:00
bors
4e1f5d90bc Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obk
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`)

Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587.

We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list.

We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future.

We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future.

r? `@oli-obk`

Tracking issue:

- https://github.com/rust-lang/rust/issues/123432
2024-04-16 11:22:35 +00:00
Oli Scherer
801413ecd1 Taint const qualifs if a static is referenced that didn't pass wfcheck 2024-04-16 10:43:41 +00:00
Gurinder Singh
c30e15aded Fail candidate assembly for erroneous types
Trait predicates for types which have errors may still
evaluate to OK leading to downstream ICEs. Now we return
a selection error for such types in candidate assembly and
thereby prevent such issues
2024-04-16 12:42:48 +05:30
Jules Bertholet
e3945bd3a8
Ensure inherited reference is never set to &mut behind an & 2024-04-15 23:34:50 -04:00
Jules Bertholet
b6c409723b
Support let &mut x = &&mut 0; 2024-04-15 23:34:49 -04:00
Jules Bertholet
4cd87c463c
Properly downgrade inherited mutability 2024-04-15 23:34:47 -04:00
Jules Bertholet
93544d5db3
Match ergonomics 2024: Implement eat-one-layer 2024-04-15 23:34:44 -04:00
Jules Bertholet
7a3211726b
Fix tests 2024-04-15 23:27:22 -04:00
Jules Bertholet
e13911e6e8
Rename feature gate 2024-04-15 23:27:21 -04:00
Jules Bertholet
d5d700d5c6
Temporarily remove future compatibility label from migration lint
The lint is unstable, and the lint group `rust_2024_compatibility` must keep working on stable
2024-04-15 23:27:20 -04:00
Jules Bertholet
83f330fbd4
Migration lint
Rustfix remains TODO
2024-04-15 23:27:19 -04:00
Jules Bertholet
ef1d084c0b
Match ergonomics 2024: mut doesn't reset binding mode 2024-04-15 23:26:22 -04:00
Michael Goulet
c95761385e Make array suggestions slightly more accurate 2024-04-15 21:45:47 -04:00
Michael Goulet
8a981b6fee Use /* value */ as a placeholder 2024-04-15 21:36:52 -04:00
Michael Goulet
6288a721f5 Delay span bug when Self resolves to DefKind::{Mod,Trait} 2024-04-15 21:05:15 -04:00
León Orell Valerian Liehr
1069ad3982
Rollup merge of #123926 - compiler-errors:no-ann, r=estebank
Fix pretty HIR for anon consts in diagnostics

This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`.

There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh.

r? estebank
2024-04-16 01:12:38 +02:00