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

Missing link to cast_possible_wrap #11805

Closed
smoelius opened this issue Nov 14, 2023 · 4 comments · Fixed by #11810
Closed

Missing link to cast_possible_wrap #11805

smoelius opened this issue Nov 14, 2023 · 4 comments · Fixed by #11810
Assignees

Comments

@smoelius
Copy link
Contributor

smoelius commented Nov 14, 2023

Run Clippy over this code and you will see a link to cast_sign_loss but not to cast_possible_wrap:

#![warn(clippy::pedantic)]

fn main() {
    let x: i64 = 1;
    let _ = x as u64; // warning with link to `cast_sign_loss`

    let y: u64 = 1;
    let _: i64 = y as i64; // warning, but no link to `cast_possible_wrap`
}

(Playgound)

@y21
Copy link
Member

y21 commented Nov 14, 2023

cx.struct_span_lint(CAST_POSSIBLE_WRAP, expr.span, message, |diag| {

This should probably use span_lint_and_then. I think the span_lint* functions are responsible for adding the link

@Jacherr
Copy link
Contributor

Jacherr commented Nov 14, 2023

@rustbot claim

@y21
Copy link
Member

y21 commented Nov 14, 2023

This is also the case for self_named_module_files.

Maybe we should have an internal lint that stops people from using cx.struct_span_lint directly.

@smoelius
Copy link
Contributor Author

Maybe we should have an internal lint that stops people from using cx.struct_span_lint directly.

Maybe disallowed_methods is all that is needed?

@bors bors closed this as completed in abf01e4 Nov 15, 2023
bors added a commit that referenced this issue Nov 15, 2023
disallow calls to `LintContext::struct_span_lint` and `TyCtxt::struct_span_lint_hir`

`LintContext::struct_span_lint` and `TyCtxt::struct_span_lint_hir` don't show the link to the clippy documentation, see: #11805

In #11810, the last few calls to those methods were replaced with `span_lint_*`. It seems like we should just disallow them altogether so that no new code tries to use them.

The existing `disallowed_methods` lint makes this easy.

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

Successfully merging a pull request may close this issue.

3 participants