mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
8536eb016c
commit
a99a48e786
86 changed files with 3149 additions and 1653 deletions
|
@ -238,9 +238,9 @@ fn format_args_expand(
|
|||
) -> ExpandResult<tt::Subtree> {
|
||||
// We expand `format_args!("", a1, a2)` to
|
||||
// ```
|
||||
// std::fmt::Arguments::new_v1(&[], &[
|
||||
// std::fmt::ArgumentV1::new(&arg1,std::fmt::Display::fmt),
|
||||
// std::fmt::ArgumentV1::new(&arg2,std::fmt::Display::fmt),
|
||||
// $crate::fmt::Arguments::new_v1(&[], &[
|
||||
// $crate::fmt::ArgumentV1::new(&arg1,$crate::fmt::Display::fmt),
|
||||
// $crate::fmt::ArgumentV1::new(&arg2,$crate::fmt::Display::fmt),
|
||||
// ])
|
||||
// ```,
|
||||
// which is still not really correct, but close enough for now
|
||||
|
@ -262,10 +262,10 @@ fn format_args_expand(
|
|||
}
|
||||
let _format_string = args.remove(0);
|
||||
let arg_tts = args.into_iter().flat_map(|arg| {
|
||||
quote! { std::fmt::ArgumentV1::new(&(#arg), std::fmt::Display::fmt), }
|
||||
quote! { #DOLLAR_CRATE::fmt::ArgumentV1::new(&(#arg), #DOLLAR_CRATE::fmt::Display::fmt), }
|
||||
}.token_trees);
|
||||
let expanded = quote! {
|
||||
std::fmt::Arguments::new_v1(&[], &[##arg_tts])
|
||||
#DOLLAR_CRATE::fmt::Arguments::new_v1(&[], &[##arg_tts])
|
||||
};
|
||||
ExpandResult::ok(expanded)
|
||||
}
|
||||
|
@ -675,8 +675,8 @@ fn option_env_expand(
|
|||
};
|
||||
|
||||
let expanded = match get_env_inner(db, arg_id, &key) {
|
||||
None => quote! { std::option::Option::None::<&str> },
|
||||
Some(s) => quote! { std::option::Some(#s) },
|
||||
None => quote! { #DOLLAR_CRATE::option::Option::None::<&str> },
|
||||
Some(s) => quote! { #DOLLAR_CRATE::option::Some(#s) },
|
||||
};
|
||||
|
||||
ExpandResult::ok(ExpandedEager::new(expanded))
|
||||
|
|
|
@ -221,8 +221,16 @@ pub fn expand_speculative(
|
|||
fixup::reverse_fixups(&mut speculative_expansion.value, &spec_args_tmap, &fixups.undo_info);
|
||||
let (node, rev_tmap) = token_tree_to_syntax_node(&speculative_expansion.value, expand_to);
|
||||
|
||||
let range = rev_tmap.first_range_by_token(token_id, token_to_map.kind())?;
|
||||
let token = node.syntax_node().covering_element(range).into_token()?;
|
||||
let syntax_node = node.syntax_node();
|
||||
let token = rev_tmap
|
||||
.ranges_by_token(token_id, token_to_map.kind())
|
||||
.filter_map(|range| syntax_node.covering_element(range).into_token())
|
||||
.min_by_key(|t| {
|
||||
// prefer tokens of the same kind and text
|
||||
// Note the inversion of the score here, as we want to prefer the first token in case
|
||||
// of all tokens having the same score
|
||||
(t.kind() != token_to_map.kind()) as u8 + (t.text() != token_to_map.text()) as u8
|
||||
})?;
|
||||
Some((node.syntax_node(), token))
|
||||
}
|
||||
|
||||
|
|
|
@ -259,6 +259,7 @@ macro_rules! __known_path {
|
|||
(core::future::Future) => {};
|
||||
(core::future::IntoFuture) => {};
|
||||
(core::ops::Try) => {};
|
||||
(core::ops::FromResidual) => {};
|
||||
($path:path) => {
|
||||
compile_error!("Please register your known path in the path module")
|
||||
};
|
||||
|
|
|
@ -279,6 +279,8 @@ pub mod known {
|
|||
RangeToInclusive,
|
||||
RangeTo,
|
||||
Range,
|
||||
Residual,
|
||||
FromResidual,
|
||||
Neg,
|
||||
Not,
|
||||
None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue