diff options
| author | Manuel Drehwald <git@manuel.drehwald.info> | 2024-10-11 19:13:31 +0200 |
|---|---|---|
| committer | Manuel Drehwald <git@manuel.drehwald.info> | 2024-10-11 19:13:31 +0200 |
| commit | 624c071b997f3bab0ef086af24f59ebc95f37c59 (patch) | |
| tree | 44091cd44e62db9aa4d0f0b6053de7b84769a5cb /compiler/rustc_passes/src/check_attr.rs | |
| parent | 52fd9983996d9fcfb719749838336be66dee68f9 (diff) | |
| download | rust-624c071b997f3bab0ef086af24f59ebc95f37c59.tar.gz rust-624c071b997f3bab0ef086af24f59ebc95f37c59.zip | |
Single commit implementing the enzyme/autodiff frontend
Co-authored-by: Lorenz Schmidt <bytesnake@mailbox.org>
Diffstat (limited to 'compiler/rustc_passes/src/check_attr.rs')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 44a62383e6e..7ce29260e36 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -243,6 +243,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_generic_attr(hir_id, attr, target, Target::Fn); self.check_proc_macro(hir_id, target, ProcMacroKind::Derive) } + [sym::autodiff, ..] => { + self.check_autodiff(hir_id, attr, span, target) + } [sym::coroutine, ..] => { self.check_coroutine(attr, target); } @@ -2345,6 +2348,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.dcx().emit_err(errors::RustcPubTransparent { span, attr_span }); } } + + /// Checks if `#[autodiff]` is applied to an item other than a function item. + fn check_autodiff(&self, _hir_id: HirId, _attr: &Attribute, span: Span, target: Target) { + debug!("check_autodiff"); + match target { + Target::Fn => {} + _ => { + self.dcx().emit_err(errors::AutoDiffAttr { attr_span: span }); + self.abort.set(true); + } + } + } } impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> { |
