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

Broken unstable lint examples in rustc book #135298

Closed
pitaj opened this issue Jan 9, 2025 · 2 comments · Fixed by #135406
Closed

Broken unstable lint examples in rustc book #135298

pitaj opened this issue Jan 9, 2025 · 2 comments · Fixed by #135406
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pitaj
Copy link
Contributor

pitaj commented Jan 9, 2025

The examples for the following unstable lints are currently broken, leading to the auto-generated outputs only displaying an "unknown lint" warning:

The examples in the lint doc-comments need to be updated to include enabling the respective feature for each lint. See the must_not_suspend lint docs for a correct example.

@pitaj pitaj added A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Jan 9, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 9, 2025
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 9, 2025
@Aditya-PS-05
Copy link
Contributor

@jieyouxu , can you assign me this issue? I would love to work on this?

@ehuss
Copy link
Contributor

ehuss commented Jan 9, 2025

Hm, we have code to specifically prevent this from happening, but unfortunately it is too loose.

let matches: Vec<_> = msgs.iter().filter(|msg|
matches!(&msg["rendered"], serde_json::Value::String(s) if s.contains(name)))
.map(|msg| msg["rendered"].as_str().expect("rendered field should exist").to_string())
.collect();

Perhaps that could be tightened up somehow to prevent this?

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 12, 2025
…s, r=compiler-errors

Update unstable lint docs to include required feature attributes

closes rust-lang#135298

## Summary
This PR updates the documentation examples for the following unstable lints to ensure they include the necessary feature attributes for proper usage:

- fuzzy_provenance_casts
- lossy_provenance_casts
- unqualified_local_imports
- test_unstable_lint

## Changes Made:

- Added the appropriate #![feature(...)] attributes to the example code for each lint.
- Updated the examples to produce correct and meaningful warnings, ensuring they align with current lint behavior.

Reference:
- Used the `must_not_suspend` lint documentation as a template for these updates.
@bors bors closed this as completed in d8e88c9 Jan 13, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 13, 2025
Rollup merge of rust-lang#135406 - Aditya-PS-05:fix/unstable-lint-docs, r=compiler-errors

Update unstable lint docs to include required feature attributes

closes rust-lang#135298

## Summary
This PR updates the documentation examples for the following unstable lints to ensure they include the necessary feature attributes for proper usage:

- fuzzy_provenance_casts
- lossy_provenance_casts
- unqualified_local_imports
- test_unstable_lint

## Changes Made:

- Added the appropriate #![feature(...)] attributes to the example code for each lint.
- Updated the examples to produce correct and meaningful warnings, ensuring they align with current lint behavior.

Reference:
- Used the `must_not_suspend` lint documentation as a template for these updates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants