Commit Graph

1369 Commits

Author SHA1 Message Date
Ralf Jung
ad3991d303 nightly feature tracking: get rid of the per-feature bool fields 2024-10-23 09:14:41 +01:00
Michael Goulet
febb3f7c88 Represent TraitBoundModifiers as distinct parts in HIR 2024-10-22 19:48:44 +00:00
Michael Goulet
70746d078e Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax 2024-10-19 18:02:26 +00:00
bors
f79fae3069 Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #122670 (Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode)
 - #131095 (Use environment variables instead of command line arguments for merged doctests)
 - #131339 (Expand set_ptr_value / with_metadata_of docs)
 - #131652 (Move polarity into `PolyTraitRef` rather than storing it on the side)
 - #131675 (Update lint message for ABI not supported)
 - #131681 (Fix up-to-date checking for run-make tests)
 - #131702 (Suppress import errors for traits that couldve applied for method lookup error)
 - #131703 (Resolved python deprecation warning in publish_toolstate.py)
 - #131710 (Remove `'apostrophes'` from `rustc_parse_format`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-15 11:50:31 +00:00
Matthias Krüger
fb691b470a
Rollup merge of #130635 - eholk:pin-reborrow-sugar, r=compiler-errors
Add `&pin (mut|const) T` type position sugar

This adds parser support for `&pin mut T` and `&pin const T` references. These are desugared to `Pin<&mut T>` and `Pin<&T>` in the AST lowering phases.

This PR currently includes #130526 since that one is in the commit queue. Only the most recent commits (bd450027eb4a94b814a7dd9c0fa29102e6361149 and following) are new.

Tracking:

- #130494

r? `@compiler-errors`
2024-10-15 05:12:34 +02:00
Michael Goulet
95dba280b9 Move trait bound modifiers into ast::PolyTraitRef 2024-10-14 09:20:38 -04:00
Michael Goulet
7500e09b8b Move trait bound modifiers into hir::PolyTraitRef 2024-10-14 09:20:38 -04:00
Michael Goulet
204e6af3ea Remove const trait bound modifier hack 2024-10-13 09:48:01 -04:00
bors
f4966590d8 Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiser
Retire the `unnamed_fields` feature for now

`#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature.

However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly.

Fixes #117942
Fixes #121161
Fixes #121263
Fixes #121299
Fixes #121722
Fixes #121799
Fixes #126969
Fixes #131041

Tracking:
* https://github.com/rust-lang/rust/issues/49804

[^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields
[^2]: https://github.com/rust-lang/rust/issues/49804#issuecomment-1972619108
2024-10-11 13:11:13 +00:00
Michael Goulet
b7297ac440 Add gate for precise capturing in traits 2024-10-10 11:44:11 -07:00
Eric Holk
ae698f8199
Add sugar for &pin (const|mut) types 2024-10-07 11:15:04 -07:00
Noah Lev
d6f247f3d5 rm ItemKind::OpaqueTy
This introduce an additional collection of opaques on HIR, as they can no
longer be listed using the free item list.
2024-10-04 23:28:22 +00:00
Michael Goulet
7cd466a036 Move in_trait into OpaqueTyOrigin 2024-10-02 22:48:26 -04:00
Michael Goulet
cb7e3695e8 Use named fields for OpaqueTyOrigin 2024-10-02 22:04:18 -04:00
Michael Goulet
f95bdf453e Remove redundant in_trait from hir::TyKind::OpaqueDef 2024-10-02 21:59:55 -04:00
Michael Goulet
40465d2449 Remove anon struct and union types 2024-10-01 13:55:46 -04:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
bors
55043f067d Auto merge of #130337 - BoxyUwU:anon_const_macro_call, r=camelid
Fix anon const def-creation when macros are involved take 2

Fixes #130321

There were two cases that #129137 did not handle correctly:

- Given a const argument `Foo<{ bar!() }>` in which `bar!()` expands to `N`, we would visit the anon const and then visit the `{ bar() }` expression instead of visiting the macro call. This meant that we would build a def for the anon const as `{ bar!() }` is not a trivial const argument as `bar!()` is not a path.
- Given a const argument `Foo<{ bar!() }>` is which `bar!()` expands to `{ qux!() }` in which `qux!()` expands to `N`, it should not be considered a trivial const argument as `{{ N }}` has two pairs of braces.  If we only looked at `qux`'s expansion it would *look* like a trivial const argument even though it is not. We have to track whether we have "unwrapped" a brace already when recursing into the expansions of `bar`/`qux`/any macro

r? `@camelid`
2024-09-22 00:31:03 +00:00
Boxy
781ec111b7 Handle macro calls in anon const def creation take 2 2024-09-21 22:17:18 +01:00
Michael Goulet
174c3f9519 Add missing diagnostics and flesh out tests 2024-09-20 22:18:57 -04:00
Michael Goulet
51b51bb570 Implement RTN in resolve_bound_vars and HIR ty lowering 2024-09-20 22:18:57 -04:00
Michael Goulet
19881b5a5a Conditionally allow lowering RTN (..) in paths 2024-09-20 22:18:57 -04:00
Noah Lev
e0bd01167e Re-enable ConstArgKind::Path lowering by default
...and remove the `const_arg_path` feature gate as a result. It was only
a stopgap measure to fix the regression that the new lowering introduced
(which should now be fixed by this PR).
2024-09-12 13:56:01 -04:00
Stuart Cook
3ba12756d3
Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoerister
Simplify some nested `if` statements

Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if`

