Skip to content

Ubuntu 21.10 compat #12419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
31b7849
Revert upgrade of lsp_server to incompatible version.
KOLANICH May 30, 2022
10c6547
Reverted the usage of destructuring assignment into existing variable…
KOLANICH May 30, 2022
5d4f27e
Fixed some new usage of format incompatible with older versions of ru…
KOLANICH May 30, 2022
a3ecf2d
Fixed some new usage of format incompatible with older versions of ru…
KOLANICH May 30, 2022
5256620
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
742a81e
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
3b082e2
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
c9abc5c
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
4c8ec9f
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
36785d3
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
48f893a
Revert upgrade of xshell 56e43c34e7c56fe3c72e02c3d7d9261c73071f61.
KOLANICH May 30, 2022
7cb5b59
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
e248e6f
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
7488ff0
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
ac56b19
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
e39356e
Fixed some new usage of `format!` incompatible with older versions of…
KOLANICH May 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/hir-expand/src/builtin_fn_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,10 @@ fn relative_file(
let path = AnchoredPath { anchor: call_site, path: path_str };
let res = db
.resolve_path(path)
.ok_or_else(|| ExpandError::Other(format!("failed to load file `{path_str}`").into()))?;
.ok_or_else(|| ExpandError::Other(format!("failed to load file `{}`", path_str).into()))?;
// Prevent include itself
if res == call_site && !allow_recursion {
Err(ExpandError::Other(format!("recursive inclusion of `{path_str}`").into()))
Err(ExpandError::Other(format!("recursive inclusion of `{}`", path_str).into()))
} else {
Ok(res)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ impl HirDisplay for Path {
.as_ref()
.map(|name| name.canonical_name())
.unwrap_or("$crate");
write!(f, "{name}")?
write!(f, "{}", name)?
}
}

Expand Down
18 changes: 9 additions & 9 deletions crates/ide-assists/src/handlers/convert_let_else_to_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub(crate) fn convert_let_else_to_match(acc: &mut Assists, ctx: &AssistContext)
// remove the mut from the pattern
for (b, ismut) in binders.iter() {
if *ismut {
pat_no_mut = pat_no_mut.replace(&format!("mut {b}"), &b.to_string());
pat_no_mut = pat_no_mut.replace(&format!("mut {}", b), &b.to_string());
}
}

Expand All @@ -158,17 +158,17 @@ pub(crate) fn convert_let_else_to_match(acc: &mut Assists, ctx: &AssistContext)
};
let replace = if binders.is_empty() {
format!(
"match {init_expr} {{
{indent1}{pat_no_mut} => {binders_str}
{indent1}_ => {branch2}
{indent}}}"
"match {} {{
{}{} => {}
{}_ => {}
{}}}", init_expr, indent1, pat_no_mut, binders_str, indent1, branch2, indent
)
} else {
format!(
"let {binders_str_mut} = match {init_expr} {{
{indent1}{pat_no_mut} => {binders_str},
{indent1}_ => {branch2}
{indent}}};"
"let {} = match {} {{
{}{} => {},
{}_ => {}
{}}};", binders_str_mut, init_expr, indent1, pat_no_mut, binders_str, indent1, branch2, indent
)
};
edit.replace(target, replace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fn introduction_builder(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<Strin
} else {
""
};
Some(format!("Returns{reference} the {what} of this [`{}`].", linkable_self_ty?))
Some(format!("Returns{} the {} of this [`{}`].", reference, what, linkable_self_ty?))
}
_ => None,
};
Expand All @@ -228,7 +228,7 @@ fn introduction_builder(ast_func: &ast::Fn, ctx: &AssistContext) -> Option<Strin
if what == "len" {
what = "length".into()
};
Some(format!("Sets the {what} of this [`{}`].", linkable_self_ty?))
Some(format!("Sets the {} of this [`{}`].", what, linkable_self_ty?))
};

if let Some(intro) = intro_for_new() {
Expand Down
4 changes: 2 additions & 2 deletions crates/ide-completion/src/completions/fn_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub(crate) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
ParamKind::Closure(closure) => {
let stmt_list = closure.syntax().ancestors().find_map(ast::StmtList::cast)?;
params_from_stmt_list_scope(ctx, stmt_list, |name, ty| {
add_new_item_to_acc(&format!("{name}: {ty}"));
add_new_item_to_acc(&format!("{}: {}", name, ty));
});
}
}
Expand Down Expand Up @@ -95,7 +95,7 @@ fn fill_fn_params(

if let Some(stmt_list) = function.syntax().parent().and_then(ast::StmtList::cast) {
params_from_stmt_list_scope(ctx, stmt_list, |name, ty| {
file_params.entry(format!("{name}: {ty}")).or_insert(name.to_string());
file_params.entry(format!("{}: {}", name, ty)).or_insert(name.to_string());
});
}
remove_duplicated(&mut file_params, param_list.params());
Expand Down
4 changes: 3 additions & 1 deletion crates/ide-completion/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,9 @@ impl<'a> CompletionContext<'a> {
it.syntax().text_range().end() == syntax_element.text_range().end()
});

(self.expected_type, self.expected_name) = self.expected_type_and_name();
let (expected_type, expected_name) = self.expected_type_and_name();
self.expected_type = expected_type;
self.expected_name = expected_name;

// Overwrite the path kind for derives
if let Some((original_file, file_with_fake_ident, offset, origin_attr)) = derive_ctx {
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ limit = { path = "../limit", version = "0.0.0" }
[dev-dependencies]
test-utils = { path = "../test-utils" }
sourcegen = { path = "../sourcegen" }
xshell = "0.2.1"
xshell = "0.1"
expect-test = "1.2.2"
23 changes: 8 additions & 15 deletions crates/ide-db/src/tests/sourcegen_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ use std::{borrow::Cow, fs, path::Path};
use itertools::Itertools;
use stdx::format_to;
use test_utils::project_root;
use xshell::{cmd, Shell};
use xshell::cmd;

/// This clones rustc repo, and so is not worth to keep up-to-date. We update
/// manually by un-ignoring the test from time to time.
#[test]
#[ignore]
fn sourcegen_lint_completions() {
let sh = &Shell::new().unwrap();

let rust_repo = project_root().join("./target/rust");
if !rust_repo.exists() {
cmd!(sh, "git clone --depth=1 https://github.com/rust-lang/rust {rust_repo}")
.run()
.unwrap();
cmd!("git clone --depth=1 https://github.com/rust-lang/rust {rust_repo}").run().unwrap();
}

let mut contents = String::from(
Expand All @@ -34,19 +30,16 @@ pub struct LintGroup {
",
);

generate_lint_descriptor(sh, &mut contents);
generate_lint_descriptor(&mut contents);
contents.push('\n');

generate_feature_descriptor(&mut contents, &rust_repo.join("src/doc/unstable-book/src"));
contents.push('\n');

let lints_json = project_root().join("./target/clippy_lints.json");
cmd!(
sh,
"curl https://rust-lang.github.io/rust-clippy/master/lints.json --output {lints_json}"
)
.run()
.unwrap();
cmd!("curl https://rust-lang.github.io/rust-clippy/master/lints.json --output {lints_json}")
.run()
.unwrap();
generate_descriptor_clippy(&mut contents, &lints_json);

let contents = sourcegen::add_preamble("sourcegen_lints", sourcegen::reformat(contents));
Expand All @@ -55,10 +48,10 @@ pub struct LintGroup {
sourcegen::ensure_file_contents(destination.as_path(), &contents);
}

fn generate_lint_descriptor(sh: &Shell, buf: &mut String) {
fn generate_lint_descriptor(buf: &mut String) {
// FIXME: rustdoc currently requires an input file for -Whelp cc https://github.com/rust-lang/rust/pull/88831
let file = project_root().join(file!());
let stdout = cmd!(sh, "rustdoc -W help {file}").read().unwrap();
let stdout = cmd!("rustdoc -W help {file}").read().unwrap();
let start_lints = stdout.find("---- ------- -------").unwrap();
let start_lint_groups = stdout.find("---- ---------").unwrap();
let start_lints_rustdoc =
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-diagnostics/src/handlers/unresolved_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedModule) -> Option<Vec<
.map(|candidate| {
fix(
"create_module",
&format!("Create module at `{candidate}`"),
&format!("Create module at `{}`", candidate),
FileSystemEdit::CreateFile {
dst: AnchoredPathBuf {
anchor: d.decl.file_id.original_file(ctx.sema.db),
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ fn get_doc_base_url(db: &RootDatabase, def: Definition) -> Option<Url> {
| LangCrateOrigin::Std
| LangCrateOrigin::Test),
) => {
format!("https://doc.rust-lang.org/nightly/{origin}")
format!("https://doc.rust-lang.org/nightly/{}", origin)
}
_ => {
krate.get_html_root_url(db).or_else(|| {
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/expand_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn _format(
SyntaxKind::MACRO_TYPE => ("type __ =", ";"),
_ => ("", ""),
};
let expansion = format!("{prefix}{expansion}{suffix}");
let expansion = format!("{}{}{}", prefix, expansion, suffix);

let &crate_id = db.relevant_crates(file_id).iter().next()?;
let edition = db.crate_graph()[crate_id].edition;
Expand Down
4 changes: 2 additions & 2 deletions crates/ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn fn_lifetime_fn_hints(
let mut gen_idx_name = {
let mut gen = (0u8..).map(|idx| match idx {
idx if idx < 10 => SmolStr::from_iter(['\'', (idx + 48) as char]),
idx => format!("'{idx}").into(),
idx => format!("'{}", idx).into(),
});
move || gen.next().unwrap_or_default()
};
Expand Down Expand Up @@ -412,7 +412,7 @@ fn fn_lifetime_fn_hints(
Some(it) if config.param_names_for_lifetime_elision_hints => {
if let Some(c) = used_names.get_mut(it.text().as_str()) {
*c += 1;
SmolStr::from(format!("'{text}{c}", text = it.text().as_str()))
SmolStr::from(format!("'{text}{c}", text = it.text().as_str(), c=c))
} else {
used_names.insert(it.text().as_str().into(), 0);
SmolStr::from_iter(["\'", it.text().as_str()])
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/moniker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub(crate) fn def_to_moniker(
LangCrateOrigin::Other => {
"https://github.com/rust-lang/rust/library/".into()
}
lang => format!("https://github.com/rust-lang/rust/library/{lang}",),
lang => format!("https://github.com/rust-lang/rust/library/{}", lang),
},
),
};
Expand Down
2 changes: 1 addition & 1 deletion crates/mbe/src/expander/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
fn match_leaf(lhs: &tt::Leaf, src: &mut TtIter) -> Result<(), ExpandError> {
let rhs = src
.expect_leaf()
.map_err(|()| ExpandError::binding_error(format!("expected leaf: `{lhs}`")))?;
.map_err(|()| ExpandError::binding_error(format!("expected leaf: `{}`", lhs)))?;
match (lhs, rhs) {
(
tt::Leaf::Punct(tt::Punct { char: lhs, .. }),
Expand Down
10 changes: 5 additions & 5 deletions crates/mbe/src/expander/transcriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ impl Bindings {
}

let mut b: &Binding =
self.inner.get(name).ok_or_else(|| binding_err!("could not find binding `{name}`"))?;
self.inner.get(name).ok_or_else(|| binding_err!("could not find binding `{}`", name))?;
for nesting_state in nesting.iter_mut() {
nesting_state.hit = true;
b = match b {
Binding::Fragment(_) => break,
Binding::Nested(bs) => bs.get(nesting_state.idx).ok_or_else(|| {
nesting_state.at_end = true;
binding_err!("could not find nested binding `{name}`")
binding_err!("could not find nested binding `{}`", name)
})?,
Binding::Empty => {
nesting_state.at_end = true;
return Err(binding_err!("could not find empty binding `{name}`"));
return Err(binding_err!("could not find empty binding `{}`", name));
}
};
}
match b {
Binding::Fragment(it) => Ok(it),
Binding::Nested(_) => {
Err(binding_err!("expected simple binding, found nested binding `{name}`"))
Err(binding_err!("expected simple binding, found nested binding `{}`", name))
}
Binding::Empty => {
Err(binding_err!("expected simple binding, found empty binding `{name}`"))
Err(binding_err!("expected simple binding, found empty binding `{}`", name))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/mbe/src/tt_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'a> TtIter<'a> {
}

let err = if error || !cursor.is_root() {
Some(ExpandError::binding_error(format!("expected {entry_point:?}")))
Some(ExpandError::binding_error(format!("expected {:?}", entry_point)))
} else {
None
};
Expand Down
4 changes: 2 additions & 2 deletions crates/project-model/src/rustc_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn get(cargo_toml: Option<&ManifestPath>, target: Option<&str>) -> Ve
);
res.extend(rustc_cfgs.lines().filter_map(|it| it.parse().ok()));
}
Err(e) => tracing::error!("failed to get rustc cfgs: {e:?}"),
Err(e) => tracing::error!("failed to get rustc cfgs: {:?}", e),
}

res
Expand All @@ -47,7 +47,7 @@ fn get_rust_cfgs(cargo_toml: Option<&ManifestPath>, target: Option<&str>) -> Res
}
match utf8_stdout(cargo_config) {
Ok(it) => return Ok(it),
Err(e) => tracing::debug!("{e:?}: falling back to querying rustc for cfgs"),
Err(e) => tracing::debug!("{:?}: falling back to querying rustc for cfgs", e),
}
}
// using unstable cargo features failed, fall back to using plain rustc
Expand Down
4 changes: 2 additions & 2 deletions crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ threadpool = "1.8.1"
rayon = "1.5.1"
num_cpus = "1.13.1"
mimalloc = { version = "0.1.28", default-features = false, optional = true }
lsp-server = { version = "0.6.0", path = "../../lib/lsp-server" }
lsp-server = "0.5.2"
tracing = "0.1.32"
tracing-subscriber = { version = "0.3.9", default-features = false, features = [
"env-filter",
Expand Down Expand Up @@ -75,7 +75,7 @@ jemallocator = { version = "0.4.3", package = "tikv-jemallocator", optional = tr
[dev-dependencies]
expect-test = "1.2.2"
jod-thread = "0.1.2"
xshell = "0.2.1"
xshell = "0.1"

test-utils = { path = "../test-utils" }
sourcegen = { path = "../sourcegen" }
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ impl Config {
) {
Some(snippet) => self.snippets.push(snippet),
None => errors.push((
format!("snippet {name} is invalid"),
format!("snippet {} is invalid", name),
<serde_json::Error as serde::de::Error>::custom(
"snippet path is invalid or triggers are missing",
),
Expand Down
6 changes: 1 addition & 5 deletions crates/rust-analyzer/src/dispatch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! See [RequestDispatcher].
use std::{fmt, panic, thread};

use lsp_server::ExtractError;
use serde::{de::DeserializeOwned, Serialize};

use crate::{
Expand Down Expand Up @@ -235,10 +234,7 @@ impl<'a> NotificationDispatcher<'a> {
};
let params = match not.extract::<N::Params>(N::METHOD) {
Ok(it) => it,
Err(ExtractError::JsonError { method, error }) => {
panic!("Invalid request\nMethod: {method}\n error: {error}",)
}
Err(ExtractError::MethodMismatch(not)) => {
Err(not) => {
self.not = Some(not);
return Ok(self);
}
Expand Down
6 changes: 1 addition & 5 deletions crates/rust-analyzer/src/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ impl GlobalState {
}

pub(crate) fn complete_request(&mut self, response: lsp_server::Response) {
let handler = self
.req_queue
.outgoing
.complete(response.id.clone())
.expect("received response for unknown request");
let handler = self.req_queue.outgoing.complete(response.id.clone());
handler(self, response)
}

Expand Down
Loading