Repository: rust-analyzer/rust-analyzer (rust)

Issue:
Info/Hint Settings swapped 
<!--
Troubleshooting guide: https://rust-analyzer.github.io/manual.html#troubleshooting
Forum for questions: https://users.rust-lang.org/c/ide/14

Before submitting, please make sure that you're not running into one of these known issues:
-->
![image](https://user-images.githubusercontent.com/56208328/114429965-329a5a00-9bbe-11eb-867d-4a04ff6e5207.png)

If i register dead_code under the Setting "Warning as Info", that claims to "display warning with HINT severity" and to simply fade the text color, it underlines them with blue squiggly lines

If i register dead_code under the Setting "Warning as Hint", that claims to "displayed warnings with INFO severity" and to underline text with blue squiggly lines, it fades the text color

So basically the Settings have contradictary descriptions and swapped.
This is kinda confusing, that's all, the actual functionality seems to be working

(v0.2.554, VsCode Windows 64bit)

Pull request description:
Fix incorrect setting descriptions
Descriptions for diagnostic warning hint and info display were swapped.

Fixes #8485.

Patch:
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index 0b310ba2fc..94d7aecb6f 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -8,6 +8,7 @@ use base_db::{AnchoredPath, Edition, FileId};
 use cfg::CfgExpr;
 use either::Either;
 use mbe::{parse_exprs_with_sep, parse_to_token_tree, ExpandResult};
+use parser::FragmentKind;
 use syntax::ast::{self, AstToken};
 
 macro_rules! register_builtin {
@@ -46,7 +47,7 @@ macro_rules! register_builtin {
                 let expander = match *self {
                     $( EagerExpander::$e_kind => $e_expand, )*
                 };
-                expander(db, arg_id, tt)
+                expander(db,arg_id,tt)
             }
         }
 
@@ -63,13 +64,14 @@ macro_rules! register_builtin {
 #[derive(Debug)]
 pub struct ExpandedEager {
     pub(crate) subtree: tt::Subtree,
+    pub(crate) fragment: FragmentKind,
     /// The included file ID of the include macro.
     pub(crate) included_file: Option<FileId>,
 }
 
 impl ExpandedEager {
-    fn new(subtree: tt::Subtree) -> Self {
-        ExpandedEager { subtree, included_file: None }
+    fn new(subtree: tt::Subtree, fragment: FragmentKind) -> Self {
+        ExpandedEager { subtree, fragment, included_file: None }
     }
 }
 
@@ -338,7 +340,7 @@ fn compile_error_expand(
         _ => mbe::ExpandError::BindingError("`compile_error!` argument must be a string".into()),
     };
 
-    ExpandResult { value: Some(ExpandedEager::new(quote! {})), err: Some(err) }
+    ExpandResult { value: Some(ExpandedEager::new(quote! {}, FragmentKind::Items)), err: Some(err) }
 }
 
 fn concat_expand(
@@ -369,7 +371,7 @@ fn concat_expand(
             }
         }
     }
-    ExpandResult { value: Some(ExpandedEager::new(quote!(#text))), err }
+    ExpandResult { value: Some(ExpandedEager::new(quote!(#text), FragmentKind::Expr)), err }
 }
 
 fn concat_idents_expand(
@@ -391,7 +393,7 @@ fn concat_idents_expand(
         }
     }
     let ident = tt::Ident { text: ident.into(), id: tt::TokenId::unspecified() };
-    ExpandResult { value: Some(ExpandedEager::new(quote!(#ident))), err }
+    ExpandResult { value: Some(ExpandedEager::new(quote!(#ident), FragmentKind::Expr)), err }
 }
 
 fn relative_file(
@@ -440,7 +442,14 @@ fn include_expand(
 
     match res {
         Ok((subtree, file_id)) => {
-            ExpandResult::ok(Some(ExpandedEager { subtree, included_file: Some(file_id) }))
+            // FIXME:
+            // Handle include as expression
+
+            ExpandResult::ok(Some(ExpandedEager {
+                subtree,
+                fragment: FragmentKind::Items,
+                included_file: Some(file_id),
+            }))
         }
         Err(e) => ExpandResult::only_err(e),
     }
@@ -463,7 +472,7 @@ fn include_bytes_expand(
             id: tt::TokenId::unspecified(),
         }))],
     };
-    ExpandResult::ok(Some(ExpandedEager::new(res)))
+    ExpandResult::ok(Some(ExpandedEager::new(res, FragmentKind::Expr)))
 }
 
 fn include_str_expand(
@@ -483,14 +492,14 @@ fn include_str_expand(
     let file_id = match relative_file(db, arg_id.into(), &path, true) {
         Ok(file_id) => file_id,
         Err(_) => {
-            return ExpandResult::ok(Some(ExpandedEager::new(quote!(""))));
+            return ExpandResult::ok(Some(ExpandedEager::new(quote!(""), FragmentKind::Expr)));
         }
     };
 
     let text = db.file_text(file_id);
     let text = &*text;
 
-    ExpandResult::ok(Some(ExpandedEager::new(quote!(#text))))
+    ExpandResult::ok(Some(ExpandedEager::new(quote!(#text), FragmentKind::Expr)))
 }
 
 fn get_env_inner(db: &dyn AstDatabase, arg_id: MacroCallId, key: &str) -> Option<String> {
@@ -526,7 +535,7 @@ fn env_expand(
     });
     let expanded = quote! { #s };
 
-    ExpandResult { value: Some(ExpandedEager::new(expanded)), err }
+    ExpandResult { value: Some(ExpandedEager::new(expanded, FragmentKind::Expr)), err }
 }
 
 fn option_env_expand(
@@ -544,7 +553,7 @@ fn option_env_expand(
         Some(s) => quote! { std::option::Some(#s) },
     };
 
-    ExpandResult::ok(Some(ExpandedEager::new(expanded)))
+    ExpandResult::ok(Some(ExpandedEager::new(expanded, FragmentKind::Expr)))
 }
 
 #[cfg(test)]
@@ -556,7 +565,6 @@ mod tests {
     };
     use base_db::{fixture::WithFixture, SourceDatabase};
     use expect_test::{expect, Expect};
-    use parser::FragmentKind;
     use std::sync::Arc;
     use syntax::ast::NameOwner;
 
@@ -609,7 +617,6 @@ mod tests {
                     local_inner: false,
                 };
 
-                let fragment = crate::to_fragment_kind(&macro_call);
                 let args = macro_call.token_tree().unwrap();
                 let parsed_args = mbe::ast_to_token_tree(&args).0;
                 let call_id = AstId::new(file_id.into(), ast_id_map.ast_id(&macro_call));
@@ -632,7 +639,7 @@ mod tests {
                         arg_or_expansion: Arc::new(expanded.subtree),
                         included_file: expanded.included_file,
                     }),
-                    kind: MacroCallKind::FnLike { ast_id: call_id, fragment },
+                    kind: MacroCallKind::FnLike { ast_id: call_id, fragment: expanded.fragment },
                 };
 
                 let id: MacroCallId = db.intern_macro(loc).into();
diff --git a/crates/hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs
index 14af628a1f..1464320ba2 100644
--- a/crates/hir_expand/src/eager.rs
+++ b/crates/hir_expand/src/eager.rs
@@ -113,7 +113,6 @@ pub fn expand_eager_macro(
 
     let ast_map = db.ast_id_map(macro_call.file_id);
     let call_id = InFile::new(macro_call.file_id, ast_map.ast_id(&macro_call.value));
-    let fragment = crate::to_fragment_kind(&macro_call.value);
 
     // Note:
     // When `lazy_expand` is called, its *parent* file must be already exists.
@@ -153,7 +152,7 @@ pub fn expand_eager_macro(
                 arg_or_expansion: Arc::new(expanded.subtree),
                 included_file: expanded.included_file,
             }),
-            kind: MacroCallKind::FnLike { ast_id: call_id, fragment },
+            kind: MacroCallKind::FnLike { ast_id: call_id, fragment: expanded.fragment },
         };
 
         Ok(db.intern_macro(loc))
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index 13d5b90c99..610fec65a7 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -3,6 +3,8 @@
 //! This module uses a bit of static metadata to provide completions
 //! for built-in attributes.
 
+use std::mem;
+
 use once_cell::sync::Lazy;
 use rustc_hash::{FxHashMap, FxHashSet};
 use syntax::{ast, AstNode, NodeOrToken, SyntaxKind, T};
@@ -270,27 +272,27 @@ const ATTRIBUTES: &[AttrCompletion] = &[
 fn parse_comma_sep_input(derive_input: ast::TokenTree) -> Option<FxHashSet<String>> {
     let (l_paren, r_paren) = derive_input.l_paren_token().zip(derive_input.r_paren_token())?;
     let mut input_derives = FxHashSet::default();
-    let mut tokens = derive_input
+    let mut current_derive = String::new();
+    for token in derive_input
         .syntax()
         .children_with_tokens()
         .filter_map(NodeOrToken::into_token)
         .skip_while(|token| token != &l_paren)
         .skip(1)
         .take_while(|token| token != &r_paren)
-        .peekable();
-    let mut input = String::new();
-    while tokens.peek().is_some() {
-        for token in tokens.by_ref().take_while(|t| t.kind() != T![,]) {
-            input.push_str(token.text());
-        }
-
-        if !input.is_empty() {
-            input_derives.insert(input.trim().to_owned());
+    {
+        if token.kind() == T![,] {
+            if !current_derive.is_empty() {
+                input_derives.insert(mem::take(&mut current_derive));
+            }
+        } else {
+            current_derive.push_str(token.text().trim());
         }
-
-        input.clear();
     }
 
+    if !current_derive.is_empty() {
+        input_derives.insert(current_derive);
+    }
     Some(input_derives)
 }
 
diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs
index 634c0cb00d..7b0a778a22 100644
--- a/crates/ide_completion/src/completions/attribute/derive.rs
+++ b/crates/ide_completion/src/completions/attribute/derive.rs
@@ -45,7 +45,6 @@ pub(super) fn complete_derive(
         }
     }
 }
-
 fn get_derive_names_in_scope(ctx: &CompletionContext) -> FxHashSet<String> {
     let mut result = FxHashSet::default();
     ctx.scope.process_all_names(&mut |name, scope_def| {
@@ -90,14 +89,12 @@ mod tests {
     }
 
     #[test]
-    fn no_completion_for_incorrect_derive() {
-        check(r#"#[derive{$0)] struct Test;"#, expect![[]])
-    }
-
-    #[test]
-    fn empty_derive() {
+    fn empty_derive_completion() {
         check(
-            r#"#[derive($0)] struct Test;"#,
+            r#"
+#[derive($0)]
+struct Test {}
+        "#,
             expect![[r#"
                 at Clone
                 at Clone, Copy
@@ -113,26 +110,23 @@ mod tests {
     }
 
     #[test]
-    fn derive_with_input() {
+    fn no_completion_for_incorrect_derive() {
         check(
-            r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#,
-            expect![[r#"
-                at Clone
-                at Clone, Copy
-                at Debug
-                at Default
-                at Hash
-                at Eq
-                at PartialOrd
-                at Eq, PartialOrd, Ord
-            "#]],
+            r#"
+#[derive{$0)]
+struct Test {}
+"#,
+            expect![[r#""#]],
         )
     }
 
     #[test]
-    fn derive_with_input2() {
+    fn derive_with_input_completion() {
         check(
-            r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#,
+            r#"
+#[derive(serde::Serialize, PartialEq, $0)]
+struct Test {}
+"#,
             expect![[r#"
                 at Clone
                 at Clone, Copy
diff --git a/crates/ide_completion/src/completions/attribute/lint.rs b/crates/ide_completion/src/completions/attribute/lint.rs
index 403630dce4..115c6cfe0c 100644
--- a/crates/ide_completion/src/completions/attribute/lint.rs
+++ b/crates/ide_completion/src/completions/attribute/lint.rs
@@ -152,36 +152,3 @@ pub(super) const DEFAULT_LINT_COMPLETIONS: &[LintCompletion] = &[
     LintCompletion { label: "unconditional_panic", description: r#"operation will cause a panic at runtime"# },
     LintCompletion { label: "unknown_crate_types", description: r#"unknown crate type found in `#[crate_type]` directive"# },
 ];
-
-#[cfg(test)]
-mod tests {
-
-    use crate::test_utils::check_edit;
-
-    #[test]
-    fn check_empty() {
-        check_edit(
-            "deprecated",
-            r#"#[allow($0)] struct Test;"#,
-            r#"#[allow(deprecated)] struct Test;"#,
-        )
-    }
-
-    #[test]
-    fn check_with_existing() {
-        check_edit(
-            "deprecated",
-            r#"#[allow(keyword_idents, $0)] struct Test;"#,
-            r#"#[allow(keyword_idents, deprecated)] struct Test;"#,
-        )
-    }
-
-    #[test]
-    fn check_qualified() {
-        check_edit(
-            "deprecated",
-            r#"#[allow(keyword_idents, $0)] struct Test;"#,
-            r#"#[allow(keyword_idents, deprecated)] struct Test;"#,
-        )
-    }
-}
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index b6a1124a54..a67b0bb257 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -111,15 +111,15 @@ config_data! {
         /// Map of prefixes to be substituted when parsing diagnostic file paths.
         /// This should be the reverse mapping of what is passed to `rustc` as `--remap-path-prefix`.
         diagnostics_remapPrefix: FxHashMap<String, String> = "{}",
-        /// List of warnings that should be displayed with info severity.
-        ///
-        /// The warnings will be indicated by a blue squiggly underline in code
-        /// and a blue icon in the `Problems Panel`.
-        diagnostics_warningsAsHint: Vec<String> = "[]",
         /// List of warnings that should be displayed with hint severity.
         ///
         /// The warnings will be indicated by faded text or three dots in code
         /// and will not show up in the `Problems Panel`.
+        diagnostics_warningsAsHint: Vec<String> = "[]",
+        /// List of warnings that should be displayed with info severity.
+        ///
+        /// The warnings will be indicated by a blue squiggly underline in code
+        /// and a blue icon in the `Problems Panel`.
         diagnostics_warningsAsInfo: Vec<String> = "[]",
 
         /// Controls file watching implementation.
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index f3da82febb..4a5782a57e 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -161,18 +161,18 @@ This should be the reverse mapping of what is passed to `rustc` as `--remap-path
 [[rust-analyzer.diagnostics.warningsAsHint]]rust-analyzer.diagnostics.warningsAsHint (default: `[]`)::
 +
 --
-List of warnings that should be displayed with info severity.
+List of warnings that should be displayed with hint severity.
 
-The warnings will be indicated by a blue squiggly underline in code
-and a blue icon in the `Problems Panel`.
+The warnings will be indicated by faded text or three dots in code
+and will not show up in the `Problems Panel`.
 --
 [[rust-analyzer.diagnostics.warningsAsInfo]]rust-analyzer.diagnostics.warningsAsInfo (default: `[]`)::
 +
 --
-List of warnings that should be displayed with hint severity.
+List of warnings that should be displayed with info severity.
 
-The warnings will be indicated by faded text or three dots in code
-and will not show up in the `Problems Panel`.
+The warnings will be indicated by a blue squiggly underline in code
+and a blue icon in the `Problems Panel`.
 --
 [[rust-analyzer.files.watcher]]rust-analyzer.files.watcher (default: `"client"`)::
 +
diff --git a/editors/code/package.json b/editors/code/package.json
index 05cbccf946..5b80cc1f9d 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -597,7 +597,7 @@
                     "type": "object"
                 },
                 "rust-analyzer.diagnostics.warningsAsHint": {
-                    "markdownDescription": "List of warnings that should be displayed with info severity.\n\nThe warnings will be indicated by a blue squiggly underline in code\nand a blue icon in the `Problems Panel`.",
+                    "markdownDescription": "List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code\nand will not show up in the `Problems Panel`.",
                     "default": [],
                     "type": "array",
                     "items": {
@@ -605,7 +605,7 @@
                     }
                 },
                 "rust-analyzer.diagnostics.warningsAsInfo": {
-                    "markdownDescription": "List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code\nand will not show up in the `Problems Panel`.",
+                    "markdownDescription": "List of warnings that should be displayed with info severity.\n\nThe warnings will be indicated by a blue squiggly underline in code\nand a blue icon in the `Problems Panel`.",
                     "default": [],
                     "type": "array",
                     "items": {


Test patch:
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs
index 7647bb08b7..6588aa46c1 100644
--- a/crates/hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
@@ -751,24 +751,6 @@ fn bar() -> u32 {0}
     );
 }
 
-#[test]
-fn infer_builtin_macros_include_expression() {
-    check_types(
-        r#"
-//- /main.rs
-#[rustc_builtin_macro]
-macro_rules! include {() => {}}
-fn main() {
-    let i = include!("bla.rs");
-    i;
-  //^ i32
-}
-//- /bla.rs
-0
-        "#,
-    )
-}
-
 #[test]
 fn infer_builtin_macros_include_child_mod() {
     check_types(