4758: Actually test include!(concant!(env!())); r=matklad a=matklad

It triggered index-based goto definition before :-(



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-06-05 13:51:35 +00:00 committed by GitHub
commit 9c52f527a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,9 +4,7 @@ use std::{collections::HashMap, path::PathBuf, time::Instant};
use lsp_types::{ use lsp_types::{
notification::DidOpenTextDocument, notification::DidOpenTextDocument,
request::{ request::{CodeActionRequest, Completion, Formatting, GotoTypeDefinition, HoverRequest},
CodeActionRequest, Completion, Formatting, GotoDefinition, GotoTypeDefinition, HoverRequest,
},
CodeActionContext, CodeActionParams, CompletionParams, DidOpenTextDocumentParams, CodeActionContext, CodeActionParams, CompletionParams, DidOpenTextDocumentParams,
DocumentFormattingParams, FormattingOptions, GotoDefinitionParams, HoverParams, DocumentFormattingParams, FormattingOptions, GotoDefinitionParams, HoverParams,
PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams, PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams,
@ -507,6 +505,10 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
} }
//- src/main.rs //- src/main.rs
#[rustc_builtin_macro] macro_rules! include {}
#[rustc_builtin_macro] macro_rules! concat {}
#[rustc_builtin_macro] macro_rules! env {}
include!(concat!(env!("OUT_DIR"), "/hello.rs")); include!(concat!(env!("OUT_DIR"), "/hello.rs"));
#[cfg(atom_cfg)] #[cfg(atom_cfg)]
@ -521,7 +523,7 @@ struct B;
fn main() { fn main() {
let va = A; let va = A;
let vb = B; let vb = B;
message(); let should_be_str = message();
} }
"###, "###,
) )
@ -530,36 +532,35 @@ fn main() {
}) })
.server(); .server();
server.wait_until_workspace_is_loaded(); server.wait_until_workspace_is_loaded();
let res = server.send_request::<GotoDefinition>(GotoDefinitionParams { let res = server.send_request::<HoverRequest>(HoverParams {
text_document_position_params: TextDocumentPositionParams::new( text_document_position_params: TextDocumentPositionParams::new(
server.doc_id("src/main.rs"), server.doc_id("src/main.rs"),
Position::new(14, 8), Position::new(18, 10),
), ),
work_done_progress_params: Default::default(), work_done_progress_params: Default::default(),
partial_result_params: Default::default(),
}); });
assert!(format!("{}", res).contains("hello.rs")); assert!(res.to_string().contains("&str"));
server.request::<GotoTypeDefinition>( server.request::<GotoTypeDefinition>(
GotoDefinitionParams { GotoDefinitionParams {
text_document_position_params: TextDocumentPositionParams::new( text_document_position_params: TextDocumentPositionParams::new(
server.doc_id("src/main.rs"), server.doc_id("src/main.rs"),
Position::new(12, 9), Position::new(16, 9),
), ),
work_done_progress_params: Default::default(), work_done_progress_params: Default::default(),
partial_result_params: Default::default(), partial_result_params: Default::default(),
}, },
json!([{ json!([{
"originSelectionRange": { "originSelectionRange": {
"end": { "character": 10, "line": 12 }, "end": { "character": 10, "line": 16 },
"start": { "character": 8, "line": 12 } "start": { "character": 8, "line": 16 }
}, },
"targetRange": { "targetRange": {
"end": { "character": 9, "line": 3 }, "end": { "character": 9, "line": 7 },
"start": { "character": 0, "line": 2 } "start": { "character": 0, "line": 6 }
}, },
"targetSelectionRange": { "targetSelectionRange": {
"end": { "character": 8, "line": 3 }, "end": { "character": 8, "line": 7 },
"start": { "character": 7, "line": 3 } "start": { "character": 7, "line": 7 }
}, },
"targetUri": "file:///[..]src/main.rs" "targetUri": "file:///[..]src/main.rs"
}]), }]),
@ -568,23 +569,23 @@ fn main() {
GotoDefinitionParams { GotoDefinitionParams {
text_document_position_params: TextDocumentPositionParams::new( text_document_position_params: TextDocumentPositionParams::new(
server.doc_id("src/main.rs"), server.doc_id("src/main.rs"),
Position::new(13, 9), Position::new(17, 9),
), ),
work_done_progress_params: Default::default(), work_done_progress_params: Default::default(),
partial_result_params: Default::default(), partial_result_params: Default::default(),
}, },
json!([{ json!([{
"originSelectionRange": { "originSelectionRange": {
"end": { "character": 10, "line": 13 }, "end": { "character": 10, "line": 17 },
"start": { "character": 8, "line":13 } "start": { "character": 8, "line": 17 }
}, },
"targetRange": { "targetRange": {
"end": { "character": 9, "line": 7 }, "end": { "character": 9, "line": 11 },
"start": { "character": 0, "line":6 } "start": { "character": 0, "line":10 }
}, },
"targetSelectionRange": { "targetSelectionRange": {
"end": { "character": 8, "line": 7 }, "end": { "character": 8, "line": 11 },
"start": { "character": 7, "line": 7 } "start": { "character": 7, "line": 11 }
}, },
"targetUri": "file:///[..]src/main.rs" "targetUri": "file:///[..]src/main.rs"
}]), }]),