c: remove the config load string API

It was unused and doesn't match our diagnostic API.
This commit is contained in:
Mitchell Hashimoto
2024-10-17 08:02:28 -07:00
parent a12b33662c
commit 70c175e2a6
6 changed files with 31 additions and 50 deletions

View File

@@ -15,31 +15,6 @@ pub const Diagnostic = struct {
key: [:0]const u8 = "",
message: [:0]const u8,
/// The possible locations for a diagnostic message. This is used
/// to provide context for the message.
pub const Location = union(enum) {
none,
cli: usize,
file: struct {
path: []const u8,
line: usize,
},
pub fn fromIter(iter: anytype) Location {
const Iter = t: {
const T = @TypeOf(iter);
break :t switch (@typeInfo(T)) {
.Pointer => |v| v.child,
.Struct => T,
else => return .none,
};
};
if (!@hasDecl(Iter, "location")) return .none;
return iter.location() orelse .none;
}
};
/// Write the full user-friendly diagnostic message to the writer.
pub fn write(self: *const Diagnostic, writer: anytype) !void {
switch (self.location) {
@@ -61,6 +36,31 @@ pub const Diagnostic = struct {
}
};
/// The possible locations for a diagnostic message. This is used
/// to provide context for the message.
pub const Location = union(enum) {
none,
cli: usize,
file: struct {
path: []const u8,
line: usize,
},
pub fn fromIter(iter: anytype) Location {
const Iter = t: {
const T = @TypeOf(iter);
break :t switch (@typeInfo(T)) {
.Pointer => |v| v.child,
.Struct => T,
else => return .none,
};
};
if (!@hasDecl(Iter, "location")) return .none;
return iter.location() orelse .none;
}
};
/// A list of diagnostics. The "_diagnostics" field must be this type
/// for diagnostics to be supported. If this field is an incorrect type
/// a compile-time error will be raised.