Commit Graph

269475 Commits

Author SHA1 Message Date
Jubilee
259ddf9b50
Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errors
Add `LayoutS::is_uninhabited` and use it

Use accessors for the things that accessors are good at: reducing everyone's need to be nosy and peek at the internals of every data structure.
2024-10-28 10:18:50 -07:00
Jubilee
d6be363400
Rollup merge of #132249 - workingjubilee:add-rustc-abi, r=compiler-errors
compiler: Add rustc_abi dependence to the compiler

Depend on rustc_abi in compiler crates that use it indirectly but have not yet taken on that dependency, and are not *significantly* entangled in my other PRs. This leaves an "excise rustc_target" step after the dust settles.
2024-10-28 10:18:50 -07:00
Jubilee
e20026cac0
Rollup merge of #132247 - workingjubilee:add-rustc-abi-to-smir, r=celinval
stable_mir: Directly use types from rustc_abi

In most cases, rustc_target is not necessary, so use rustc_abi instead of its reexports.
2024-10-28 10:18:49 -07:00
Jubilee
c9347f1e27
Rollup merge of #131441 - SpriteOvO:proc-macro-to-tokens-trait, r=dtolnay
Add a new trait `proc_macro::ToTokens`

Tracking issue #130977

This PR adds a new trait `ToTokens`, implemented for types that can be interpolated inside a `quote!` invocation.

```rust
impl ToTokens for TokenTree
impl ToTokens for TokenStream
impl ToTokens for Literal
impl ToTokens for Ident
impl ToTokens for Punct
impl ToTokens for Group
impl<T: ToTokens + ?Sized> ToTokens for &T
impl<T: ToTokens + ?Sized> ToTokens for &mut T
impl<T: ToTokens + ?Sized> ToTokens for Box<T>
impl<T: ToTokens + ?Sized> ToTokens for Rc<T>
impl<T: ToTokens + ToOwned + ?Sized> ToTokens for Cow<'_, T>
impl<T: ToTokens> ToTokens for Option<T>
impl ToTokens for u{8,16,32,64,128}
impl ToTokens for i{8,16,32,64,128}
impl ToTokens for f{32,64}
impl ToTokens for {u,i}size
impl ToTokens for bool
impl ToTokens for char
impl ToTokens for str
impl ToTokens for String
impl ToTokens for CStr
impl ToTokens for CString
```

~This PR also implements the migration mentioned in the tracking issue, replacing `Extend<Token{Tree,Stream}>` with `Extend<T: ToTokens>`, and replacing `FromIterator<Token{Tree,Stream}>` with `FromIterator<T: ToTokens>`.~
**UPDATE**: Reverted.

```diff
-impl FromIterator<TokenTree> for TokenStream
-impl FromIterator<TokenStream> for TokenStream
+impl<T: ToTokens> FromIterator<T> for TokenStream

-impl Extend<TokenTree> for TokenStream
-impl Extend<TokenStream> for TokenStream
+impl<T: ToTokens> Extend<T> for TokenStream
```

I'm going to leave some comments in the review where I'm unsure and concerned.

r? ``@dtolnay``
CC ``@tgross35``
2024-10-28 10:18:49 -07:00
Jubilee
a24b3778d6
Rollup merge of #130259 - adwinwhite:lower-node-id-once, r=cjgillot
Lower AST node id only once

Fixes #96346.

I basically followed the given instructions except the inline part.

`lower_jump_destination` can't reuse local existing `HirId` due to unknown name resolution result so I created an additional mapping for labels.

r? ```@cjgillot```
2024-10-28 10:18:48 -07:00
Jubilee Young
5f91811c77 stable_mir: Directly use types from rustc_abi 2024-10-28 10:13:19 -07:00
Jubilee Young
641ce068ae rustdoc: Use accessors to interrogate type layouts 2024-10-28 09:58:30 -07:00
Jubilee Young
88a9edc091 compiler: Add is_uninhabited and use LayoutS accessors
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-28 09:58:30 -07:00
bors
9f57edf2e2 Auto merge of #132262 - matthiaskrgr:rollup-pcphi6l, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #131391 (Stabilize `isqrt` feature)
 - #132248 (rustc_transmute: Directly use types from rustc_abi)
 - #132252 (compiler: rename LayoutS to LayoutData)
 - #132253 (Known-bug test for `keyword_idents` lint not propagating to other files)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-28 13:32:57 +00:00
