rust-lang / nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
https://doc.rust-lang.org/nomicon/
Apache License 2.0
1.79k stars 261 forks source link

Move the (duplicate) lists of rules to the reference #279

Open JohnTitor opened 3 years ago

JohnTitor commented 3 years ago

As noted in https://github.com/rust-lang/nomicon/issues/230#issuecomment-858248008, we have some duplicate lists of the rules between the nomicon and the reference, and Eric and I would like to defer them to the reference.

So, we should:

@ehuss is the above what you meant?

cc @rust-lang/lang-docs feel free to drop your thoughts, any suggestions are welcome!

ehuss commented 3 years ago

Yea, that's probably reasonable, though I'm uncertain. I don't think it's terribly bad if there is some duplication, the main concern is that we don't have the resources to keep things in sync, and in general that is a hassle for people contributing. Unfortunately, removing it from the nomicon can make reading it a little harder since you would need to head over to the reference to find the actual information.

I would suggest if removing stuff to do it carefully. Make sure the information is complete in the reference, and that it doesn't gut the nomicon too much. For example, the coercions page could remove the list of rules, but keep a high-level discussion and a good suite of examples. A rule of thumb is that the reference generally doesn't explain the "why" of anything in the language. It doesn't explain why you would want to coerce, or when it is useful or important or necessary. That seems like a better fit for the nomicon.

Some of the duplication I see is:

JohnTitor commented 3 years ago

Yeah, I agree with removing may overdo cleanup. So, adding a note saying "this list may be outdated, see the reference for a more accurate list" is enough here?

Gankra commented 3 years ago

Coercions and Casting were both originally written in the context of "the reference is dead, I need to be the reference", so they can be happily moved to the reference. The list of unsafe/UB things I think is definitely worth mirroring in the nomicon, since it's kind of a fundamental pretext for everything we're doing, although that page is getting a bit unwieldy as we more precisely define things.

JohnTitor commented 3 years ago

Another one about lifetime elision: https://github.com/rust-lang/nomicon/pull/306#issuecomment-908685816