RS.CLIPPY.BORROWED_BOX

A borrow of a boxed type

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: borrowed_box. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for usage of &Box<T> anywhere in the code. Check the Box documentation for more information.

Why is this bad?

A &Box<T> parameter requires the function caller to box T first before passing it to a function. Using &T defines a concrete type for the parameter and generalizes the function, this would also auto-deref to &T at the function call site if passed a &Box<T>.

Example

fn foo(bar: &Box<T>) { ... }

Better:

fn foo(bar: &T) { ... }