Matthias Krüger
2ca9b2cddd
Rollup merge of #132253 - Zalathar:keyword-idents-bug, r=jieyouxu
Known-bug test for `keyword_idents` lint not propagating to other files

Known-bug test for `keyword_idents` lint not propagating to other files when configured via attribute (#132218).
2024-10-28 12:14:59 +01:00
Matthias Krüger
a4acbd561b
Rollup merge of #132252 - workingjubilee:rename-layouts-to-layoutdata, r=jieyouxu
compiler: rename LayoutS to LayoutData

Bid `LayoutS` goodbye because it looks like a typo.

`LayoutS` is the last of the types that use the "`{TypeName}` is the interned type, `{TypeName}S` is the backing data that is interned" convention. This is pretty confusing to those not intimately familiar with the history of rustc's names for its types over time, and doubly so now that there are no other examples in the tree. Abolish this convention.
2024-10-28 12:14:59 +01:00
Matthias Krüger
f62ed5eb57
Rollup merge of #132248 - workingjubilee:add-rustc-abi-to-transmute, r=compiler-errors
rustc_transmute: Directly use types from rustc_abi

Using the reexport from rustc_target is not necessary here, so use rustc_abi directly.
2024-10-28 12:14:58 +01:00
Matthias Krüger
81d885b933
Rollup merge of #131391 - ChaiTRex:isqrt, r=scottmcm,tgross35
Stabilize `isqrt` feature

Stabilizes the `isqrt` feature. FCP is incomplete.

Closes #116226
2024-10-28 12:14:57 +01:00
bors
32b17d56eb Auto merge of #132244 - jyn514:linker-refactors, r=bjorn3
fix various linker warnings

separated out from https://github.com/rust-lang/rust/pull/119286; this doesn't have anything user-facing, i just want to land these changes so i can stop rebasing them.

r? `@bjorn3`
2024-10-28 10:44:24 +00:00
bors
66701c4226 Auto merge of #132251 - jieyouxu:rollup-mtv9mpd, r=jieyouxu
Rollup of 7 pull requests

Successful merges:

 - #131633 (error on alignments greater than `isize::MAX`)
 - #132086 (Tweak E0277 highlighting and "long type" path printing)
 - #132220 (Add GUI regression test for doc struct fields margins)
 - #132225 (Dynamically link run-make support)
 - #132227 (Pass constness with span into lower_poly_trait_ref)
 - #132242 (Support `char::is_digit` in const contexts.)
 - #132243 (Remove `ObligationCause::span()` method)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-28 07:14:11 +00:00
Jubilee Young
3f73fe7db4 compiler: Depend on rustc_abi in rustc_lint 2024-10-27 23:59:31 -07:00
Adwin White
e3bf50ede2 more consistent debug_assertions 2024-10-28 14:13:39 +08:00
Adwin White
1a39247d8d Add duplicate lowering check 2024-10-28 14:13:36 +08:00
Adwin White
cb08e08722 Lower AST node id only once 2024-10-28 14:12:17 +08:00
Zalathar
dfafbc41d8 Known-bug test for keyword_idents lint not propagating to other files 2024-10-28 16:57:08 +11:00
许杰友 Jieyou Xu (Joe)
3e3feac7c3
Rollup merge of #132243 - compiler-errors:no-span, r=jieyouxu
Remove `ObligationCause::span()` method

I think it's an incredibly confusing footgun to expose both `obligation_cause.span` and `obligation_cause.span()`. Especially because `ObligationCause::span()` (the method) seems to just be hacking around a single quirk in the way we set up obligation causes for match arms.

First commit removes the need for that hack, with only one diagnostic span changing (but IMO not really getting worse -- I'd argue that it was already confusing).
2024-10-28 13:36:21 +08:00
许杰友 Jieyou Xu (Joe)
f14637b025
Rollup merge of #132242 - ultrabear:const_is_digit, r=scottmcm
Support `char::is_digit` in const contexts.

This PR implements [`feature(const_char_is_digit)` #132241](https://github.com/rust-lang/rust/issues/132241)
2024-10-28 13:36:20 +08:00
许杰友 Jieyou Xu (Joe)
a9ee1d025b
Rollup merge of #132227 - compiler-errors:better-const-span, r=Nadrieril
Pass constness with span into lower_poly_trait_ref

Gives us a span to point at for ~const/const on non-const traits.

Split from #132209. r? Nadrieril
2024-10-28 13:36:20 +08:00
许杰友 Jieyou Xu (Joe)
afc93a9128
Rollup merge of #132225 - clubby789:run-make-dynamic, r=jieyouxu
Dynamically link run-make support

Fixes #131810

r? `@jieyouxu`
2024-10-28 13:36:19 +08:00
许杰友 Jieyou Xu (Joe)
5c14e3d54c
Rollup merge of #132220 - GuillaumeGomez:gui-test-struct-fields-margins, r=notriddle
Add GUI regression test for doc struct fields margins

Fixes #131402.

r? `@notriddle`
2024-10-28 13:36:19 +08:00
许杰友 Jieyou Xu (Joe)
20d2a546fa
Rollup merge of #132086 - estebank:long-types, r=jieyouxu
Tweak E0277 highlighting and "long type" path printing

Partially address #132013.

![Output from this PR for the repro case in #132013](https://github.com/user-attachments/assets/a073ba37-4adc-411e-81f7-6cb9a945ce3d)
2024-10-28 13:36:18 +08:00
许杰友 Jieyou Xu (Joe)
95a9d496f3
Rollup merge of #131633 - asquared31415:align_isize_max, r=jieyouxu
error on alignments greater than `isize::MAX`

Fixes #131122

On zulip someone had a concern that it was legal to create a type with alignment `isize::MAX + 1`, but I do not believe this should be allowed for `repr(align)`, as `repr(align)` also increases the *size* of the type, and that would be larger than the maximum allowed size of objects.

(cc `@workingjubilee` #131276)
2024-10-28 13:36:17 +08:00
Jubilee Young
2a9239a105 rust-analyzer: Rename LayoutS to LayoutData 2024-10-27 22:32:58 -07:00
Jubilee Young
9015c6deca cg_clif: Rename LayoutS to LayoutData 2024-10-27 22:32:40 -07:00
Jubilee Young
e1781297f3 compiler: Rename LayoutS to LayoutData
The last {UninternedType}S is in captivity. The galaxy is at peace.
2024-10-27 22:31:14 -07:00
asquared31415
6fc7ce43d2 Error on alignments greater than isize::MAX
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2024-10-28 13:17:37 +08:00
bors
6929a48275 Auto merge of #132200 - Mark-Simulacrum:strengthen-cross-lang, r=RalfJung
Make clearer that guarantees in ABI compatibility are for Rust only

cc https://github.com/rust-lang/rust/pull/132136#issuecomment-2439737631 -- it looks like we already had a note that I missed in my initial look here, but this goes further to emphasize the guarantees, including uplifting it to the top of the general documentation.

r? `@RalfJung`
2024-10-28 04:47:06 +00:00
Jubilee Young
4839d6e6e5 compiler: Add rustc_abi dependence to the compiler
Depend on rustc_abi in compiler crates that use it indirectly but have
not yet taken on that dependency, and are not entangled in my other PRs.
This leaves an "excise rustc_target" step after the dust settles.
2024-10-27 21:10:58 -07:00
Jubilee Young
27207069d8 rustc_transmute: Directly use types from rustc_abi 2024-10-27 20:29:27 -07:00
jyn
675f447d88 don't pass -L .../auxiliary unless it exists
this avoids warnings from macOS ld
2024-10-27 21:23:28 -04:00
jyn
f1e5b365f0 port tests/ui/linkage-attr/framework to run-make
this makes it much easier to understand test failures.

before:
```
diff of stderr:

1 error: linking with `LINKER` failed: exit status: 1
2    |
-            ld: Undefined symbols:
4              _CFRunLoopGetTypeID, referenced from:
5            clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

after:
```
=== HAYSTACK ===
error: linking with `cc` failed: exit status: 1
  |
  = note: use `--verbose` to show all linker arguments
  = note: Undefined symbols for architecture arm64:
            "_CFRunLoopGetTypeID", referenced from:
                main::main::hbb553f5dda62d3ea in main.main.d17f5fbe6225cf88-cgu.0.rcgu.o
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to 1 previous error

=== NEEDLE ===
_CFRunLoopGetTypeID\.?, referenced from:
thread 'main' panicked at /Users/jyn/git/rust-lang/rust/tests/run-make/linkage-attr-framework/rmake.rs:22:10:
needle was not found in haystack
```

this also fixes a failure related to missing whitespace; we don't actually care about whitespace in this test.
2024-10-27 21:23:28 -04:00
jyn
3141a65d25 give a better error for tuple structs in derive(Diagnostic) 2024-10-27 21:23:28 -04:00
jyn
d792e1f50a remove dead code in CGREP script 2024-10-27 21:23:28 -04:00
Michael Goulet
7f54b9ecef Remove ObligationCause::span() method 2024-10-27 23:54:06 +00:00
Michael Goulet
2507e83d7b Stop using the whole match expr span for an arm's obligation span 2024-10-27 22:48:03 +00:00
ultrabear
66209cd9b5
Support char::is_digit in const contexts 2024-10-27 14:31:58 -07:00
bors
df4ca44d3f Auto merge of #132237 - matthiaskrgr:rollup-ulogwtd, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #132043 (Simplify param handling in `resolve_bound_vars`)
 - #132214 (Cleanup: Move an impl-Trait check from AST validation to AST lowering)
 - #132221 (Clean up some comments on lint implementation)
 - #132228 (Revert "ci update freebsd version proposal, freebsd 12 being eol.")
 - #132234 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-27 20:00:19 +00:00
Matthias Krüger
0cace65e8f
Rollup merge of #132234 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-10-27 19:49:09 +01:00
Matthias Krüger
afd889732f
Rollup merge of #132228 - devnexen:ci_update_fbsd_revert, r=workingjubilee
Revert "ci update freebsd version proposal, freebsd 12 being eol."

This reverts commit 1239c81c14.

Fix GH-132185 revert for now until early next year/FreeBSD 13.3 becomes EOL.
2024-10-27 19:49:09 +01:00
Matthias Krüger
4649a1b141
Rollup merge of #132221 - ehuss:lint-docs, r=compiler-errors
Clean up some comments on lint implementation

This updates some doc comments that have gotten very out of date. Some of these macros were removed or renamed in #57726 and #104863 and others. Manual emitting of lints was significantly reworked when the `Diagnostic` infrastructure was added.

Rather than try to replicate the high-level documentation, I added pointers to the rustc-dev-guide.

I linkified some types so that if they are renamed/removed without updating the docs, it will break CI.
2024-10-27 19:49:08 +01:00
Matthias Krüger
574a8ba6af
Rollup merge of #132214 - fmease:mv-impl-trait-val-paths, r=compiler-errors
Cleanup: Move an impl-Trait check from AST validation to AST lowering

Namely the one that rejects `impl Trait` in qself types and non-final path segments.
There's no good reason to perform this during AST validation.
We have better infrastructure in place in the AST lowerer (`ImplTraitContext`).
This shaves off a lot of code.
We now lower `impl Trait` in bad positions to `{type error}` which allows us to
remove a special case from HIR ty lowering.

Coincidentally fixes #126725. Well, it only *masks* it by passing `{type error}` to HIR analysis instead of a "bad" opaque. I was able to find a new reproducer for it. See the issue.
2024-10-27 19:49:07 +01:00
Matthias Krüger
60beb5979b
Rollup merge of #132043 - compiler-errors:simplify-rbv, r=cjgillot
Simplify param handling in `resolve_bound_vars`

I always found the flow of the `ResolvedArg` constructors to be a bit confusing; turns out they're also kinda redundantly passing around their data, too.

Also, deduplicate some code handling early-bound var to late-bound var conversion between return type notation's two styles: `where <T as Trait>::method(..): Bound` and `where T: Trait<method(..): Bound>`.
2024-10-27 19:49:06 +01:00
bors
81d6652e74 Auto merge of #131284 - dingxiangfei2009:rename-smart-ptr-to-coerce-referent, r=compiler-errors
Rename macro `SmartPointer` to `CoercePointee`

As per resolution #129104 we will rename the macro to better reflect the technical specification of the feature and clarify the communication.

- `SmartPointer` is renamed to `CoerceReferent`
- `#[pointee]` attribute is renamed to `#[referent]`
- `#![feature(derive_smart_pointer)]` gate is renamed to `#![feature(derive_coerce_referent)]`.
- Any mention of `SmartPointer` in the file names are renamed accordingly.

r? `@compiler-errors`

cc `@nikomatsakis` `@Darksonn`
2024-10-27 17:04:12 +00:00
David Carlier
4ccaef12a6 Revert "ci update freebsd version proposal, freebsd 12 being eol."
This reverts commit 1239c81c14.

Fix GH-132185 revert for now until early next year/FreeBSD 13.3
becomes EOL.
2024-10-27 16:20:14 +00:00
clubby789
9bb6e0789c Dynamically link run-make support 2024-10-27 14:56:35 +00:00