• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vcfxb / wright-lang / 15061769677

16 May 2025 06:02AM UTC coverage: 75.523% (+0.7%) from 74.809%
15061769677

push

github

vcfxb
chore: cargo fmt

6 of 13 new or added lines in 4 files covered. (46.15%)

27 existing lines in 2 files now uncovered.

938 of 1242 relevant lines covered (75.52%)

29.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

53.33
/wright/src/parser/ty.rs
1
//! Parser implementation for parsing types.
2

3
use crate::ast::ty::{AtomicTy, ReferenceTy, Type};
4

5
use super::{
6
    Parser,
7
    error::{ParserError, ParserErrorKind},
8
};
9

10
mod primitive;
11
mod reference;
12

13
impl Type {
14
    /// Parse a type signature in source code.
15
    pub fn parse(parser: &mut Parser) -> Result<Self, ParserError> {
3✔
16
        // Atempt to parse atomic types first -- they're the simplest. If we fail to parse, the parser doesn't advance.
17
        // Since they're all keywords we don't have to worry at all about under-greedy parsing (yet).
18
        if let Ok(atomic) = AtomicTy::parse(parser) {
3✔
19
            return Ok(Type::Atomic(atomic));
2✔
20
        }
1✔
21

22
        let bytes_remaining = parser.bytes_remaining();
1✔
23

24
        match ReferenceTy::parse(parser) {
1✔
25
            Ok(reference_ty) => return Ok(Type::Reference(reference_ty)),
1✔
26

27
            Err(err) => {
×
28
                // If the parser was advanced in parsing the reference type, error out here.
29
                if bytes_remaining != parser.bytes_remaining() {
×
NEW
30
                    return Err(
×
NEW
31
                        err.with_help("encountered error while parsing reference type signature")
×
NEW
32
                    );
×
33
                }
×
34

35
                // If we didn't advance we can just ignore the error and try parsing other type signature
36
                // forms or fall through to the catch all "expected type signature" error (since it means
37
                // we would have not seen an `@` to start a reference type signature).
38
            }
39
        }
40

41
        Err(ParserErrorKind::ExpectedTypeSignature.at(parser.peek_fragment_or_rest_cloned()))
×
42
    }
3✔
43
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc