"warning: variant `UploadTerrain` is never constructed" false alarm
⚓ Rust 📅 2026-02-02 👤 surdeus 👁️ 9"Warning: variant UploadTerrain is never constructed" as a false alarm.
Here's the enum declaration:
--> src/server/auth.rs:
pub enum AuthorizeType {
/// Upload terrain. Can add and update terrain data.
UploadTerrain,
/// Upload impostors. Can add and upload impostor data.
UploadImpostors,
}
Here's the use, in another file that brings in "auth" with "mod".
mod auth;
use auth::{Authorizer, AuthorizeType};
...
`self.owner_name = Some(Authorizer::authorize(AuthorizeType::UploadTerrain, env, params)?);`
The error message is:
warning: variant `UploadImpostors` is never constructed
--> src/server/auth.rs:37:5
|
33 | pub enum AuthorizeType {
| ------------- variant in this enum
...
37 | UploadImpostors,
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
As a check, I commented out that enum case, and then I get an error:
error[E0599]: no variant or associated item named `UploadImpostors` found for enum `AuthorizeType` in the current scope
--> src/server/uploadimpostor.rs:470:77
|
470 | ...horizeType::UploadImpostors, env, params)?);
| ^^^^^^^^^^^^^^^ variant or associated item not found in `AuthorizeType`
|
::: src/server/auth.rs:33:1
|
33 | pub enum AuthorizeType {
| ---------------------- variant or associated item `UploadImpostors` not found for this enum
So that enum case really was needed.
The enum is pub, so the known special case around non-pub enums does not apply.
The unusual thing here is that the file that uses the enum brings in the file that defines it with "mod" directly. There's no "lib.rs" or "mod.rs" file involved. That ought to work.
Obscure case, or lint bug?
Code is in GitHub - John-Nagle/maptools: Tools for manipulating Second Life / Open Simulator map data branch "newregionorder", if anybody cares
rustc 1.93.0 (254b59607 2026-01-19) stable.
3 posts - 3 participants
🏷️ Rust_feed