Skip to content

Have error classes for simpler emission and more factoring #1420

@CohenArthur

Description

@CohenArthur

Something we might start to think about doing is for every error diagnostic have some kind of class for them all, so we can enforce good error messages so for example we might have:

class ErrorDiagnostics {
static void StaticMutableUnsafe(Location) { }
}

Originally posted by @philberty in #1417 (review)

I think a good interface would be the following:

class Emittable {
    Location locus;
    std::string msg;
    unsigned error_code;

    void emit() {
        rust_error_at(locus, msg); // or similar
    }
}

class ErrorStaticMutableUnsafe: public Emittable {
    /* ... */
}

I wonder if there is something we can do better with an enum class or similar

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions