`invalid base+index expression` when trying to use gs in assembly

I can't figure out why this doesn't work.
NASM will compile mov rax, [gs:0], but rust errors out for all 3

fn main() {
    unsafe {
        core::arch::asm!("mov rax, [gs]");
        core::arch::asm!("mov rax, [gs:0]");
        core::arch::asm!("mov rax, [gs+0]");
    }
}

(Playground)

llvm support at&t syntax and intel syntax, and by default, rust uses intel syntax, but you can choose at&t syntax if you prefer.

I do think nasm syntax is better than intel syntax as standalone assembler, but it's not designed to work with compiler backend, and it is not supported by llvm.

the intel syntax equivalence for your example is:

asm!("mov rax, gs:[0]");

sorry, it's been a while since I last used nasm, but I think the actual equivalence should be:

asm!("mov rax, gs:0");

if in doubt, you should check the generated machine code to be sure.