Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change all compile_fail tests to use error number annotations #5752

Open
sffc opened this issue Oct 30, 2024 · 2 comments
Open

Change all compile_fail tests to use error number annotations #5752

sffc opened this issue Oct 30, 2024 · 2 comments
Labels
needs-approval One or more stakeholders need to approve proposal T-techdebt Type: ICU4X code health and tech debt

Comments

@sffc
Copy link
Member

sffc commented Oct 30, 2024

Apparently (#5747) we can use notation such as

```compile_fail,E0271
// test that fails with code E0271
```

This isn't documented anywhere, but it is a feature for Rust developers according to @Manishearth. We should use it everywhere to make sure our compile_fail tests continue failing for the same reason.

CC @robertbastian

@sffc sffc added T-techdebt Type: ICU4X code health and tech debt discuss Discuss at a future ICU4X-SC meeting labels Oct 30, 2024
@sffc
Copy link
Member Author

sffc commented Oct 30, 2024

@Manishearth found the documentation for it:

https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#error-numbers-for-compile-fail-doctests

It says:

As detailed in the chapter on documentation tests, you can add a compile_fail attribute to a doctest to state that the test should fail to compile. However, on nightly, you can optionally add an error number to state that a doctest should emit a specific error number:

```compile_fail,E0044
extern { fn some_func<T>(x: T); }
```

This is used by the error index to ensure that the samples that correspond to a given error number properly emit that error code. However, these error codes aren't guaranteed to be the only thing that a piece of code emits from version to version, so this is unlikely to be stabilized in the future.

Attempting to use these error numbers on stable will result in the code sample being interpreted as plain text.

We do run tests on nightly each night.

However, I'm a bit concerned by the last line. I think it would be nice if on stable we would still enforce the compile_fail. But maybe that's not necessary.

I wonder if it still produces the "this code does not compile" CSS styles in the rustdoc?

@sffc sffc added needs-approval One or more stakeholders need to approve proposal and removed discuss Discuss at a future ICU4X-SC meeting labels Oct 30, 2024
@robertbastian
Copy link
Member

Huh I thought this was already stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-approval One or more stakeholders need to approve proposal T-techdebt Type: ICU4X code health and tech debt
Projects
None yet
Development

No branches or pull requests

2 participants