← All lints

redundant_prelude_import

L0208Stylewarn

use of a name the prelude already provides

use std.tree.{Rooted} imports what the prelude gives every program

Flagged
use std.tree.{Rooted}
domain V = 1..=3
let t = Rooted(Graph.undirected(read<Tree<V>>()), V.first!)
print(t.size(V.first!))
Write instead
domain V = 1..=3
let t = Rooted(Graph.undirected(read<Tree<V>>()), V.first!)
print(t.size(V.first!))

Why

The prelude (std/prelude.cp) brings in each of its names when a program uses it, so use std.tree.{Rooted} or use std.mod.Mod says nothing. cpl fix drops the name, and the use when nothing is left. An alias, a glob, a pub use and the imports of a library (a file with pub items) are left alone.

The practice it serves

Spelling that hides what the code means. Family: R. Redundancy and dead code.

Not flagged

A near miss: close to the pattern, but not it.

Near miss
use std.geometry.{same_dir}
print(yes(same_dir(Pt(1, 0), Pt(2, 0))))

Turn it off

For one block, wrap it in with lint(redundant_prelude_import: allow):. For a project, add redundant_prelude_import = "allow" under [lints] in cp.toml.

Generated from spec/lints/redundant_prelude_import, the same record the linter is built from.