about summary refs log tree commit diff
path: root/compiler/rustc_ast_passes/src
AgeCommit message (Collapse)AuthorLines
2025-10-02Extract common logic for iterating over featuresDeadbeef-5/+1
Two places doing the same thing is enough to motivate me to extract this to a method :)
2025-09-27Improve code and better check `doc(cfg(...))` attributesGuillaume Gomez-0/+1
2025-09-27Put back the `doc_cfg` code behind a nightly featureGuillaume Gomez-0/+1
2025-09-27Implement RFC 3631Guillaume Gomez-2/+0
2025-09-18Rollup merge of #146434 - folkertdev:c-variadic-inherent-methods, ↵Matthias Krüger-13/+1
r=workingjubilee c-variadic: allow c-variadic inherent and trait methods tracking issue: https://github.com/rust-lang/rust/issues/44930 Continuing the work of https://github.com/rust-lang/rust/pull/146342, allow inherent and trait methods to be c-variadic. However, a trait that contains a c-variadic method is no longer dyn-compatible. There is, presumably, some way to make c-variadic methods dyn-compatible. However currently, we don't have confidence that it'll work reliably: when methods from a `dyn` object are cast to a function pointer, a `ReifyShim` is created. If that shim is c-variadic, it would need to forward the C variable argument list. That does appear to work, because the `va_list` is not represented in MIR at all in this case, so the registers from the call site are untouched by the shim and can be read by the actual implementation. That just does not seem like a solid implementation. Also, intuitively, why would c-variadic function, primarily needed for FFI, need to be used with `dyn` objects at all? We can revisit this limitation if a need arises. r? `@workingjubilee`
2025-09-14Move more early buffered lints to dyn lint diagnostics (2/N)León Orell Valerian Liehr-1/+8
2025-09-11c-variadic: allow trait methods to be c-variadicFolkert de Vries-40/+26
but a C-variadic method makes a trait dyn-incompatible. That is because methods from dyn traits, when cast to a function pointer, create a shim. That shim can't really forward the c-variadic arguments.
2025-09-11c-variadic: allow inherent methods to be c-variadicFolkert de Vries-26/+28
2025-09-09c-variadic: reject functions with unsupported extern ABIFolkert de Vries-4/+12
2025-09-09c-variadic: reject non-unsafe functionsFolkert de Vries-9/+29
2025-09-08Refactor how to get the span of a function headerFolkert de Vries-1/+1
2025-09-08c-variadic: reject non-extern functionsFolkert de Vries-1/+9
2025-09-08clarify control flow of `check_c_variadic_type`Folkert de Vries-7/+16
2025-09-08disallow c-variadic associated functions (for now)Folkert de Vries-5/+16
there is no reason this should not work, really, we're just cutting some scope for now
2025-09-08disallow c-variadic coroutinesFolkert de Vries-0/+21
2025-09-03simplify `check_c_variadic_type`Folkert de Vries-25/+21
2025-08-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-0/+1
2025-08-22Rollup merge of #145747 - joshtriplett:builtin-diag-dyn, r=jdonszelmannJacob Pratt-4/+12
Refactor lint buffering to avoid requiring a giant enum Lint buffering currently relies on a giant enum `BuiltinLintDiag` containing all the lints that might potentially get buffered. In addition to being an unwieldy enum in a central crate, this also makes `rustc_lint_defs` a build bottleneck: it depends on various types from various crates (with a steady pressure to add more), and many crates depend on it. Having all of these variants in a separate crate also prevents detecting when a variant becomes unused, which we can do with a dedicated type defined and used in the same crate. Refactor this to use a dyn trait, to allow using `LintDiagnostic` types directly. Because the existing `BuiltinLintDiag` requires some additional types in order to decorate some variants, which are only available later in `rustc_lint`, use an enum `DecorateDiagCompat` to handle both the `dyn LintDiagnostic` case and the `BuiltinLintDiag` case. --- With the infrastructure in place, use it to migrate three of the enum variants to use `LintDiagnostic` directly, as a proof of concept and to demonstrate that the net result is a reduction in code size and a removal of a boilerplate-heavy layer of indirection. Also remove an unused `BuiltinLintDiag` variant.
2025-08-22Migrate `BuiltinLintDiag::MissingAbi` to use `LintDiagnostic` directlyJosh Triplett-2/+10
2025-08-22Refactor lint buffering to avoid requiring a giant enumJosh Triplett-2/+2
Lint buffering currently relies on a giant enum `BuiltinLintDiag` containing all the lints that might potentially get buffered. In addition to being an unwieldy enum in a central crate, this also makes `rustc_lint_defs` a build bottleneck: it depends on various types from various crates (with a steady pressure to add more), and many crates depend on it. Having all of these variants in a separate crate also prevents detecting when a variant becomes unused, which we can do with a dedicated type defined and used in the same crate. Refactor this to use a dyn trait, to allow using `LintDiagnostic` types directly. This requires boxing, but all of this is already on the slow path (emitting an error). Because the existing `BuiltinLintDiag` requires some additional types in order to decorate some variants, which are only available later in `rustc_lint`, use an enum `DecorateDiagCompat` to handle both the `dyn LintDiagnostic` case and the `BuiltinLintDiag` case.
2025-08-22Move validate_attr to `rustc_attr_parsing`Jonathan Brouwer-1/+1
2025-08-21Rollup merge of #145604 - compiler-errors:static-closure, r=fmeaseJacob Pratt-0/+1
Gate static closures behind a parser feature I'd like to gate `static ||` closures behind a feature gate, since we shouldn't allow people to take advantage of this syntax if it's currently unstable. Right now, since it's only rejected after ast lowering, it's accessible to macros. Let's crater this to see if we can claw it back without breaking anyone's code.
2025-08-21Rollup merge of #145662 - GrigorenkoPV:x86-interrupt, r=compiler-errorsJacob Pratt-0/+20
Enforce correct number of arguments for `"x86-interrupt"` functions Tracking issue: rust-lang/rust#40180 Partially fixes rust-lang/rust#132835 `````@rustbot````` label: +F-abi_x86_interrupt +A-LLVM +O-x86_64 +O-x86_32 +A-ABI
2025-08-20Enforce correct number of arguments for `"x86-interrupt"` functionsPavel Grigorenko-0/+20
2025-08-19Gate static coroutines behind a parser featureMichael Goulet-0/+1
2025-08-19Prevent impossible combinations in `ast::ModKind`.Nicholas Nethercote-1/+1
`ModKind::Loaded` has an `inline` field and a `had_parse_error` field. If the `inline` field is `Inline::Yes` then `had_parse_error` must be `Ok(())`. This commit moves the `had_parse_error` field into the `Inline::No` variant. This makes it impossible to create the nonsensical combination of `inline == Inline::Yes` and `had_parse_error = Err(_)`.
2025-08-15Rollup merge of #144907 - ShoyuVanilla:no-const-async, r=fmeaseJacob Pratt-0/+26
fix: Reject async assoc fns of const traits/impls in ast_passes Fixes rust-lang/rust#117629
2025-08-15fix: Reject async assoc fns of const traits/impls in ast_passesShoyu Vanilla-0/+26
2025-08-15Rollup merge of #143075 - workingjubilee:interrupts-may-return-nevermore, ↵Stuart Cook-2/+14
r=davidtwco compiler: Allow `extern "interrupt" fn() -> !` While reviewing rust-lang/rust#142633 I overlooked a few details because I was kind of excited. - Fixes rust-lang/rust#143072
2025-08-14cleanup: Remove useless `[T].iter().last()`Esteban Küber-1/+1
2025-08-11Extract ast TraitImplHeaderCameron Steffen-20/+14
2025-08-11Move trait impl modifier errors to parsingCameron Steffen-48/+5
This is a technically a breaking change for what can be parsed in `#[cfg(false)]`.
2025-08-11Factor out InherentImplCannotUnsafeCameron Steffen-19/+11
2025-08-09remove `P`Deadbeef-2/+1
2025-08-07Rollup merge of #137831 - estebank:auto-trait-err, r=compiler-errorsStuart Cook-10/+15
Tweak auto trait errors Make suggestions to remove params and super traits verbose and make spans more accurate. ``` error[E0567]: auto traits cannot have generic parameters --> $DIR/auto-trait-validation.rs:6:19 | LL | auto trait Generic<T> {} | -------^^^ | | | auto trait cannot have generic parameters error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/auto-trait-validation.rs:8:20 | LL | auto trait Bound : Copy {} | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds ``` ``` error[E0380]: auto traits cannot have associated items --> $DIR/issue-23080.rs:5:8 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | fn method(&self) { | ^^^^^^ ```
2025-08-04Tweak auto trait errorsEsteban Küber-10/+15
Make suggestions to remove params and super traits tool-only, and make the suggestion span more accurate. ``` error[E0567]: auto traits cannot have generic parameters --> $DIR/auto-trait-validation.rs:6:19 | LL | auto trait Generic<T> {} | -------^^^ | | | auto trait cannot have generic parameters error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/auto-trait-validation.rs:8:20 | LL | auto trait Bound : Copy {} | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds ``` ``` error[E0380]: auto traits cannot have associated items --> $DIR/issue-23080.rs:5:8 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | fn method(&self) { | ^^^^^^ ```
2025-08-04fix: Error on illegal `[const]`s inside blocks within legal positionsShoyu Vanilla-16/+51
2025-07-28use let chains in ast, borrowck, codegen, const_evalKivooeo-20/+15
2025-07-18AST lowering: More robustly deal with relaxed boundsLeón Orell Valerian Liehr-39/+0
2025-07-17parse `const trait Trait`Deadbeef-16/+24
2025-07-06compiler: rename {ast,hir}::BareFn* to FnPtr*Jubilee Young-8/+8
Fix some comments and related types and locals where it is obvious, e.g. - bare_fn -> fn_ptr - LifetimeBinderKind::BareFnType -> LifetimeBinderKind::FnPtrType Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-07-03Replace kw_span by full span.Camille GILLOT-2/+2
2025-07-02Auto merge of #143214 - camsteffen:remove-let-chains-feature, r=est31bors-1/+0
Remove let_chains unstable feature Per https://github.com/rust-lang/rust/issues/53667#issuecomment-3016742982 (but then I also noticed rust-lang/rust#140722) This replaces the feature gate with a parser error that says let chains require 2024. A lot of tests were using the unstable feature. I either added edition:2024 to the test or split out the parts that require 2024.
2025-07-01Remove support for dyn*Michael Goulet-1/+0
2025-06-30Remove let_chains featureCameron Steffen-1/+0
2025-06-27compiler: allow interrupts to return () or !Jubilee Young-2/+14
2025-06-24Error on invalid signatures for interrupt ABIsFolkert de Vries-21/+88
2025-06-16Fold unnecessary visit_struct_field_def in AstValidatorMichael Goulet-18/+2
2025-06-13Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgrbors-4/+149
Rollup of 9 pull requests Successful merges: - rust-lang/rust#128425 (Make `missing_fragment_specifier` an unconditional error) - rust-lang/rust#135927 (retpoline and retpoline-external-thunk flags (target modifiers) to enable retpoline-related target features) - rust-lang/rust#140770 (add `extern "custom"` functions) - rust-lang/rust#142176 (tests: Split dont-shuffle-bswaps along opt-levels and arches) - rust-lang/rust#142248 (Add supported asm types for LoongArch32) - rust-lang/rust#142267 (assert more in release in `rustc_ast_lowering`) - rust-lang/rust#142274 (Update the stdarch submodule) - rust-lang/rust#142276 (Update dependencies in `library/Cargo.lock`) - rust-lang/rust#142308 (Upgrade `object`, `addr2line`, and `unwinding` in the standard library) Failed merges: - rust-lang/rust#140920 (Extract some shared code from codegen backend target feature handling) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-apple try-job: x86_64-msvc-1 try-job: x86_64-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: test-various
2025-06-12add `extern "custom"` functionsFolkert de Vries-4/+149