Skip to content

explicit_outlives_requirements lint triggers in macro-generated code #96640

Closed
@jplatte

Description

@jplatte
Contributor

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

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on May 2, 2022
djkoloski

djkoloski commented on May 2, 2022

@djkoloski
Contributor

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.

self-assigned this
on May 6, 2022
added a commit that references this issue on May 10, 2022

Rollup merge of rust-lang#96812 - cjgillot:no-lint-outllives-macro, r…

7b32e93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @jplatte@cjgillot@djkoloski

    Issue actions

      explicit_outlives_requirements lint triggers in macro-generated code · Issue #96640 · rust-lang/rust