]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #12515 - Veykril:rustc-proc-macros, r=Veykril
bors [Sun, 12 Jun 2022 17:35:55 +0000 (17:35 +0000)]
Auto merge of #12515 - Veykril:rustc-proc-macros, r=Veykril

fix: Pass the build data to rustc_private crates

With this all proc-macros should resolve in rustc now when setting up the build script running command properly.

2 years agofix: Pass the build data to rustc_private crates
Lukas Wirth [Sun, 12 Jun 2022 17:29:45 +0000 (19:29 +0200)]
fix: Pass the build data to rustc_private crates

2 years agoAuto merge of #12514 - Veykril:proc-mac-err, r=Veykril
bors [Sun, 12 Jun 2022 17:27:41 +0000 (17:27 +0000)]
Auto merge of #12514 - Veykril:proc-mac-err, r=Veykril

More precise proc-macro errors

2 years agoMore precise proc-macro errors
Lukas Wirth [Sun, 12 Jun 2022 16:44:46 +0000 (18:44 +0200)]
More precise proc-macro errors

2 years agoAuto merge of #12513 - Veykril:ty-utils, r=Veykril
bors [Sun, 12 Jun 2022 14:08:08 +0000 (14:08 +0000)]
Auto merge of #12513 - Veykril:ty-utils, r=Veykril

internal: Simplify `hir_ty::utils`

2 years agointernal: Simplify `hir_ty::utils`
Lukas Wirth [Sun, 12 Jun 2022 14:07:08 +0000 (16:07 +0200)]
internal: Simplify `hir_ty::utils`

2 years agoAuto merge of #12509 - Veykril:ty-utils, r=Veykril
bors [Sun, 12 Jun 2022 12:40:57 +0000 (12:40 +0000)]
Auto merge of #12509 - Veykril:ty-utils, r=Veykril

internal: Remove `Generics::type_iter` in favor of `Generics::iter`

2 years agointernal: Remove `Generics::type_iter` in favor of `Generics::iter`
Lukas Wirth [Sun, 12 Jun 2022 12:40:37 +0000 (14:40 +0200)]
internal: Remove `Generics::type_iter` in favor of `Generics::iter`

2 years agoAuto merge of #12455 - bitgaoshu:fix_12441, r=flodiebold
bors [Sun, 12 Jun 2022 09:01:00 +0000 (09:01 +0000)]
Auto merge of #12455 - bitgaoshu:fix_12441, r=flodiebold

fix: #12441 False-positive type-mismatch error with generic future

I think the reason is same with #11815.
add ```Sized``` bound for ```AsyncBlockTypeImplTrait```.

2 years agoAuto merge of #12508 - Veykril:req-retry, r=Veykril
bors [Sun, 12 Jun 2022 00:56:52 +0000 (00:56 +0000)]
Auto merge of #12508 - Veykril:req-retry, r=Veykril

fix: Don't respond to cancelled requests when retrying them

Fixes https://github.com/rust-lang/rust-analyzer/issues/12482

2 years agofix: Don't respond to cancelled requests when retrying them
Lukas Wirth [Sun, 12 Jun 2022 00:56:19 +0000 (02:56 +0200)]
fix: Don't respond to cancelled requests when retrying them

2 years agoAuto merge of #12506 - cgburgess:master, r=Veykril
bors [Sat, 11 Jun 2022 16:57:38 +0000 (16:57 +0000)]
Auto merge of #12506 - cgburgess:master, r=Veykril

minor: Fix typo in style guide

Fix type `Ues` -> `Use` in `style.md`

2 years agofix typo in style.md
Chris Burgess [Sat, 11 Jun 2022 16:50:36 +0000 (12:50 -0400)]
fix typo in style.md

2 years agoAuto merge of #12504 - rust-lang:Veykril-patch-1, r=Veykril
bors [Sat, 11 Jun 2022 11:41:26 +0000 (11:41 +0000)]
Auto merge of #12504 - rust-lang:Veykril-patch-1, r=Veykril

fix: Fix config patching for callable snippets

Closes https://github.com/rust-lang/rust-analyzer/issues/12498

2 years agofix: Fix config patching for callable snippets
Lukas Wirth [Sat, 11 Jun 2022 11:41:06 +0000 (13:41 +0200)]
fix: Fix config patching for callable snippets

2 years agoAuto merge of #12481 - XFFXFF:add_label_to_loop, r=Veykril
bors [Sat, 11 Jun 2022 11:34:08 +0000 (11:34 +0000)]
Auto merge of #12481 - XFFXFF:add_label_to_loop, r=Veykril

assist: add label to loop

closes: #12392

I changed `'loop` to `'l`, as `cargo check` says `'loop` is an invalid label name.

2 years agoAuto merge of #12449 - Veykril:version, r=Veykril
bors [Fri, 10 Jun 2022 23:35:38 +0000 (23:35 +0000)]
Auto merge of #12449 - Veykril:version, r=Veykril

Bring the version command output in line with other rust tools

Inspired by how cargo handles it
Fixes https://github.com/rust-lang/rust-analyzer/issues/12280
![image](https://user-images.githubusercontent.com/3757771/171680176-236451ee-2c6c-449f-8aa5-4a047e8cc907.png)

2 years agorestrict the assist so that it only appears if the cursor is on the loop keyword
XFFXFF [Fri, 10 Jun 2022 23:02:42 +0000 (07:02 +0800)]
restrict the assist so that it only appears if the cursor is on the loop keyword

2 years agochange 'loop to 'l, as 'loop is not a valid label name
XFFXFF [Mon, 6 Jun 2022 11:20:01 +0000 (19:20 +0800)]
change 'loop to 'l, as 'loop is not a valid label name

2 years agomake generated test pass and make tidy happy
XFFXFF [Mon, 6 Jun 2022 11:18:44 +0000 (19:18 +0800)]
make generated test pass and make tidy happy

2 years agoadd more tests and some doc
XFFXFF [Mon, 6 Jun 2022 10:57:37 +0000 (18:57 +0800)]
add more tests and some doc

2 years agoMake add_label_to_loop basically work
XFFXFF [Mon, 6 Jun 2022 10:49:29 +0000 (18:49 +0800)]
Make add_label_to_loop basically work

2 years agoAuto merge of #12490 - yue4u:fix/show-enum-in-fresh-use-tree, r=Veykril
bors [Fri, 10 Jun 2022 20:33:17 +0000 (20:33 +0000)]
Auto merge of #12490 - yue4u:fix/show-enum-in-fresh-use-tree, r=Veykril

fix: complete non-std enum at the start of `use` completions

close: #12421

2 years agoAuto merge of #12464 - harpsword:fix-inline-variable-mismatched-type, r=Veykril
bors [Fri, 10 Jun 2022 20:24:06 +0000 (20:24 +0000)]
Auto merge of #12464 - harpsword:fix-inline-variable-mismatched-type, r=Veykril

feat: fix inline variable produce mismatched type

wrap reference for RefExpr initializer to fix #12453

2 years agoAuto merge of #12477 - hasali19:auto-reload, r=Veykril
bors [Fri, 10 Jun 2022 20:11:48 +0000 (20:11 +0000)]
Auto merge of #12477 - hasali19:auto-reload, r=Veykril

Restart server automatically on settings changes

Closes #12476

I think this works quite well, but if you think it would be better to put it behind a setting I can do that.

2 years agoAuto merge of #12473 - yue4u:fix/no-enum-parens-in-use, r=Veykril
bors [Fri, 10 Jun 2022 20:03:29 +0000 (20:03 +0000)]
Auto merge of #12473 - yue4u:fix/no-enum-parens-in-use, r=Veykril

fix: avoid adding enum parens in use path

close #12420

2 years agoAuto merge of #12502 - Veykril:deps, r=Veykril
bors [Fri, 10 Jun 2022 19:51:04 +0000 (19:51 +0000)]
Auto merge of #12502 - Veykril:deps, r=Veykril

internal: Bump Dependencies

2 years agointernal: Bump Dependencies
Lukas Wirth [Fri, 10 Jun 2022 14:30:09 +0000 (16:30 +0200)]
internal: Bump Dependencies

2 years agoAuto merge of #12501 - Veykril:dashmap, r=Veykril
bors [Fri, 10 Jun 2022 14:20:46 +0000 (14:20 +0000)]
Auto merge of #12501 - Veykril:dashmap, r=Veykril

internal: Update dashmap and freeze its version

2 years agointernal: Update dashmap and freeze its version
Lukas Wirth [Fri, 10 Jun 2022 13:59:46 +0000 (15:59 +0200)]
internal: Update dashmap and freeze its version

2 years agofeat: append :: after
yue4u [Thu, 9 Jun 2022 07:37:18 +0000 (16:37 +0900)]
feat: append :: after

2 years agoAuto merge of #12487 - lukechu10:master, r=lnicola
bors [Wed, 8 Jun 2022 14:55:17 +0000 (14:55 +0000)]
Auto merge of #12487 - lukechu10:master, r=lnicola

minor: hide param inlay hint when argument is fn-like macro with similar name

Closes #12486

2 years agoAuto merge of #12493 - bjorn3:fix_warnings, r=lnicola
bors [Wed, 8 Jun 2022 14:46:40 +0000 (14:46 +0000)]
Auto merge of #12493 - bjorn3:fix_warnings, r=lnicola

Fix a couple of weak warnings found by rust-analyzer itself

2 years agoHide param inlay hint when argument is fn-like macro with similar name
Luke Chu [Tue, 7 Jun 2022 23:29:25 +0000 (23:29 +0000)]
Hide param inlay hint when argument is fn-like macro with similar name

2 years agoFix a couple of weak warnings found by rust-analyzer itself
bjorn3 [Wed, 8 Jun 2022 14:35:11 +0000 (14:35 +0000)]
Fix a couple of weak warnings found by rust-analyzer itself

2 years agoAuto merge of #12492 - bjorn3:proc_macro_abi_1_63, r=lnicola
bors [Wed, 8 Jun 2022 14:34:40 +0000 (14:34 +0000)]
Auto merge of #12492 - bjorn3:proc_macro_abi_1_63, r=lnicola

feat: Add proc macro ABI for rustc 1.63

Fixes https://github.com/rust-lang/rust-analyzer/issues/12489

This bumps the MSRV to 1.61 due to usage of function pointers and `impl Trait` in const functions.

<details>

<summary>Diff from upstream proc_macro as of rust-lang/rust@e45d9973b2665897a768312e971b82cc62633103 (misses lib.rs as it got renamed to mod.rs)</summary>

```diff
diff -u --recursive ../rust/library/proc_macro/src/bridge/client.rs crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs
--- ../rust/library/proc_macro/src/bridge/client.rs     2022-06-08 13:14:57.763123238 +0000
+++ crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs 2022-06-08 13:33:23.378430287 +0000
`@@` -430,27 +430,27 `@@`
     buf
 }

-impl Client<crate::TokenStream, crate::TokenStream> {
-    pub const fn expand1(f: impl Fn(crate::TokenStream) -> crate::TokenStream + Copy) -> Self {
+impl Client<super::super::TokenStream, super::super::TokenStream> {
+    pub const fn expand1(f: impl Fn(super::super::TokenStream) -> super::super::TokenStream + Copy) -> Self {
         Client {
             get_handle_counters: HandleCounters::get,
             run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| {
-                run_client(bridge, |input| f(crate::TokenStream(input)).0)
+                run_client(bridge, |input| f(super::super::TokenStream(input)).0)
             }),
             _marker: PhantomData,
         }
     }
 }

-impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> {
+impl Client<(super::super::TokenStream, super::super::TokenStream), super::super::TokenStream> {
     pub const fn expand2(
-        f: impl Fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream + Copy,
+        f: impl Fn(super::super::TokenStream, super::super::TokenStream) -> super::super::TokenStream + Copy,
     ) -> Self {
         Client {
             get_handle_counters: HandleCounters::get,
             run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| {
                 run_client(bridge, |(input, input2)| {
-                    f(crate::TokenStream(input), crate::TokenStream(input2)).0
+                    f(super::super::TokenStream(input), super::super::TokenStream(input2)).0
                 })
             }),
             _marker: PhantomData,
`@@` -464,17 +464,17 `@@`
     CustomDerive {
         trait_name: &'static str,
         attributes: &'static [&'static str],
-        client: Client<crate::TokenStream, crate::TokenStream>,
+        client: Client<super::super::TokenStream, super::super::TokenStream>,
     },

     Attr {
         name: &'static str,
-        client: Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream>,
+        client: Client<(super::super::TokenStream, super::super::TokenStream), super::super::TokenStream>,
     },

     Bang {
         name: &'static str,
-        client: Client<crate::TokenStream, crate::TokenStream>,
+        client: Client<super::super::TokenStream, super::super::TokenStream>,
     },
 }

`@@` -490,21 +490,21 `@@`
     pub const fn custom_derive(
         trait_name: &'static str,
         attributes: &'static [&'static str],
-        expand: impl Fn(crate::TokenStream) -> crate::TokenStream + Copy,
+        expand: impl Fn(super::super::TokenStream) -> super::super::TokenStream + Copy,
     ) -> Self {
         ProcMacro::CustomDerive { trait_name, attributes, client: Client::expand1(expand) }
     }

     pub const fn attr(
         name: &'static str,
-        expand: impl Fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream + Copy,
+        expand: impl Fn(super::super::TokenStream, super::super::TokenStream) -> super::super::TokenStream + Copy,
     ) -> Self {
         ProcMacro::Attr { name, client: Client::expand2(expand) }
     }

     pub const fn bang(
         name: &'static str,
-        expand: impl Fn(crate::TokenStream) -> crate::TokenStream + Copy,
+        expand: impl Fn(super::super::TokenStream) -> super::super::TokenStream + Copy,
     ) -> Self {
         ProcMacro::Bang { name, client: Client::expand1(expand) }
     }
diff -u --recursive ../rust/library/proc_macro/src/bridge/mod.rs crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/mod.rs
--- ../rust/library/proc_macro/src/bridge/mod.rs        2022-06-08 13:14:57.763123238 +0000
+++ crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/mod.rs    2022-06-08 13:33:39.694243060 +0000
`@@` -8,7 +8,7 `@@`

 #![deny(unsafe_code)]

-use crate::{Delimiter, Level, LineColumn, Spacing};
+pub use super::{Delimiter, Level, LineColumn, Spacing};
 use std::fmt;
 use std::hash::Hash;
 use std::marker;
diff '--color=always' -u --recursive ../rust/library/proc_macro/src/bridge/server.rs crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/server.rs
--- ../rust/library/proc_macro/src/bridge/server.rs     2022-06-08 13:14:57.763123238 +0000
+++ crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/server.rs 2022-06-08 13:33:54.306075391 +0000
`@@` -274,7 +274,7 `@@`
     Result::decode(&mut &buf[..], &mut dispatcher.handle_store)
 }

-impl client::Client<crate::TokenStream, crate::TokenStream> {
+impl client::Client<super::super::TokenStream, super::super::TokenStream> {
     pub fn run<S: Server>(
         &self,
         strategy: &impl ExecutionStrategy,
`@@` -295,7 +295,7 `@@`
     }
 }

-impl client::Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> {
+impl client::Client<(super::super::TokenStream, super::super::TokenStream), super::super::TokenStream> {
     pub fn run<S: Server>(
         &self,
         strategy: &impl ExecutionStrategy,
diff -u --recursive ../rust/library/proc_macro/src/diagnostic.rs crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/diagnostic.rs
--- ../rust/library/proc_macro/src/diagnostic.rs        2022-05-11 10:07:59.099909725 +0000
+++ crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/diagnostic.rs    2022-06-08 13:35:01.169308145 +0000
`@@` -1,7 +1,6 `@@`
-use crate::Span;
+use super::Span;

 /// An enum representing a diagnostic level.
-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 #[derive(Copy, Clone, Debug)]
 #[non_exhaustive]
 pub enum Level {
`@@` -16,27 +15,23 `@@`
 }

 /// Trait implemented by types that can be converted into a set of `Span`s.
-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 pub trait MultiSpan {
     /// Converts `self` into a `Vec<Span>`.
     fn into_spans(self) -> Vec<Span>;
 }

-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 impl MultiSpan for Span {
     fn into_spans(self) -> Vec<Span> {
         vec![self]
     }
 }

-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 impl MultiSpan for Vec<Span> {
     fn into_spans(self) -> Vec<Span> {
         self
     }
 }

-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 impl<'a> MultiSpan for &'a [Span] {
     fn into_spans(self) -> Vec<Span> {
         self.to_vec()
`@@` -45,7 +40,6 `@@`

 /// A structure representing a diagnostic message and associated children
 /// messages.
-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 #[derive(Clone, Debug)]
 pub struct Diagnostic {
     level: Level,
`@@` -56,7 +50,6 `@@`

 macro_rules! diagnostic_child_methods {
     ($spanned:ident, $regular:ident, $level:expr) => {
-        #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
         #[doc = concat!("Adds a new child diagnostics message to `self` with the [`",
                         stringify!($level), "`] level, and the given `spans` and `message`.")]
         pub fn $spanned<S, T>(mut self, spans: S, message: T) -> Diagnostic
`@@` -68,7 +61,6 `@@`
             self
         }

-        #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
         #[doc = concat!("Adds a new child diagnostic message to `self` with the [`",
                         stringify!($level), "`] level, and the given `message`.")]
         pub fn $regular<T: Into<String>>(mut self, message: T) -> Diagnostic {
`@@` -80,10 +72,8 `@@`

 /// Iterator over the children diagnostics of a `Diagnostic`.
 #[derive(Debug, Clone)]
-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 pub struct Children<'a>(std::slice::Iter<'a, Diagnostic>);

-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 impl<'a> Iterator for Children<'a> {
     type Item = &'a Diagnostic;

`@@` -92,17 +82,14 `@@`
     }
 }

-#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 impl Diagnostic {
     /// Creates a new diagnostic with the given `level` and `message`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn new<T: Into<String>>(level: Level, message: T) -> Diagnostic {
         Diagnostic { level, message: message.into(), spans: vec![], children: vec![] }
     }

     /// Creates a new diagnostic with the given `level` and `message` pointing to
     /// the given set of `spans`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn spanned<S, T>(spans: S, level: Level, message: T) -> Diagnostic
     where
         S: MultiSpan,
`@@` -117,59 +104,51 `@@`
     diagnostic_child_methods!(span_help, help, Level::Help);

     /// Returns the diagnostic `level` for `self`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn level(&self) -> Level {
         self.level
     }

     /// Sets the level in `self` to `level`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn set_level(&mut self, level: Level) {
         self.level = level;
     }

     /// Returns the message in `self`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn message(&self) -> &str {
         &self.message
     }

     /// Sets the message in `self` to `message`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn set_message<T: Into<String>>(&mut self, message: T) {
         self.message = message.into();
     }

     /// Returns the `Span`s in `self`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn spans(&self) -> &[Span] {
         &self.spans
     }

     /// Sets the `Span`s in `self` to `spans`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn set_spans<S: MultiSpan>(&mut self, spans: S) {
         self.spans = spans.into_spans();
     }

     /// Returns an iterator over the children diagnostics of `self`.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn children(&self) -> Children<'_> {
         Children(self.children.iter())
     }

     /// Emit the diagnostic.
