1

I wrote this the other day:

let µ = ... some expression ...

(As it happens, the µ sign is easily typeable on my keyboard, just AltGr+m. This is why I have a habit to use this letter quite often especially when it is about small values.)

Now I got this:

identifier contains uncommon Unicode codepoints
`#[warn(uncommon_codepoints)]` on by default

No problem, I'll just allow it, I thought, and put this at the front:

#![allow(uncommon_codepoints)]

But no, it's utterly hesitant against greek:

allow(uncommon_codepoints) is ignored unless specified at crate level
`#[warn(unused_attributes)]` on by default

I would think it is at least debatable what "uncommon" exactly is. But I'm not really interested in that discussion, as long as I can turn it off.

So please ... how exactly do I specify something at the crate level? I tried it in main.rs and libs.rs but it wont accept it.

Edit

This really starts to become interesting:

I put the line

#![allow(uncommon_codepoints)]

as line 1 in main.rs and it now stops complaining about the unused_attribute. However, the "uncommon codepoint" warning still appears when compiling the file that contains it (i.e. with cargo build). I am at rustc 1.58.1 (stable, AFAIK)

I also found out that what my keyboard produces is not U+03BC GREEK SMALL LETTER MU but U+00B5 MICRO SIGN. It's still a letter, lowercase. Now, the interesting thing is: the uncommon Unicode warning does not appear for a genuine greek Mu, but for the micro sign it does!

Is there any other place I can turn off annoying and (from my point of view utterly useless) warnings? In general, I highly appreciate rust's detailed and often helpful warnings (though lately I found myself making an unused HashSet just to avoid the warnings about unused imports --- hey I know I will need this later, so please stop nagging), but this unicode thingy is a bit overdone. Its a valid variable name according to rust lexical syntax, and I really do want to use it. Period.

Ingo
  • 36,037
  • 5
  • 53
  • 100
  • 2
    Is [that](https://stackoverflow.com/a/27455138/11527076) useful? – prog-fh Feb 13 '22 at 16:42
  • What do you mean "it won't accept it"? When I put `#![allow(uncommon_codepoints)]` in `main.rs` and use mu as an identifier in a submodule, I don't get any warnings/errors on stable rustc 1.58.1. Can you provide more details? – cameron1024 Feb 13 '22 at 17:59
  • The only thing I can think of if you tried putting it in `main.rs` and `lib.rs` is that it must go *at the very top of the file*. If you didn't, you'd get a similar error indicating where you put it is not allowed. – kmdreko Feb 13 '22 at 18:56
  • Ok, thank you all so far i put it as first line in main.rs and now it doesn't say it will ignore it anymore. However, the warning concerning the µ (which is in another file) still appears. Is there anything else where I can turn it off? – Ingo Feb 13 '22 at 21:30
  • 1
    Putting that line in `main.rs` or `lib.rs` should apply it transitively to the entire crate. If you're still getting an error message, it's possible the file you're editing is in another crate (perhaps if you're in a large multi-crate project), or that your IDE has got a bit stuck and might need restarting. If it's definitely in the same crate, and you've cleared caches/restarted your IDE, it might be worth raising an issue with rust-analyzer – cameron1024 Feb 13 '22 at 21:46
  • *"Is there any other place I can turn off ... warnings?"* - you can specify [lints](https://doc.rust-lang.org/rustc/lints/groups.html) via command line via `RUSTFLAGS` or via `.cargo/config.toml` file, but usually crate attributes are more common, visible, and accessible. If you really want the compiler to just shut up, `#![allow(warnings, unused)]` gets most of it I think. – kmdreko Feb 13 '22 at 23:53
  • @cameron - I have now put it *also* in lib.rs and, after cargo clean and cargo build it suddenly worked. I guess, when I have src/rasch.rs (with main) and src/lib.rs and all other rs-files in src are declared as modules in lib.rs, then my crate is rasch? But then why does cargo say `rasch (lib) generated 2 warnings` AFAICS I nowhere asked for a lib crate, all I want is the good old binary executable which I also get (under the name rasch) – Ingo Feb 14 '22 at 00:38

0 Answers0