Review with whitespace disabled please.
2024-09-12 20:37:16 +10:00
Michael Goulet
af8d911d63 Also fix if in else 2024-09-11 17:24:01 -04:00
Samuel Tardieu
6ee87ae594 Use the same span for attributes and Try expansion of ?
This is needed for Clippy to know that the `#[allow(unused)]` attributes
added by the expansion of `?` are part of the desugaring, and that they
do not come from the user code.

rust-lang/rust-clippy#13380 exhibits a manifestation of this problem.
2024-09-11 21:42:32 +02:00
Michael Goulet
954419aab0 Simplify some nested if statements 2024-09-11 13:45:23 -04:00
Folkert de Vries
6ca5ec7b4e disallow naked_asm! outside of #[naked] functions 2024-09-10 15:19:14 +02:00
Alexander Cyon
ac69544a17
chore: Fix typos in 'compiler' (batch 1) 2024-09-02 07:42:38 +02:00
Matthias Krüger
07d5c250be
Rollup merge of #129493 - cjgillot:early-opaque-def, r=petrochenkov
Create opaque definitions in resolver.

Implementing https://github.com/rust-lang/rust/issues/129023#issuecomment-2306079532

That was easier than I expected.

r? `@petrochenkov`
2024-09-01 03:58:04 +02:00
Camille GILLOT
f68f66538a Create opaque definitions in resolver. 2024-08-31 20:14:43 +00:00
Pavel Grigorenko
5d04472461 Implement elided_named_lifetimes lint 2024-08-31 15:35:41 +03:00
Kornel
88b9edc9db
fmt-debug option
Allows disabling `fmt::Debug` derive and debug formatting.
2024-08-28 23:32:40 +01:00
Matthias Krüger
b3b6baf833
Rollup merge of #129626 - compiler-errors:explicit-named, r=fmease
Remove `ParamMode::ExplicitNamed`

This was introduced as a hack to improve a diagnostics suggestion in #61679. It was subsequently broken, but also it was an incomplete hack that I don't believe we need to support, so let's just remove it.
2024-08-27 00:42:02 +02:00
Matthias Krüger
3d8d9da6a0
Rollup merge of #129625 - compiler-errors:generic-args-mode, r=fmease
Rename `ParenthesizedGenericArgs` to `GenericArgsMode`

A bit easier to digest name. Broken out of a PR implementing return type notation.
2024-08-27 00:42:02 +02:00
Matthias Krüger
110c3df7fd
Rollup merge of #126013 - nnethercote:unreachable_pub, r=Urgau
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates

By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal.

There are plenty more crates to do but this seems like enough for a first PR.

r? `@compiler-errors`
2024-08-27 00:41:57 +02:00
Michael Goulet
2db1d2e261 Rename ParenthesizedGenericArgs to GenericArgsMode 2024-08-26 16:48:13 -04:00
Michael Goulet
b4d3fa4829 Remove ParamMode::ExplicitNamed 2024-08-26 16:47:52 -04:00
Matthias Krüger
c0bedb9e5e
Rollup merge of #129246 - BoxyUwU:feature_gate_const_arg_path, r=cjgillot
Retroactively feature gate `ConstArgKind::Path`

This puts the lowering introduced by #125915 under a feature gate until we fix the regressions introduced by it. Alternative to whole sale reverting the PR since it didn't seem like a very clean revert and I think this is generally a step in the right direction and don't want to get stuck landing and reverting the PR over and over :)

cc #129137 ``@camelid,`` tests taken from there. beta is branching soon so I think it makes sense to not try and rush that fix through since it wont have much time to bake and if it has issues we can't simply revert it on beta.

Fixes #128016
2024-08-24 22:14:12 +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
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
Boxy
b8eedfa3d2 Retroactively feature gate ConstArgKind::Path 2024-08-19 01:14:22 +01:00
Michael Goulet
833af65f38 Use FnSig instead of raw FnDecl for ForeignItemKind::Fn 2024-08-16 14:10:06 -04:00
Nicholas Nethercote
ea014b4d75 Add warn(unreachable_pub) to rustc_ast_lowering. 2024-08-16 08:46:33 +10:00
Folkert
8419c0956e stabilize asm_const 2024-08-13 23:18:31 +02:00
Guillaume Gomez
ea74eff55c
Rollup merge of #128886 - GrigorenkoPV:untranslatable-diagnostic, r=nnethercote
Get rid of some `#[allow(rustc::untranslatable_diagnostic)]`

`@rustbot` label +A-translation
cc https://github.com/rust-lang/rust/issues/100717
2024-08-12 17:09:17 +02:00
Matthias Krüger
32e0fe129d
Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors
Use more slice patterns inside the compiler

Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'.

r? ghost
2024-08-11 07:51:51 +02:00
Pavel Grigorenko
67602980de rustc_ast_lowering: make asm-related unstability messages translatable 2024-08-10 14:32:55 +03:00
Pavel Grigorenko
290df4fa56 rustc_ast_lowering: make "yield syntax is experimental" translatable 2024-08-10 14:32:55 +03:00