-    #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
     pub fn emit(self) {
-        fn to_internal(spans: Vec<Span>) -> crate::bridge::client::MultiSpan {
-            let mut multi_span = crate::bridge::client::MultiSpan::new();
+        fn to_internal(spans: Vec<Span>) -> super::bridge::client::MultiSpan {
+            let mut multi_span = super::bridge::client::MultiSpan::new();
             for span in spans {
                 multi_span.push(span.0);
             }
             multi_span
         }

-        let mut diag = crate::bridge::client::Diagnostic::new(
+        let mut diag = super::bridge::client::Diagnostic::new(
             self.level,
             &self.message[..],
             to_internal(self.spans),
Only in ../rust/library/proc_macro/src/: lib.rs
Only in crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/: mod.rs
diff -u --recursive ../rust/library/proc_macro/src/quote.rs crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/quote.rs
--- ../rust/library/proc_macro/src/quote.rs     2022-05-11 10:22:36.097429479 +0000
+++ crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/quote.rs 2022-06-08 13:35:08.737221303 +0000
`@@` -4,7 +4,7 `@@`
 //! This quasiquoter uses macros 2.0 hygiene to reliably access
 //! items from `proc_macro`, to build a `proc_macro::TokenStream`.

-use crate::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
+use super::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};

 macro_rules! quote_tt {
     (($($t:tt)*)) => { Group::new(Delimiter::Parenthesis, quote!($($t)*)) };
`@@` -59,10 +59,9 `@@`
 /// This is the actual implementation of the `quote!()` proc macro.
 ///
 /// It is loaded by the compiler in `register_builtin_macros`.
-#[unstable(feature = "proc_macro_quote", issue = "54722")]
 pub fn quote(stream: TokenStream) -> TokenStream {
     if stream.is_empty() {
-        return quote!(crate::TokenStream::new());
+        return quote!(super::TokenStream::new());
     }
     let proc_macro_crate = quote!(crate);
     let mut after_dollar = false;
`@@` -73,7 +72,7 `@@`
                 after_dollar = false;
                 match tree {
                     TokenTree::Ident(_) => {
-                        return Some(quote!(Into::<crate::TokenStream>::into(
+                        return Some(quote!(Into::<super::TokenStream>::into(
                         Clone::clone(&(@ tree))),));
                     }
                     TokenTree::Punct(ref tt) if tt.as_char() == '$' => {}
`@@` -86,33 +85,33 `@@`
                 }
             }

-            Some(quote!(crate::TokenStream::from((@ match tree {
-                TokenTree::Punct(tt) => quote!(crate::TokenTree::Punct(crate::Punct::new(
+            Some(quote!(super::TokenStream::from((@ match tree {
+                TokenTree::Punct(tt) => quote!(super::TokenTree::Punct(super::Punct::new(
                     (@ TokenTree::from(Literal::character(tt.as_char()))),
                     (@ match tt.spacing() {
-                        Spacing::Alone => quote!(crate::Spacing::Alone),
-                        Spacing::Joint => quote!(crate::Spacing::Joint),
+                        Spacing::Alone => quote!(super::Spacing::Alone),
+                        Spacing::Joint => quote!(super::Spacing::Joint),
                     }),
                 ))),
-                TokenTree::Group(tt) => quote!(crate::TokenTree::Group(crate::Group::new(
+                TokenTree::Group(tt) => quote!(super::TokenTree::Group(super::Group::new(
                     (@ match tt.delimiter() {
-                        Delimiter::Parenthesis => quote!(crate::Delimiter::Parenthesis),
-                        Delimiter::Brace => quote!(crate::Delimiter::Brace),
-                        Delimiter::Bracket => quote!(crate::Delimiter::Bracket),
-                        Delimiter::None => quote!(crate::Delimiter::None),
+                        Delimiter::Parenthesis => quote!(super::Delimiter::Parenthesis),
+                        Delimiter::Brace => quote!(super::Delimiter::Brace),
+                        Delimiter::Bracket => quote!(super::Delimiter::Bracket),
+                        Delimiter::None => quote!(super::Delimiter::None),
                     }),
                     (@ quote(tt.stream())),
                 ))),
-                TokenTree::Ident(tt) => quote!(crate::TokenTree::Ident(crate::Ident::new(
+                TokenTree::Ident(tt) => quote!(super::TokenTree::Ident(super::Ident::new(
                     (@ TokenTree::from(Literal::string(&tt.to_string()))),
                     (@ quote_span(proc_macro_crate.clone(), tt.span())),
                 ))),
-                TokenTree::Literal(tt) => quote!(crate::TokenTree::Literal({
+                TokenTree::Literal(tt) => quote!(super::TokenTree::Literal({
                     let mut iter = (@ TokenTree::from(Literal::string(&tt.to_string())))
-                        .parse::<crate::TokenStream>()
+                        .parse::<super::TokenStream>()
                         .unwrap()
                         .into_iter();
-                    if let (Some(crate::TokenTree::Literal(mut lit)), None) =
+                    if let (Some(super::TokenTree::Literal(mut lit)), None) =
                         (iter.next(), iter.next())
                     {
                         lit.set_span((@ quote_span(proc_macro_crate.clone(), tt.span())));
`@@` -129,12 +128,11 `@@`
         panic!("unexpected trailing `$` in `quote!`");
     }

-    quote!([(@ tokens)].iter().cloned().collect::<crate::TokenStream>())
+    quote!([(@ tokens)].iter().cloned().collect::<super::TokenStream>())
 }

 /// Quote a `Span` into a `TokenStream`.
 /// This is needed to implement a custom quoter.
-#[unstable(feature = "proc_macro_quote", issue = "54722")]
 pub fn quote_span(proc_macro_crate: TokenStream, span: Span) -> TokenStream {
     let id = span.save_span();
     quote!((@ proc_macro_crate ) ::Span::recover_proc_macro_span((@ TokenTree::from(Literal::usize_unsuffixed(id)))))
```

</details>

2 years agoAdd doc comment
bjorn3 [Wed, 8 Jun 2022 14:31:36 +0000 (14:31 +0000)]
Add doc comment

2 years agoRustfmt
bjorn3 [Wed, 8 Jun 2022 14:22:17 +0000 (14:22 +0000)]
Rustfmt

2 years agoAdd proc macro ABI for rustc 1.63
bjorn3 [Wed, 8 Jun 2022 13:41:10 +0000 (13:41 +0000)]
Add proc macro ABI for rustc 1.63

2 years agofix: show non-std enum in a fresh use tree completion
yue4u [Wed, 8 Jun 2022 11:53:42 +0000 (20:53 +0900)]
fix: show non-std enum in a fresh use tree completion

2 years agoAuto merge of #12480 - KOLANICH-tools:unneeded_destr_assignment, r=jonas-schievink
bors [Tue, 7 Jun 2022 10:46:56 +0000 (10:46 +0000)]
Auto merge of #12480 - KOLANICH-tools:unneeded_destr_assignment, r=jonas-schievink

Remove the unneeded destructuring assignment

in `run` in `project-model/src/build_scripts.rs`

2 years agoRemove the unneeded destructuring assignment in `run` in `project-model/src/build_scr...
KOLANICH [Mon, 6 Jun 2022 10:59:29 +0000 (13:59 +0300)]
Remove the unneeded destructuring assignment in `run` in `project-model/src/build_scripts.rs`

2 years agoAdd restartServerOnConfigChange setting
Hasan Ali [Mon, 6 Jun 2022 07:51:50 +0000 (08:51 +0100)]
Add restartServerOnConfigChange setting

2 years agoRestart server automatically on settings changes
Hasan Ali [Sun, 5 Jun 2022 20:36:42 +0000 (21:36 +0100)]
Restart server automatically on settings changes

2 years agoAuto merge of #12475 - Veykril:trait-impl-completion, r=Veykril
bors [Sun, 5 Jun 2022 18:29:59 +0000 (18:29 +0000)]
Auto merge of #12475 - Veykril:trait-impl-completion, r=Veykril

fix: Fix trait impl completions using wrong insert position

Fixes https://github.com/rust-lang/rust-analyzer/issues/12474

2 years agofix: Fix trait impl completions using wrong insert position
Lukas Wirth [Sun, 5 Jun 2022 18:29:36 +0000 (20:29 +0200)]
fix: Fix trait impl completions using wrong insert position

2 years agofix: avoid adding enum parens in use
yue4u [Sun, 5 Jun 2022 16:34:01 +0000 (01:34 +0900)]
fix: avoid adding enum parens in use

2 years agoAuto merge of #12472 - Veykril:output-ch, r=Veykril
bors [Sun, 5 Jun 2022 12:20:21 +0000 (12:20 +0000)]
Auto merge of #12472 - Veykril:output-ch, r=Veykril

internal: Keep output channels across restarts

cc https://github.com/rust-lang/rust-analyzer/pull/12470

2 years agointernal: Keep output channels across restarts
Lukas Wirth [Sun, 5 Jun 2022 11:59:49 +0000 (13:59 +0200)]
internal: Keep output channels across restarts

2 years agoAuto merge of #12471 - Veykril:reload-restart, r=Veykril
bors [Sun, 5 Jun 2022 11:35:09 +0000 (11:35 +0000)]
Auto merge of #12471 - Veykril:reload-restart, r=Veykril

fix: Restart the server instead of reloading the window when config changes

 cc https://github.com/rust-lang/rust-analyzer/issues/12469#event-6743447147

2 years agofix: Restart the server instead of reloading the window when config changes
Lukas Wirth [Sun, 5 Jun 2022 11:29:08 +0000 (13:29 +0200)]
fix: Restart the server instead of reloading the window when config changes

2 years agoAuto merge of #12470 - Veykril:output-ch, r=Veykril
bors [Sun, 5 Jun 2022 11:25:02 +0000 (11:25 +0000)]
Auto merge of #12470 - Veykril:output-ch, r=Veykril

fix: Cleanup output channels when restarting server

Fixes https://github.com/rust-lang/rust-analyzer/issues/12469

2 years agofix: Cleanup output channels when restarting server
Lukas Wirth [Sun, 5 Jun 2022 11:24:39 +0000 (13:24 +0200)]
fix: Cleanup output channels when restarting server

2 years agoAuto merge of #12466 - lnicola:worker-thread-stack, r=lnicola
bors [Sun, 5 Jun 2022 07:59:42 +0000 (07:59 +0000)]
Auto merge of #12466 - lnicola:worker-thread-stack, r=lnicola

Increase worker thread stack and name them

CC #11370

2 years agoAuto merge of #12468 - Veykril:cancelled-diags, r=Veykril
bors [Sat, 4 Jun 2022 23:40:05 +0000 (23:40 +0000)]
Auto merge of #12468 - Veykril:cancelled-diags, r=Veykril

minor: Don't log cancelled diagnostics

Since we retry requests now we can actually hit this legitimately

2 years agominor: Don't log cancelled diagnostics
Lukas Wirth [Sat, 4 Jun 2022 23:38:46 +0000 (01:38 +0200)]
minor: Don't log cancelled diagnostics

2 years agoAuto merge of #12467 - Veykril:assist-fix, r=Veykril
bors [Sat, 4 Jun 2022 23:02:50 +0000 (23:02 +0000)]
Auto merge of #12467 - Veykril:assist-fix, r=Veykril

fix: Fix match to if let assist for wildcard pats

2 years agofix: Fix match to if let assist for wildcard pats
Lukas Wirth [Sat, 4 Jun 2022 23:02:24 +0000 (01:02 +0200)]
fix: Fix match to if let assist for wildcard pats

2 years agoIncrease worker thread stack and name them
Laurențiu Nicola [Sat, 4 Jun 2022 17:48:51 +0000 (20:48 +0300)]
Increase worker thread stack and name them

2 years agoAuto merge of #12465 - Veykril:buildscripts, r=Veykril
bors [Sat, 4 Jun 2022 13:05:36 +0000 (13:05 +0000)]
Auto merge of #12465 - Veykril:buildscripts, r=Veykril

internal: Only record build script outputs when the output has been changed

Follow up to https://github.com/rust-lang/rust-analyzer/pull/12457

2 years agoOnly record build script outputs when the output has been changed
Lukas Wirth [Sat, 4 Jun 2022 13:04:56 +0000 (15:04 +0200)]
Only record build script outputs when the output has been changed

2 years agofeat: fix inline variable produce mismatched type
harpsword [Sat, 4 Jun 2022 09:07:24 +0000 (17:07 +0800)]
feat: fix inline variable produce mismatched type

wrap reference for RefExpr initializer

2 years agoAuto merge of #12461 - Veykril:completions, r=Veykril
bors [Fri, 3 Jun 2022 18:49:37 +0000 (18:49 +0000)]
Auto merge of #12461 - Veykril:completions, r=Veykril

Move trait_impl completion analysis into CompletionContext

2 years agoRemove some of the unnecessary helpfer functions from CompletionContext
Lukas Wirth [Fri, 3 Jun 2022 18:49:25 +0000 (20:49 +0200)]
Remove some of the unnecessary helpfer functions from CompletionContext

2 years agoSimplify
Lukas Wirth [Fri, 3 Jun 2022 17:51:08 +0000 (19:51 +0200)]
Simplify

2 years agoMove trait_impl completion analysis into CompletionContext
Lukas Wirth [Fri, 3 Jun 2022 17:48:55 +0000 (19:48 +0200)]
Move trait_impl completion analysis into CompletionContext

2 years agoAuto merge of #12459 - Veykril:completions, r=Veykril
bors [Fri, 3 Jun 2022 15:20:30 +0000 (15:20 +0000)]
Auto merge of #12459 - Veykril:completions, r=Veykril

internal: Clean up keyword completion handling

https://github.com/rust-lang/rust-analyzer/issues/12144

2 years agoAuto merge of #12457 - Veykril:logging, r=Veykril
bors [Fri, 3 Jun 2022 15:11:02 +0000 (15:11 +0000)]
Auto merge of #12457 - Veykril:logging, r=Veykril

internal: Don't log default build script outputs

2 years agoAuto merge of #12460 - Veykril:move-guard, r=Veykril
bors [Fri, 3 Jun 2022 15:00:26 +0000 (15:00 +0000)]
Auto merge of #12460 - Veykril:move-guard, r=Veykril

minor: Reduce move-guard trigger range

2 years agominor: Reduce move-guard trigger range
Lukas Wirth [Fri, 3 Jun 2022 15:00:03 +0000 (17:00 +0200)]
minor: Reduce move-guard trigger range

2 years agointernal: Don't log default build script outputs
Lukas Wirth [Fri, 3 Jun 2022 11:50:49 +0000 (13:50 +0200)]
internal: Don't log default build script outputs

2 years agoDeduplicate
Lukas Wirth [Fri, 3 Jun 2022 14:33:37 +0000 (16:33 +0200)]
Deduplicate

2 years agoRemove prev-sibling completion machinery
Lukas Wirth [Fri, 3 Jun 2022 14:25:37 +0000 (16:25 +0200)]
Remove prev-sibling completion machinery

2 years agoMore precise where keyword completions
Lukas Wirth [Fri, 3 Jun 2022 14:11:26 +0000 (16:11 +0200)]
More precise where keyword completions

2 years agoRemove dead code
Lukas Wirth [Fri, 3 Jun 2022 13:46:17 +0000 (15:46 +0200)]
Remove dead code

2 years agoFix visibility mods not being completed for field defs
Lukas Wirth [Fri, 3 Jun 2022 13:41:51 +0000 (15:41 +0200)]
Fix visibility mods not being completed for field defs

2 years agointernal: Move most remaining keyword completions to item list completions
Lukas Wirth [Fri, 3 Jun 2022 13:15:21 +0000 (15:15 +0200)]
internal: Move most remaining keyword completions to item list completions

2 years agoAuto merge of #12333 - nolanderc:order-import-assist, r=Veykril
bors [Fri, 3 Jun 2022 07:49:59 +0000 (07:49 +0000)]
Auto merge of #12333 - nolanderc:order-import-assist, r=Veykril

Order auto-imports by relevance

Fixes #10337.

Basically we sort the imports according to how "far away" the imported item is from where we want to import it to. This change makes it so that imports from the current crate are sorted before any third-party crates. Additionally, we make an exception for builtin crates (`std`, `core`, etc.) so that they are sorted before any third-party crates.

There are probably other heuristics that should be added to improve the experience (such as preferring imports that are common elsewhere in the same crate, and ranking crates depending on the dependency graph). However, I think this is a first good step.

PS. This is my first time contributing here, so please be gentle if I have missed something obvious :-)

2 years agoAuto merge of #12452 - iDawer:assist.merge_selected_imports, r=Veykril
bors [Fri, 3 Jun 2022 07:40:34 +0000 (07:40 +0000)]
Auto merge of #12452 - iDawer:assist.merge_selected_imports, r=Veykril

feature: `Merge imports` assist can merge multiple selected imports.

The selected imports have to have a common prefix in paths.

Select imports or use trees to merge:
```rust
$0use std::fmt::Display;
use std::fmt::Debug;
use std::fmt::Write;$0
```
Apply `Merge imports`:
```rust
use std::fmt::{Display, Debug, Write};
```

Closes #12426

2 years agoAuto merge of #12451 - TimNN:double-dollar, r=Veykril
bors [Fri, 3 Jun 2022 07:23:48 +0000 (07:23 +0000)]
Auto merge of #12451 - TimNN:double-dollar, r=Veykril

feat: Support `$$` in macros.

The implementation mirrors what `rustc` currently does [1]. Part of #11952.

\[1]: https://github.com/rust-lang/rust/blob/0595ea1d12cf745e0a672d05341429ecb0917e66/compiler/rustc_expand/src/mbe/quoted.rs#L230-L241

2 years agoAuto merge of #12456 - lnicola:thread-names, r=lnicola
bors [Fri, 3 Jun 2022 04:28:07 +0000 (04:28 +0000)]
Auto merge of #12456 - lnicola:thread-names, r=lnicola

internal: Shorten main thread names

Linux effectively has a 15 byte limit, which resulted in `rust-analyzer s` and `rust-analyzer p`. That's still unambiguous, but probably not obvious.

2 years agoShorten main thread name
Laurențiu Nicola [Fri, 3 Jun 2022 04:13:02 +0000 (07:13 +0300)]
Shorten main thread name

2 years agofix: #12441 False-positive type-mismatch error with generic future
bitgaoshu [Fri, 3 Jun 2022 02:28:01 +0000 (10:28 +0800)]
fix: #12441 False-positive type-mismatch error with generic future

2 years agofeat: Support `$$` in macros.
Tim Neumann [Thu, 2 Jun 2022 19:36:11 +0000 (21:36 +0200)]
feat: Support `$$` in macros.

The implementation mirrors what `rustc` currently does [1]. Part of #11952.

[1]: https://github.com/rust-lang/rust/blob/0595ea1d12cf745e0a672d05341429ecb0917e66/compiler/rustc_expand/src/mbe/quoted.rs#L230-L241

2 years agoAllow merging of multiple selected imports.
iDawer [Thu, 2 Jun 2022 18:15:55 +0000 (23:15 +0500)]
Allow merging of multiple selected imports.

The selected imports have to have a common prefix in paths.

Before
```rust
$0use std::fmt::Display;
use std::fmt::Debug;$0
```
After
```rust
use std::fmt::{Display, Debug};
```

2 years agoBring the version command output in line with other rust tools
Lukas Wirth [Thu, 2 Jun 2022 16:14:38 +0000 (18:14 +0200)]
Bring the version command output in line with other rust tools

2 years agoAuto merge of #12444 - XFFXFF:fix_12442, r=Veykril
bors [Thu, 2 Jun 2022 14:02:36 +0000 (14:02 +0000)]
Auto merge of #12444 - XFFXFF:fix_12442, r=Veykril

fix: parsing of `?` opt-out trait bounds

fixes #12442

2 years agofix: parsing of `?` opt-out trait bounds
XFFXFF [Thu, 2 Jun 2022 13:30:18 +0000 (21:30 +0800)]
fix: parsing of `?` opt-out trait bounds

thanks to Veykril

2 years agoAuto merge of #12347 - feniljain:fix_extract_module, r=Veykril
bors [Thu, 2 Jun 2022 12:37:17 +0000 (12:37 +0000)]
Auto merge of #12347 - feniljain:fix_extract_module, r=Veykril

fix(extract_module) resolving import panics and improve import resolution

- Should solve #11766
- While adding a test case for this issue, I observed another issue:
For this test case:
```rust
            mod x {
                pub struct Foo;
                pub struct Bar;
            }

            use x::{Bar, Foo};

            $0type A = (Foo, Bar);$0
```
extract module should yield this:

```rust
            mod x {
                pub struct Foo;
                pub struct Bar;
            }

            use x::{};

            mod modname {
                use super::x::Bar;

                use super::x::Foo;

                pub(crate) type A = (Foo, Bar);
            }
```

instead it gave:

```rust
            mod x {
                pub struct Foo;
                pub struct Bar;
            }

            use x::{};

            mod modname {
                use x::Bar;

                use x::Foo;

                pub(crate) type A = (Foo, Bar);
            }
```

So fixed this problem with second commit

2 years agoAuto merge of #12443 - Veykril:fmtfix, r=Veykril
bors [Wed, 1 Jun 2022 19:23:22 +0000 (19:23 +0000)]
Auto merge of #12443 - Veykril:fmtfix, r=Veykril

minor: Fix rustfmt failing on main_loop.rs

2 years agominor: Fix rustfmt failing on main_loop.rs
Lukas Wirth [Wed, 1 Jun 2022 19:20:54 +0000 (21:20 +0200)]
minor: Fix rustfmt failing on main_loop.rs

2 years agoAuto merge of #12440 - Maan2003:empty-msg-diag, r=jonas-schievink
bors [Wed, 1 Jun 2022 14:31:14 +0000 (14:31 +0000)]
Auto merge of #12440 - Maan2003:empty-msg-diag, r=jonas-schievink

fix(diagnostic): Don't remove diagnostic with empty message

Use " " as message if it is empty

[discussion on zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/empty.20diagnostic.20message)

![image](https://user-images.githubusercontent.com/49202620/171412661-9b9575e9-e71b-4b84-a5c0-00271548d50c.png)

2 years agofix(diagnostic): Don't remove diagnostic with empty message
Maan2003 [Wed, 1 Jun 2022 13:08:53 +0000 (18:38 +0530)]
fix(diagnostic): Don't remove diagnostic with empty message

Use " " as message if it is empty

2 years agoAuto merge of #12431 - Veykril:request-retry, r=Veykril
bors [Wed, 1 Jun 2022 10:18:50 +0000 (10:18 +0000)]
Auto merge of #12431 - Veykril:request-retry, r=Veykril

fix: Fix completions disappearing when typing two keys in quick succession

With this PR we now retry requests if they get cancelled due to document changes.

This fixes the completions problem we have where completions seem to randomly disappear, see https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Completions.20not.20always.20appearing

Fixes https://github.com/rust-lang/rust-analyzer/issues/10187
Fixes https://github.com/rust-lang/rust-analyzer/issues/7560
Fixes https://github.com/rust-lang/rust-analyzer/issues/12153

2 years agoSync handlers cannot be cancelled
Lukas Wirth [Wed, 1 Jun 2022 10:17:49 +0000 (12:17 +0200)]
Sync handlers cannot be cancelled

2 years agoAuto merge of #12435 - jhgg:vscode/status-bar-color-fix, r=Veykril
bors [Wed, 1 Jun 2022 07:19:42 +0000 (07:19 +0000)]
Auto merge of #12435 - jhgg:vscode/status-bar-color-fix, r=Veykril

[editors/vscode] cleaer status bar bg color / command  when server status returns to OK

fixes #12433

2 years ago[editors/vscode] cleaer status bar bg color / command when server status returns...
Jake Heinz [Wed, 1 Jun 2022 06:58:16 +0000 (06:58 +0000)]
[editors/vscode] cleaer status bar bg color / command  when server status returns to OK

2 years agofix: Fix completions disappearing when typing two keys in quick succession
Lukas Wirth [Tue, 31 May 2022 22:20:28 +0000 (00:20 +0200)]
fix: Fix completions disappearing when typing two keys in quick succession

2 years agoAuto merge of #12430 - Veykril:completions, r=Veykril
bors [Tue, 31 May 2022 18:22:41 +0000 (18:22 +0000)]
Auto merge of #12430 - Veykril:completions, r=Veykril

minor: Remove unused code

2 years agominor: Remove unused code
Lukas Wirth [Tue, 31 May 2022 18:21:50 +0000 (20:21 +0200)]
minor: Remove unused code