Skip to content

Commit e80742b

Browse files
committed
UX Guidelines RFC
1 parent 04d8736 commit e80742b

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

text/0000-ux-guidelines.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
- Feature Name: ux-guidelines
2+
- Start Date: 2015-07-30
3+
- RFC PR: (leave this empty)
4+
- Rust Issue: (leave this empty)
5+
6+
# Summary
7+
8+
This is a conventions RFC to settle and document a number of UX guidelines.
9+
10+
* Error Messages
11+
* Explain Messages
12+
* Compiler flags
13+
14+
# Motivation
15+
16+
Good user experience is paramount for happy users. We already have informal
17+
guidelines, and having them documented makes it easier for new developers to
18+
start contributing without regressing on user experience.
19+
20+
# Detailed design
21+
22+
This RFC includes a number of unrelated UX guidelines broken down into
23+
arbitrary subsections. It starts with an overall summary of the goals of
24+
these guidelines. Ideally, everything after this paragraph should be
25+
copyable into a `ux-guidelines.md` file into the rustc repo. This RFC is
26+
specifically not trying to create *new* guidelines - just codify the ones that
27+
already exist informally.
28+
29+
### Summary
30+
31+
Don't forget the user. Whether human or another program, such as an IDE, a
32+
good user experience with the compiler goes a long way into making developer
33+
lives better. We don't want users to be baffled by compiler output or
34+
learn arcane patterns to compile their program.
35+
36+
### Error, Warning, Help, Note Messages
37+
38+
When the compiler detects a problem, it can emit either an error, warning,
39+
note, or help message.
40+
41+
An `error` is emitted when the compiler detects a problem that makes it unable
42+
to compile the program, either because the program is invalid or the
43+
programmer has decided to make a specific `warning` into an error.
44+
45+
A `warning` is emitted when the compiler detects something odd about a
46+
program. For instance, dead code and unused `Result` values.
47+
48+
A `help` is emitted following either an `error` or `warning` giving extra
49+
information to the user about how to solve their problem.
50+
51+
A `note` is for identifying additional circumstances and parts of the code
52+
that lead to a warning or error. For example, the borrow checker will note any
53+
previous conflicting borrows.
54+
55+
* Write in plain simple English. If your message, when shown on a – possibly
56+
small – screen (which hasn't been cleaned for a while), cannot be understood
57+
by a normal programmer, who just came out of bed after a night partying, it's
58+
too complex.
59+
* `Errors` and `Warnings` should not suggest how to fix the problem. A `Help`
60+
message should be emitted instead.
61+
* `Error`, `Warning`, `Note`, and `Help` messages start with a lowercase
62+
letter and do not end with punctuation.
63+
* Error messages should be succinct. Users will see these error messages many
64+
times, and more verbose descriptions can be viewed with the `--explain` flag.
65+
That said, don't make it so terse that it's hard to understand.
66+
* The word "illegal" is illegal. Prefer "invalid" or a more specific word
67+
instead.
68+
* Errors should document the span of code where they occur – the `span_..`
69+
methods allow to easily do this. Also `note` other spans that have contributed
70+
to the error if the span isn't too large.
71+
* When emitting a message with span, try to reduce the span to the smallest
72+
amount possible that still signifies the issue
73+
* Try not to emit multiple error messages for the same error. This may require
74+
detecting duplicates.
75+
* When the compiler has too little information for a specific error message,
76+
lobby for annotations for library code that allow adding more. For example see
77+
`#[on_unimplemented]`. Use these annotations when available!
78+
* Keep in mind that Rust's learning curve is rather steep, and that the
79+
compiler messages are an important learning tool.
80+
81+
### Error Explanations
82+
83+
Error explanations are long form descriptions of error messages provided with
84+
the compiler. They are accessible via the `--explain` flag. Each explanation
85+
comes with an example of how to trigger it and advice on how to fix it.
86+
87+
* All of them are accessible [online](https://github.com/rust-lang/rust/blob/master/src/librustc/diagnostics.rs).
88+
* Explanations have full markdown support. Use it, especially to highlight
89+
code with backticks.
90+
* When talking about the compiler, call it `the compiler`, not `Rust` or
91+
`rustc`.
92+
93+
### Compiler Flags
94+
95+
* Flags should be orthogonal to each other. For example, if we'd have a
96+
json-emitting variant of multiple actions `foo` and `bar, an additional
97+
--json flag is better than adding `--foo-json` and `--bar-json`.
98+
* Always give options a long descriptive name, if only for better
99+
understandable compiler scripts.
100+
* The `--verbose` flag is for adding verbose information to `rustc` output
101+
when not compiling a program. For example, using it with the `--version` flag
102+
gives information about the hashes of the code.
103+
* Experimental flags must be behind the `-Z` flag.
104+
105+
# Drawbacks
106+
107+
None.
108+
109+
# Alternatives
110+
111+
Have no UX guidelines.
112+
113+
# Unresolved questions
114+
115+
What other UX guidelines exist but aren't documented anywhere?
116+
117+
What happens when a warning or error subsumes another warning or error?
118+
119+
How should the UX guidelines be added to in the future? Not every addition
120+
will be forcing a new style, but rather, just documenting practice already
121+
done. Should they just be added via a Pull Request?

0 commit comments

Comments
 (0)