(&self, attr: &Attribute)
| 433 | } |
| 434 | |
| 435 | fn parse(&self, attr: &Attribute) -> Option<KlintAttribute> { |
| 436 | let Attribute::Unparsed(item) = attr else { |
| 437 | return None; |
| 438 | }; |
| 439 | if item.path.segments[0] != crate::symbol::klint { |
| 440 | return None; |
| 441 | }; |
| 442 | if item.path.segments.len() != 2 { |
| 443 | self.tcx |
| 444 | .dcx() |
| 445 | .emit_err(InvalidAttribute { span: item.span }); |
| 446 | return None; |
| 447 | } |
| 448 | match item.path.segments[1] { |
| 449 | // Shorthands |
| 450 | crate::symbol::any_context | crate::symbol::atomic_context => { |
| 451 | Some(KlintAttribute::PreemptionCount(PreemptionCount { |
| 452 | adjustment: None, |
| 453 | expectation: Some(ExpectationRange::top()), |
| 454 | unchecked: false, |
| 455 | })) |
| 456 | } |
| 457 | crate::symbol::atomic_context_only => { |
| 458 | Some(KlintAttribute::PreemptionCount(PreemptionCount { |
| 459 | adjustment: None, |
| 460 | expectation: Some(ExpectationRange { lo: 1, hi: None }), |
| 461 | unchecked: false, |
| 462 | })) |
| 463 | } |
| 464 | crate::symbol::process_context => { |
| 465 | Some(KlintAttribute::PreemptionCount(PreemptionCount { |
| 466 | adjustment: None, |
| 467 | expectation: Some(ExpectationRange::single_value(0)), |
| 468 | unchecked: false, |
| 469 | })) |
| 470 | } |
| 471 | |
| 472 | crate::symbol::preempt_count => Some(KlintAttribute::PreemptionCount( |
| 473 | self.parse_preempt_count(attr, item).ok()?, |
| 474 | )), |
| 475 | crate::symbol::drop_preempt_count => Some(KlintAttribute::DropPreemptionCount( |
| 476 | self.parse_preempt_count(attr, item).ok()?, |
| 477 | )), |
| 478 | crate::symbol::report_preempt_count => Some(KlintAttribute::ReportPreeptionCount), |
| 479 | crate::symbol::dump_mir => Some(KlintAttribute::DumpMir), |
| 480 | crate::symbol::diagnostic_item => { |
| 481 | let AttrArgs::Eq { |
| 482 | eq_span: _, |
| 483 | expr: |
| 484 | MetaItemLit { |
| 485 | kind: LitKind::Str(value, _), |
| 486 | .. |
| 487 | }, |
| 488 | } = item.args |
| 489 | else { |
| 490 | self.tcx |
| 491 | .dcx() |
| 492 | .emit_err(InvalidDiagnosticItem { span: attr.span() }); |
no test coverage detected