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

explicit_outlives_requirements lint triggers in macro-generated code #96640

Closed
jplatte opened this issue May 2, 2022 · 1 comment · Fixed by #96812
Closed

explicit_outlives_requirements lint triggers in macro-generated code #96640

jplatte opened this issue May 2, 2022 · 1 comment · Fixed by #96812
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jplatte
Copy link
Contributor

jplatte commented May 2, 2022

This was originally a clippy issue until I noticed it's actually a builtin lint, so here's clippy's issue form filled out 😄

Summary

The explicit_outlives_requirements lint seems to fire in macro-generated code, where it would be extra work to elide these. Saw this happen in CI for Ruma: https://github.com/ruma/ruma/runs/6258852689?check_suite_focus=true

Lint Name

explicit_outlives_requirements

Reproducer

  • Clone Ruma
  • Run cargo clippy --features client in crates/ruma-client-api

Version

rustc 1.62.0-nightly (4dd8b420c 2022-05-01)
binary: rustc
commit-hash: 4dd8b420c027001e47b0d811a7e55e2fe1de1395
commit-date: 2022-05-01
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1
@jplatte jplatte added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 2, 2022
@djkoloski
Copy link
Contributor

djkoloski commented May 2, 2022

This doesn't trip on stable or beta, so it appears that this is a nightly regression. Here's a minimized repro (playground link):

Cargo.toml

[dependencies]
serde = { version = "1.0", features = ["derive"] }

lib.rs

#![warn(explicit_outlives_requirements)]

use serde::Serialize;

#[derive(Serialize)]
pub struct Foo<'a> {
    #[serde(with = "stringify")]
    bar: &'a String,
}

mod stringify {
    pub fn serialize<S>(s: &String, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(&s)
    }
}

This trips the lint on a generated bound in serde:

struct __SerializeWith<'__a, 'a: '__a> {
    values: (&'__a &'a String,),
    phantom: _serde::__private::PhantomData<Foo<'a>>,
}

Since the 'a: '__a bound is technically unnecessary due to &'__a &'a String.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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.

3 participants