I'm just a beginner to Rust, but got rustup, cargo, rustc etc all working and VSCode set up. Even breakpoints work. For function parameters I sometimes get the proper type hints, but for variable declarations I only see ...

I wonder why I see no inlay hint for String::from("Hallo "); but do get an inlay hint for greetings.push_str("Richard");? The only difference I see is that the first call is to a static function, while the 2nd is to an object method.

Settings:

"rust-analyzer.inlayHints.bindingModeHints.enable": true,
"rust-analyzer.inlayHints.closingBraceHints.enable": false,
"rust-analyzer.inlayHints.closingBraceHints.minLines": 10,
"rust-analyzer.inlayHints.closureReturnTypeHints.enable": "always",
"rust-analyzer.inlayHints.expressionAdjustmentHints.enable": "always",
"rust-analyzer.inlayHints.expressionAdjustmentHints.hideOutsideUnsafe": true,
"rust-analyzer.inlayHints.lifetimeElisionHints.enable": "always",
"rust-analyzer.inlayHints.lifetimeElisionHints.useParameterNames": true,
"rust-analyzer.inlayHints.maxLength": 0,
"rust-analyzer.inlayHints.reborrowHints.enable": "always",
//"rust-analyzer.inlayHints.typeHints.hideNamedConstructor": true,
"rust-analyzer.inlayHints.typeHints.enable": true,
"rust-analyzer.checkOnSave.command":"clippy",
"rust-analyzer.displayInlayHints":true,

Then question 2 (perhaps this should be a separate question): why can't I factor out rust-analyzer.inlayHints and write something like this in the settings?

   "rust-analyzer" :  {
        "inlayHints" : {
            "closingBraceHints.minLines": 10,
            "maxLength": 0,
            "expressionAdjustmentHints.enable": "always",
            "lifetimeElisionHints.enable": "never",
            "reborrowHints.enable": "always",
        },
        "checkOnSave.command":"clippy",
        "displayInlayHints":true
    },

enter image description here

1

There are 1 best solutions below

1
On

You set inlay hints' maxLength to zero. Set it to something higher and you will see the types.