aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock4
-rw-r--r--crates/rust-analyzer/src/main_loop.rs42
-rw-r--r--xtask/src/lib.rs2
-rw-r--r--xtask/src/not_bash.rs5
-rw-r--r--xtask/tests/tidy.rs41
5 files changed, 69 insertions, 25 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c16cf4bc8..11eb9a823 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -712,9 +712,9 @@ dependencies = [
712 712
713[[package]] 713[[package]]
714name = "lsp-types" 714name = "lsp-types"
715version = "0.76.0" 715version = "0.76.1"
716source = "registry+https://github.com/rust-lang/crates.io-index" 716source = "registry+https://github.com/rust-lang/crates.io-index"
717checksum = "af5586f0631c7f7826c3ea39377c326d7b4623138be7ab1204dab22e47717449" 717checksum = "55cfa1593e04985972e018890b2e1a9ed25c71efc800067fbf0990a9432421c8"
718dependencies = [ 718dependencies = [
719 "base64", 719 "base64",
720 "bitflags", 720 "bitflags",
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 702f25a19..5afcc2d87 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -122,29 +122,33 @@ impl GlobalState {
122 ); 122 );
123 }; 123 };
124 124
125 let registration_options = lsp_types::TextDocumentRegistrationOptions { 125 let save_registration_options = lsp_types::TextDocumentSaveRegistrationOptions {
126 document_selector: Some(vec![ 126 include_text: Some(false),
127 lsp_types::DocumentFilter { 127 text_document_registration_options: lsp_types::TextDocumentRegistrationOptions {
128 language: None, 128 document_selector: Some(vec![
129 scheme: None, 129 lsp_types::DocumentFilter {
130 pattern: Some("**/*.rs".into()), 130 language: None,
131 }, 131 scheme: None,
132 lsp_types::DocumentFilter { 132 pattern: Some("**/*.rs".into()),
133 language: None, 133 },
134 scheme: None, 134 lsp_types::DocumentFilter {
135 pattern: Some("**/Cargo.toml".into()), 135 language: None,
136 }, 136 scheme: None,
137 lsp_types::DocumentFilter { 137 pattern: Some("**/Cargo.toml".into()),
138 language: None, 138 },
139 scheme: None, 139 lsp_types::DocumentFilter {
140 pattern: Some("**/Cargo.lock".into()), 140 language: None,
141 }, 141 scheme: None,
142 ]), 142 pattern: Some("**/Cargo.lock".into()),
143 },
144 ]),
145 },
143 }; 146 };
147
144 let registration = lsp_types::Registration { 148 let registration = lsp_types::Registration {
145 id: "textDocument/didSave".to_string(), 149 id: "textDocument/didSave".to_string(),
146 method: "textDocument/didSave".to_string(), 150 method: "textDocument/didSave".to_string(),
147 register_options: Some(serde_json::to_value(registration_options).unwrap()), 151 register_options: Some(serde_json::to_value(save_registration_options).unwrap()),
148 }; 152 };
149 self.send_request::<lsp_types::request::RegisterCapability>( 153 self.send_request::<lsp_types::request::RegisterCapability>(
150 lsp_types::RegistrationParams { registrations: vec![registration] }, 154 lsp_types::RegistrationParams { registrations: vec![registration] },
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index 747654c1f..94d451e23 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -20,7 +20,7 @@ use walkdir::{DirEntry, WalkDir};
20 20
21use crate::{ 21use crate::{
22 codegen::Mode, 22 codegen::Mode,
23 not_bash::{fs2, pushd, pushenv, rm_rf, run}, 23 not_bash::{fs2, pushd, pushenv, rm_rf},
24}; 24};
25 25
26pub use anyhow::{bail, Context as _, Result}; 26pub use anyhow::{bail, Context as _, Result};
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs
index 8844fa216..0f3a56b25 100644
--- a/xtask/src/not_bash.rs
+++ b/xtask/src/not_bash.rs
@@ -54,7 +54,8 @@ pub mod fs2 {
54 } 54 }
55} 55}
56 56
57macro_rules! _run { 57#[macro_export]
58macro_rules! run {
58 ($($expr:expr),*) => { 59 ($($expr:expr),*) => {
59 run!($($expr),*; echo = true) 60 run!($($expr),*; echo = true)
60 }; 61 };
@@ -65,7 +66,7 @@ macro_rules! _run {
65 $crate::not_bash::run_process(format!($($expr),*), false, Some($stdin)) 66 $crate::not_bash::run_process(format!($($expr),*), false, Some($stdin))
66 }; 67 };
67} 68}
68pub(crate) use _run as run; 69pub use crate::run;
69 70
70pub struct Pushd { 71pub struct Pushd {
71 _p: (), 72 _p: (),
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index fcfad609d..72088e414 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -5,7 +5,7 @@ use std::{
5 5
6use xtask::{ 6use xtask::{
7 codegen::{self, Mode}, 7 codegen::{self, Mode},
8 not_bash::fs2, 8 not_bash::{fs2, run},
9 project_root, run_rustfmt, rust_files, 9 project_root, run_rustfmt, rust_files,
10}; 10};
11 11
@@ -49,6 +49,45 @@ fn rust_files_are_tidy() {
49 tidy_docs.finish(); 49 tidy_docs.finish();
50} 50}
51 51
52#[test]
53fn check_licenses() {
54 let expected = "
550BSD OR MIT OR Apache-2.0
56Apache-2.0
57Apache-2.0 / MIT
58Apache-2.0 OR BSL-1.0
59Apache-2.0 OR MIT
60Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
61Apache-2.0/MIT
62BSD-2-Clause
63BSD-3-Clause
64CC0-1.0
65ISC
66MIT
67MIT / Apache-2.0
68MIT OR Apache-2.0
69MIT/Apache-2.0
70MIT/Apache-2.0 AND BSD-2-Clause
71Unlicense OR MIT
72Unlicense/MIT
73Zlib
74"
75 .lines()
76 .filter(|it| !it.is_empty())
77 .collect::<Vec<_>>();
78
79 let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap();
80 let mut licenses = meta
81 .split(|c| c == ',' || c == '{' || c == '}')
82 .filter(|it| it.contains(r#""license""#))
83 .map(|it| it.trim())
84 .map(|it| it[r#""license":"#.len()..].trim_matches('"'))
85 .collect::<Vec<_>>();
86 licenses.sort();
87 licenses.dedup();
88 assert_eq!(licenses, expected);
89}
90
52fn check_todo(path: &Path, text: &str) { 91fn check_todo(path: &Path, text: &str) {
53 let need_todo = &[ 92 let need_todo = &[
54 // This file itself obviously needs to use todo (<- like this!). 93 // This file itself obviously needs to use todo (<- like this!).