License header location in a module with doc comments

Somewhat minor question: For a module that has both a license header and an overall doc comment (//!), is there a convention for what goes first?

i.e. is this preferred:

// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

//! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
//! do eiusmod tempor incididunt ut labore et dolore magna aliqua.
//! Ut enim ad minim veniam, quis nostrud exercitation ullamco

or the other way round?

The rust-lang/rust codebase puts the license header first.

1 Like

The pervasive convention for license headers is that they appear as near the start of the file as possible, preferably at the very start of the file. If a doc comment or anything else appeared ahead of the license header, it would create confusion about whether that content is covered by the license documented in the header.

2 Likes