From b7b797a11288d3bc747bad9f00dd4ee475079a2b Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Tue, 21 Mar 2023 07:17:26 -0700 Subject: [PATCH 1/5] wip: lint for impls of 'static things --- plrust/src/lib.rs | 1 + plrustc/plrustc/src/lints.rs | 97 +++++++++++++++++++++ plrustc/plrustc/uitests/static_impls.rs | 27 ++++++ plrustc/plrustc/uitests/static_impls.stderr | 14 +++ 4 files changed, 139 insertions(+) create mode 100644 plrustc/plrustc/uitests/static_impls.rs create mode 100644 plrustc/plrustc/uitests/static_impls.stderr diff --git a/plrust/src/lib.rs b/plrust/src/lib.rs index 4380c153..88f46741 100644 --- a/plrust/src/lib.rs +++ b/plrust/src/lib.rs @@ -70,6 +70,7 @@ const DEFAULT_LINTS: &'static str = "\ plrust_lifetime_parameterized_traits, \ implied_bounds_entailment, \ plrust_autotrait_impls, \ + plrust_static_impls, \ plrust_fn_pointers, \ plrust_filesystem_macros, \ plrust_env_macros, \ diff --git a/plrustc/plrustc/src/lints.rs b/plrustc/plrustc/src/lints.rs index 43fa6794..102eb825 100644 --- a/plrustc/plrustc/src/lints.rs +++ b/plrustc/plrustc/src/lints.rs @@ -62,6 +62,101 @@ impl<'tcx> LateLintPass<'tcx> for NoExternBlockPass { } } +declare_plrust_lint!( + pub(crate) PLRUST_STATIC_IMPLS, + "Disallow impl blocks for types containing `'static` references" +); + +declare_lint_pass!(PlrustStaticImpls => [PLRUST_STATIC_IMPLS]); + +impl<'tcx> LateLintPass<'tcx> for PlrustStaticImpls { + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { + let hir::ItemKind::Impl(imp) = &item.kind else { + return; + }; + // The other stuff is all handled by `#![forbid(unsafe_code)]` or only + // occurs in the stdlib. + if ( + hir::Unsafety::Normal, + hir::Defaultness::Final, + hir::ImplPolarity::Positive, + hir::Constness::NotConst, + ) != (imp.unsafety, imp.defaultness, imp.polarity, imp.constness) + { + return; + }; + if self.has_static(imp.self_ty) { + cx.lint( + PLRUST_STATIC_IMPLS, + "`impl` blocks for types containing `'static` references are not allowed", + |b| b.set_span(item.span), + ) + } + } +} + +impl PlrustStaticImpls { + /// This is pretty naïve and designed to match the specific patterns that + /// trip up https://github.com/rust-lang/rust/issues/104005... + /// + /// Also, I feel like I should be able to use `hir::intravisit::walk_ty` + /// here instead, but it doesn't seem to let be know the lifetime of refs, + /// so... not sure... + /// + /// It's a method on `self` mostly to discourage use in other contexts, + /// since it's probably wrong for them. + fn has_static(&self, t: &hir::Ty) -> bool { + use hir::{Lifetime, LifetimeName::Static, MutTy, TyKind}; + match &t.kind { + TyKind::Infer + | TyKind::Err + // Doesn't exist + | TyKind::Typeof(..) + // Not strictly correct but we forbid this elsewhere anyway. + | TyKind::BareFn(..) + // TAIT stuff, still unstable at the moment, seems very hard to + // prevent this for... + | TyKind::OpaqueDef(..) + | TyKind::Never => false, + // Found one! + TyKind::Rptr(Lifetime { res: Static, .. }, _) | TyKind::TraitObject(_, Lifetime { res: Static, .. }, _) => true, + // Need to keep looking. + TyKind::Rptr(_, MutTy { ty, .. }) + | TyKind::Ptr(MutTy { ty, .. }) + | TyKind::Array(ty, _) + | TyKind::Slice(ty) => self.has_static(*ty), + + TyKind::Tup(types) => types.iter().any(|t| self.has_static(t)), + + TyKind::TraitObject(polytrait, ..) => { + polytrait.iter().any(|poly| { + self.segments_have_static(poly.trait_ref.path.segments) + }) + } + // Something like `Vec` or `Option`. Need to look inside... + TyKind::Path(qpath) => { + let segs = match qpath { + hir::QPath::Resolved(Some(maybe_ty), _) if self.has_static(maybe_ty) => return true, + hir::QPath::TypeRelative(t, _) if self.has_static(*t) => return true, + hir::QPath::LangItem(..) => return false, + hir::QPath::Resolved(_, path) => path.segments, + hir::QPath::TypeRelative(_, seg) => std::slice::from_ref(*seg), + }; + self.segments_have_static(segs) + } + } + } + + fn segments_have_static(&self, segs: &[hir::PathSegment]) -> bool { + segs.iter().any(|seg| { + seg.args() + .args + .iter() + .any(|arg| matches!(arg, hir::GenericArg::Type(t) if self.has_static(t))) + }) + } +} + declare_plrust_lint!( pub(crate) PLRUST_AUTOTRAIT_IMPLS, "Disallow impls of auto traits", @@ -535,6 +630,7 @@ static PLRUST_LINTS: Lazy> = Lazy::new(|| { let mut v = vec![ PLRUST_ASYNC, PLRUST_AUTOTRAIT_IMPLS, + PLRUST_STATIC_IMPLS, PLRUST_EXTERN_BLOCKS, PLRUST_EXTERNAL_MOD, PLRUST_FILESYSTEM_MACROS, @@ -580,6 +676,7 @@ pub fn register(store: &mut LintStore, _sess: &Session) { store.register_early_pass(move || Box::new(PlrustAsync)); store.register_early_pass(move || Box::new(PlrustExternalMod)); store.register_late_pass(move |_| Box::new(PlrustAutoTraitImpls)); + store.register_late_pass(move |_| Box::new(PlrustStaticImpls)); store.register_late_pass(move |_| Box::new(PlrustFnPointer)); store.register_late_pass(move |_| Box::new(PlrustLeaky)); store.register_late_pass(move |_| Box::new(PlrustBuiltinMacros)); diff --git a/plrustc/plrustc/uitests/static_impls.rs b/plrustc/plrustc/uitests/static_impls.rs new file mode 100644 index 00000000..b84213f9 --- /dev/null +++ b/plrustc/plrustc/uitests/static_impls.rs @@ -0,0 +1,27 @@ +#![crate_type = "lib"] + +use std::fmt::Display; + +trait Displayable { + fn display(self) -> Box; +} + +// This is more complex than the one in , to make sure the `Box`'s lang_item +// status doesn't bite us. +impl Displayable for (T, Box>) { + fn display(self) -> Box { + Box::new(self.0) + } +} + +fn extend_lt(val: T) -> Box +where + (T, Box>): Displayable, +{ + Displayable::display((val, Box::new(None))) +} + +pub fn get_garbage(s: &str) -> String { + let val = extend_lt(&String::from(s)); + val.to_string() +} diff --git a/plrustc/plrustc/uitests/static_impls.stderr b/plrustc/plrustc/uitests/static_impls.stderr new file mode 100644 index 00000000..6ba022a7 --- /dev/null +++ b/plrustc/plrustc/uitests/static_impls.stderr @@ -0,0 +1,14 @@ +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impls.rs:11:1 + | +LL | / impl Displayable for (T, Box>) { +LL | | fn display(self) -> Box { +LL | | Box::new(self.0) +LL | | } +LL | | } + | |_^ + | + = note: `-F plrust-static-impls` implied by `-F plrust-lints` + +error: aborting due to previous error + From e80165107becec86c52596f71edbc6c498978ccc Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Tue, 21 Mar 2023 14:30:10 -0700 Subject: [PATCH 2/5] Add lint for impl blocks containing `'static` things --- doc/src/config-lints.md | 17 +++++++++++++++++ plrustc/plrustc/src/lints.rs | 23 ++++++++--------------- plrustc/plrustc/uitests/static_impls.rs | 4 ++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/doc/src/config-lints.md b/doc/src/config-lints.md index 7fd7cc67..182419db 100644 --- a/doc/src/config-lints.md +++ b/doc/src/config-lints.md @@ -217,6 +217,23 @@ std::io::stderr().write_all(b"foobar").unwrap(); let _stdin_is_forbidden_too = std::io::stdin(); ``` +### `plrust_static_impls` + +This lint forbids certain `impl` blocks for types containing `&'static` references. The precise details are somewhat obscure, but can usually be avoided by making a custom struct to contain your static reference, which avoids the particular soundness hole we're concerned with. For example: + +```rust +// This is forbidden: +impl SomeTrait for (&'static Foo, Bar) { + // ... +} + +// Instead, do this: +struct MyType(&'static Foo, Bar); +impl SomeTrait for MyType { + // ... +} +``` + ### `plrust_autotrait_impls` This lint forbids explicit implementations of the safe auto traits, as a workaround for various soundness holes around these. It may be relaxed in the future if those are fixed. diff --git a/plrustc/plrustc/src/lints.rs b/plrustc/plrustc/src/lints.rs index 102eb825..9861ff3d 100644 --- a/plrustc/plrustc/src/lints.rs +++ b/plrustc/plrustc/src/lints.rs @@ -74,17 +74,6 @@ impl<'tcx> LateLintPass<'tcx> for PlrustStaticImpls { let hir::ItemKind::Impl(imp) = &item.kind else { return; }; - // The other stuff is all handled by `#![forbid(unsafe_code)]` or only - // occurs in the stdlib. - if ( - hir::Unsafety::Normal, - hir::Defaultness::Final, - hir::ImplPolarity::Positive, - hir::Constness::NotConst, - ) != (imp.unsafety, imp.defaultness, imp.polarity, imp.constness) - { - return; - }; if self.has_static(imp.self_ty) { cx.lint( PLRUST_STATIC_IMPLS, @@ -149,10 +138,14 @@ impl PlrustStaticImpls { fn segments_have_static(&self, segs: &[hir::PathSegment]) -> bool { segs.iter().any(|seg| { - seg.args() - .args - .iter() - .any(|arg| matches!(arg, hir::GenericArg::Type(t) if self.has_static(t))) + seg.args().args.iter().any(|arg| match arg { + hir::GenericArg::Lifetime(hir::Lifetime { + res: hir::LifetimeName::Static, + .. + }) => true, + hir::GenericArg::Type(t) => self.has_static(t), + _ => false, + }) }) } } diff --git a/plrustc/plrustc/uitests/static_impls.rs b/plrustc/plrustc/uitests/static_impls.rs index b84213f9..352ff108 100644 --- a/plrustc/plrustc/uitests/static_impls.rs +++ b/plrustc/plrustc/uitests/static_impls.rs @@ -6,8 +6,8 @@ trait Displayable { fn display(self) -> Box; } -// This is more complex than the one in , to make sure the `Box`'s lang_item -// status doesn't bite us. +// This is more complex than the one in the issue, to make sure the `Box`'s +// lang_item status doesn't bite us. impl Displayable for (T, Box>) { fn display(self) -> Box { Box::new(self.0) From 76661f858516da6c7a22e5ba32ebebeeac21526f Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Tue, 21 Mar 2023 16:52:25 -0700 Subject: [PATCH 3/5] Add more tests --- plrustc/plrustc/uitests/static_impl_etc.rs | 18 +++++ .../plrustc/uitests/static_impl_etc.stderr | 70 +++++++++++++++++++ ...static_impls.rs => static_impl_unsound.rs} | 0 ...mpls.stderr => static_impl_unsound.stderr} | 2 +- 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 plrustc/plrustc/uitests/static_impl_etc.rs create mode 100644 plrustc/plrustc/uitests/static_impl_etc.stderr rename plrustc/plrustc/uitests/{static_impls.rs => static_impl_unsound.rs} (100%) rename plrustc/plrustc/uitests/{static_impls.stderr => static_impl_unsound.stderr} (90%) diff --git a/plrustc/plrustc/uitests/static_impl_etc.rs b/plrustc/plrustc/uitests/static_impl_etc.rs new file mode 100644 index 00000000..d3a1aed2 --- /dev/null +++ b/plrustc/plrustc/uitests/static_impl_etc.rs @@ -0,0 +1,18 @@ +#![crate_type = "lib"] + +trait Foo {} +struct Bar(core::marker::PhantomData<(A, B)>); +struct Baz<'a, A>(core::marker::PhantomData<&'a A>); +trait Quux {} + +impl Foo for &'static T {} +impl Foo for &'static mut T {} +impl Foo for [&'static T] {} +impl Foo for &[&'static T] {} +impl Foo for (i32, [&'static T]) {} +impl Foo for (i32, [&'static T; 1]) {} +impl Foo for *const &'static T {} +impl Foo for Bar {} +impl Foo for Baz<'static, T> {} +impl Foo for dyn Quux<&'static T> {} +impl Foo for &'static dyn Quux {} diff --git a/plrustc/plrustc/uitests/static_impl_etc.stderr b/plrustc/plrustc/uitests/static_impl_etc.stderr new file mode 100644 index 00000000..05c4acd9 --- /dev/null +++ b/plrustc/plrustc/uitests/static_impl_etc.stderr @@ -0,0 +1,70 @@ +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:8:1 + | +LL | impl Foo for &'static T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-F plrust-static-impls` implied by `-F plrust-lints` + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:9:1 + | +LL | impl Foo for &'static mut T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:10:1 + | +LL | impl Foo for [&'static T] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:11:1 + | +LL | impl Foo for &[&'static T] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:12:1 + | +LL | impl Foo for (i32, [&'static T]) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:13:1 + | +LL | impl Foo for (i32, [&'static T; 1]) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:14:1 + | +LL | impl Foo for *const &'static T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:15:1 + | +LL | impl Foo for Bar {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:16:1 + | +LL | impl Foo for Baz<'static, T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:17:1 + | +LL | impl Foo for dyn Quux<&'static T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `impl` blocks for types containing `'static` references are not allowed + --> $DIR/static_impl_etc.rs:18:1 + | +LL | impl Foo for &'static dyn Quux {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 11 previous errors + diff --git a/plrustc/plrustc/uitests/static_impls.rs b/plrustc/plrustc/uitests/static_impl_unsound.rs similarity index 100% rename from plrustc/plrustc/uitests/static_impls.rs rename to plrustc/plrustc/uitests/static_impl_unsound.rs diff --git a/plrustc/plrustc/uitests/static_impls.stderr b/plrustc/plrustc/uitests/static_impl_unsound.stderr similarity index 90% rename from plrustc/plrustc/uitests/static_impls.stderr rename to plrustc/plrustc/uitests/static_impl_unsound.stderr index 6ba022a7..fc9a421d 100644 --- a/plrustc/plrustc/uitests/static_impls.stderr +++ b/plrustc/plrustc/uitests/static_impl_unsound.stderr @@ -1,5 +1,5 @@ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impls.rs:11:1 + --> $DIR/static_impl_unsound.rs:11:1 | LL | / impl Displayable for (T, Box>) { LL | | fn display(self) -> Box { From 7f9920aa6e73399763c063afa0eb6e1c6b5725fd Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Tue, 21 Mar 2023 16:54:44 -0700 Subject: [PATCH 4/5] Lint the span of the problematic type rather than the whole impl block --- plrustc/plrustc/src/lints.rs | 2 +- .../plrustc/uitests/static_impl_etc.stderr | 44 +++++++++---------- .../uitests/static_impl_unsound.stderr | 10 ++--- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/plrustc/plrustc/src/lints.rs b/plrustc/plrustc/src/lints.rs index 9861ff3d..3e89817f 100644 --- a/plrustc/plrustc/src/lints.rs +++ b/plrustc/plrustc/src/lints.rs @@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for PlrustStaticImpls { cx.lint( PLRUST_STATIC_IMPLS, "`impl` blocks for types containing `'static` references are not allowed", - |b| b.set_span(item.span), + |b| b.set_span(imp.self_ty.span), ) } } diff --git a/plrustc/plrustc/uitests/static_impl_etc.stderr b/plrustc/plrustc/uitests/static_impl_etc.stderr index 05c4acd9..e0f376f7 100644 --- a/plrustc/plrustc/uitests/static_impl_etc.stderr +++ b/plrustc/plrustc/uitests/static_impl_etc.stderr @@ -1,70 +1,70 @@ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:8:1 + --> $DIR/static_impl_etc.rs:8:17 | LL | impl Foo for &'static T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = note: `-F plrust-static-impls` implied by `-F plrust-lints` error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:9:1 + --> $DIR/static_impl_etc.rs:9:17 | LL | impl Foo for &'static mut T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:10:1 + --> $DIR/static_impl_etc.rs:10:17 | LL | impl Foo for [&'static T] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:11:1 + --> $DIR/static_impl_etc.rs:11:17 | LL | impl Foo for &[&'static T] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:12:1 + --> $DIR/static_impl_etc.rs:12:17 | LL | impl Foo for (i32, [&'static T]) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:13:1 + --> $DIR/static_impl_etc.rs:13:17 | LL | impl Foo for (i32, [&'static T; 1]) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:14:1 + --> $DIR/static_impl_etc.rs:14:17 | LL | impl Foo for *const &'static T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:15:1 + --> $DIR/static_impl_etc.rs:15:17 | LL | impl Foo for Bar {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:16:1 + --> $DIR/static_impl_etc.rs:16:17 | LL | impl Foo for Baz<'static, T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:17:1 + --> $DIR/static_impl_etc.rs:17:17 | LL | impl Foo for dyn Quux<&'static T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_etc.rs:18:1 + --> $DIR/static_impl_etc.rs:18:17 | LL | impl Foo for &'static dyn Quux {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 11 previous errors diff --git a/plrustc/plrustc/uitests/static_impl_unsound.stderr b/plrustc/plrustc/uitests/static_impl_unsound.stderr index fc9a421d..b37d996b 100644 --- a/plrustc/plrustc/uitests/static_impl_unsound.stderr +++ b/plrustc/plrustc/uitests/static_impl_unsound.stderr @@ -1,12 +1,8 @@ error: `impl` blocks for types containing `'static` references are not allowed - --> $DIR/static_impl_unsound.rs:11:1 + --> $DIR/static_impl_unsound.rs:11:34 | -LL | / impl Displayable for (T, Box>) { -LL | | fn display(self) -> Box { -LL | | Box::new(self.0) -LL | | } -LL | | } - | |_^ +LL | impl Displayable for (T, Box>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-F plrust-static-impls` implied by `-F plrust-lints` From 1c3ce5adfd2d0b601e5ed724cb0f4e95b81788b9 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Wed, 22 Mar 2023 16:05:22 -0700 Subject: [PATCH 5/5] Update plrustc/plrustc/src/lints.rs Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com> --- plrustc/plrustc/src/lints.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plrustc/plrustc/src/lints.rs b/plrustc/plrustc/src/lints.rs index 3e89817f..cd6400f1 100644 --- a/plrustc/plrustc/src/lints.rs +++ b/plrustc/plrustc/src/lints.rs @@ -144,7 +144,9 @@ impl PlrustStaticImpls { .. }) => true, hir::GenericArg::Type(t) => self.has_static(t), - _ => false, + hir::GenericArg::Const(_) | hir::GenericArg::Infer(_) + // Wasn't static + | hir::GenericArg::Lifetime(_) => false, }) }) }