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

Reword trivial_casts lint in rustc book to better explain what it does. #76555

Merged
merged 1 commit into from
Sep 10, 2020
Merged

Reword trivial_casts lint in rustc book to better explain what it does. #76555

merged 1 commit into from
Sep 10, 2020

Conversation

alilleybrinker
Copy link
Contributor

@alilleybrinker alilleybrinker commented Sep 10, 2020

The current description of the trivial casts lint under the "allowed
by default" listing in the rustc book indicates the lint is for casts
which may be removed, which is less clear than saying it's for casts
which may be replaced by coercion (which is the wording used by the
error message included in the doc).

This commit changes the wording slightly to better describe what the
lint does.

This issue bit me in some recent code where I was attempting to
convert a Vec<SomeType> to a Vec<SomeTraitObject>, and
hit my project-wide #![deny(trivial_casts)] with
map(|o| Box::new(o) as TraitObject). I'd read the book docs for
trivial_casts and was surprised by the error, as I took it to mean
the cast ought to be removed (rather than replaced by ascription
in this case). Removing the cast meant other code didn't compile,
and I then found issues like #23742 and realized my misunderstanding.

The current description of the trivial casts lint under the "allowed
by default" listing in the rustc book indicates the lint is for lints
which may be removed, which is less clear than saying it's for lints
which may be replaced by coercion (which is the wording used by the
error message included in the doc).

This commit changes the wording slightly to better describe what the
lint does.
@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 10, 2020
@alilleybrinker alilleybrinker changed the title Reword trivial_casts lint to better explain what it does. Reword trivial_casts lint in rustc book to better explain what it does. Sep 10, 2020
@steveklabnik
Copy link
Member

@bors: r+ rollup

thank you!

@bors
Copy link
Contributor

bors commented Sep 10, 2020

📌 Commit 01bf350 has been approved by steveklabnik

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 10, 2020
Rollup of 11 pull requests

Successful merges:

 - rust-lang#75857 (Syntactically permit unsafety on mods)
 - rust-lang#76289 (Add docs about crate level documentation support)
 - rust-lang#76514 (Add revisions to const generic issue UI tests.)
 - rust-lang#76524 (typeck: don't suggest inaccessible private fields)
 - rust-lang#76548 (Validate removal of AscribeUserType, FakeRead, and Shallow borrow)
 - rust-lang#76555 (Reword `trivial_casts` lint in rustc book to better explain what it does.)
 - rust-lang#76559 (add the `const_evaluatable_checked` feature)
 - rust-lang#76563 (small typo fix in rustc_parse docs)
 - rust-lang#76565 (take reference to Place directly instead of taking reference to Box<Place>)
 - rust-lang#76567 (use push(char) to add chars (single-char &strs) to strings instead of push_str(&str))
 - rust-lang#76568 (Add missing examples on core traits' method)

Failed merges:

r? `@ghost`
@bors bors merged commit f9df658 into rust-lang:master Sep 10, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 10, 2020
@alilleybrinker alilleybrinker deleted the reword_trivial_casts_lint_doc branch September 11, 2020 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants