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

Mark code that shouldn't compile or fails in runtime #343

Closed
adsick opened this issue Apr 16, 2022 · 5 comments
Closed

Mark code that shouldn't compile or fails in runtime #343

adsick opened this issue Apr 16, 2022 · 5 comments

Comments

@adsick
Copy link

adsick commented Apr 16, 2022

The official Rust book has fancy Ferris showing whether a given snippet compiles or not like so. Rust documentation system has it too (no Ferris tho)

So I suggest following that and explicitly show that a piece of code won't compile or will give a runtime error.
e.g. in recent 0.7 blog post we have this https://bevyengine.org/news/bevy-0-7/#world-system-param chapter and it would be a bit better if the code snippet after "... &World will conflict with any mutable Query:" was made into reddish borders or had a corresponding label.

bors bot pushed a commit that referenced this issue Apr 17, 2022
This should resolve #343 by adding a shortcode that goes around code blocks that should be marked incorrect (`incorrect_code_block()`), highlights them in a dark red, and makes the left border red. Looks like this:
<img width="1213" alt="Screen Shot 2022-04-16 at 4 50 25 PM" src="https://user-images.githubusercontent.com/1479994/163690976-77abfe98-fd71-4988-afcb-02e3be35491a.png">

from:

~~~markdown
Just keep in mind that `&World` will conflict with _any_ mutable Query:

{% incorrect_code_block() %}
```rust
fn invalid_system(world: &World, transforms: Query<&mut Transform>) {
}
```
{% end %}

In these cases, consider using our new [ParamSets](/news/bevy-0-7/#paramsets) to resolve the conflict:

```rust
fn valid_system(set: ParamSet<(&World, Query<&mut Transform>)>) {
}
```
~~~
@alice-i-cecile
Copy link
Member

Now that #348 is in, this should be a simple matter of adding this to the places where it should be :) I think we just have the news post for now.

Do you think we should add this to our "compiler error" output too?

@alice-i-cecile alice-i-cecile added the E-Good-First-Issue Good for newcomers label Apr 17, 2022
@adsick
Copy link
Author

adsick commented Apr 18, 2022

That was quick)

Do you think we should add this to our "compiler error" output too?

not sure what do you mean

@alice-i-cecile
Copy link
Member

I was definitely imprecise there. I meant general error messages like seen at https://bevyengine.org/learn/book/troubleshooting/

@adsick
Copy link
Author

adsick commented Apr 18, 2022

Yeah, that may be a nice addition.

@TimJentzsch
Copy link
Contributor

The given example is already marked in red, does this need to be added anywhere else or can this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants