mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Add inlay hint for exclusive ranges
Adds an inlay hint containing a '<' character to exclusive range expressions and patterns that specify an upper bound.
This commit is contained in:
parent
f595e60b6d
commit
3c378b9c70
14 changed files with 209 additions and 17 deletions
|
@ -32,6 +32,7 @@ mod fn_lifetime_fn;
|
|||
mod implicit_static;
|
||||
mod param_name;
|
||||
mod implicit_drop;
|
||||
mod range_exclusive;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct InlayHintsConfig {
|
||||
|
@ -51,6 +52,7 @@ pub struct InlayHintsConfig {
|
|||
pub param_names_for_lifetime_elision_hints: bool,
|
||||
pub hide_named_constructor_hints: bool,
|
||||
pub hide_closure_initialization_hints: bool,
|
||||
pub range_exclusive_hints: bool,
|
||||
pub closure_style: ClosureStyle,
|
||||
pub max_length: Option<usize>,
|
||||
pub closing_brace_hints_min_lines: Option<usize>,
|
||||
|
@ -127,6 +129,7 @@ pub enum InlayKind {
|
|||
Parameter,
|
||||
Type,
|
||||
Drop,
|
||||
RangeExclusive,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -517,13 +520,20 @@ fn hints(
|
|||
closure_captures::hints(hints, famous_defs, config, file_id, it.clone());
|
||||
closure_ret::hints(hints, famous_defs, config, file_id, it)
|
||||
},
|
||||
ast::Expr::RangeExpr(it) => range_exclusive::hints(hints, config, it),
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
ast::Pat(it) => {
|
||||
binding_mode::hints(hints, sema, config, &it);
|
||||
if let ast::Pat::IdentPat(it) = it {
|
||||
bind_pat::hints(hints, famous_defs, config, file_id, &it);
|
||||
match it {
|
||||
ast::Pat::IdentPat(it) => {
|
||||
bind_pat::hints(hints, famous_defs, config, file_id, &it);
|
||||
}
|
||||
ast::Pat::RangePat(it) => {
|
||||
range_exclusive::hints(hints, config, it);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Some(())
|
||||
},
|
||||
|
@ -621,6 +631,7 @@ mod tests {
|
|||
closing_brace_hints_min_lines: None,
|
||||
fields_to_resolve: InlayFieldsToResolve::empty(),
|
||||
implicit_drop_hints: false,
|
||||
range_exclusive_hints: false,
|
||||
};
|
||||
pub(super) const TEST_CONFIG: InlayHintsConfig = InlayHintsConfig {
|
||||
type_hints: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue