Issue #1110: A lower-case comptime in a function body prints rustc’s non_upper_case_globals warning

Open and answer this issue on GitHub.

ready · opened 2026-10-31 · updated 2026-10-31 · 1 comment

Seen by the tools architect while probing #1019 (2026-10-31).

Problem

A comptime with a lower-case name inside a function body prints rustc’s lint on the generated constant, in rustc’s words, often several times: warning: Constant d should have an upper case name. ... note: Convert the identifier to upper case. Our own tests write lower-case comptime a = f.name (tests/compiler/tests/a_comptime_calls_a_function_over_a_field.nika), and no part of Part I-III asks for upper case. A warning the language does not define should not reach the user.

Probe (target/fast/nikaia at 69ea78d)

fn main() {
	comptime d = 3 + 4
	println(f"{d}")
}

Wanted: 7, no warning. Today: 7 and the rustc non_upper_case_globals warning; in an unrolled turn (for f in T::fields { comptime d = ... }) once per turn.

Suspected location (not traced)

The emitter’s const for a body comptime (emit_* where Stmt::Comptime / a local comptime is written): it should carry #[allow(non_upper_case_globals)], as other generated items carry their allows.

To build

  1. A body comptime with any name emits no rustc naming warning. Test: the probe as tests/compiler/tests/a_lower_case_comptime_warns_nothing.nika + .stdout (and an empty .stderr if the runner pins warnings).

Generated by Claude Code

Comments

keywan-ghadami, 2026-10-31

A second rustc lint of the same kind (generated code, rustc’s words): an unrolled turn with a return inside it prints warning: Unnecessary braces around block return value twice. Probe (69ea78d):

struct Contact { name: String, age: i64 = 7, }
fn turn[T: Struct]() -> String sync {
	for f in T::fields {
		if f.name == "age" { return f"{f.name}" }
	}
	panic("no field age")
}
fn main() {
	let s = turn[Contact]()
	println(s)
}

Prints age and the warning. To build, step 2: the unrolled turn’s block carries #[allow(unused_braces)] (or is written without the braces), test beside step 1’s.


Generated by Claude Code

Back to Open Issues