Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Don't ignore incomplete server config, use default values if needed#432

Merged
nrc merged 1 commit intorust-lang:masterfrom
Xanewok:config
Aug 2, 2017
Merged

Don't ignore incomplete server config, use default values if needed#432
nrc merged 1 commit intorust-lang:masterfrom
Xanewok:config

Conversation

@Xanewok
Copy link
Copy Markdown
Contributor

@Xanewok Xanewok commented Aug 2, 2017

This probably fixes #431 and related.
In the current implementation serialization for RLS options can fail if not every option is provided, and if that happens, configuration is essentially ignored. Since for some time few options weren't included in the VS Code (and possibly ignored completely when using different clients) extension, user configuration had no effect.
This makes it so that missing options are set to the values set in Default impl for Config.

Comment thread src/actions/mod.rs
use serde::de::Error;

trace!("config change: {:?}", params.settings);
let config = params.settings.get("rust")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to chaining result to get better error messages (which incidentally lead me to the cause of the problem). Is this okay?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, looks good

Comment thread src/actions/mod.rs
trace!("config change: {:?}", params.settings);
let config = params.settings.get("rust")
.ok_or(serde_json::Error::missing_field("rust"))
.and_then(|value| Config::deserialize(value));
Copy link
Copy Markdown
Contributor Author

@Xanewok Xanewok Aug 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asked over at #serde and changed to Type::serialize, since from what I understand it allows to deserialize from ref directly instead of cloning the Value beforehand

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Comment thread src/actions/mod.rs Outdated
).unwrap();
out.response(output);
}
use serde::Deserialize;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those okay in the fn scope or should I move them to the top of the file?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move them to the top. I'm not really a fan of function-scope use, except in cases where you would never want the imports elsewhere in the module (as opposed to just happening not to need them right now)

Copy link
Copy Markdown
Member

@nrc nrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only thing to change is moving the imports out of the function

Comment thread src/actions/mod.rs Outdated
).unwrap();
out.response(output);
}
use serde::Deserialize;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move them to the top. I'm not really a fan of function-scope use, except in cases where you would never want the imports elsewhere in the module (as opposed to just happening not to need them right now)

Comment thread src/actions/mod.rs
use serde::de::Error;

trace!("config change: {:?}", params.settings);
let config = params.settings.get("rust")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, looks good

Comment thread src/actions/mod.rs
trace!("config change: {:?}", params.settings);
let config = params.settings.get("rust")
.ok_or(serde_json::Error::missing_field("rust"))
.and_then(|value| Config::deserialize(value));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@Xanewok
Copy link
Copy Markdown
Contributor Author

Xanewok commented Aug 2, 2017

Moved the imports out and pushed the new version

@nrc nrc merged commit d10e3ad into rust-lang:master Aug 2, 2017
@Xanewok Xanewok deleted the config branch August 3, 2017 07:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rust.build_lib setting doesn't have any effect on the project with both binary and lib modules

2 participants