mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Merge #4889
4889: Deprecate hir::Path::from_ast r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
db6100dbaa
7 changed files with 17 additions and 13 deletions
|
@ -106,6 +106,7 @@ impl<'a> SubstituteTypeParams<'a> {
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
// FIXME: use `hir::Path::from_src` instead.
|
// FIXME: use `hir::Path::from_src` instead.
|
||||||
|
#[allow(deprecated)]
|
||||||
let path = hir::Path::from_ast(path)?;
|
let path = hir::Path::from_ast(path)?;
|
||||||
let resolution = self.source_scope.resolve_hir_path(&path)?;
|
let resolution = self.source_scope.resolve_hir_path(&path)?;
|
||||||
match resolution {
|
match resolution {
|
||||||
|
@ -150,6 +151,7 @@ impl<'a> QualifyPaths<'a> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
// FIXME: use `hir::Path::from_src` instead.
|
// FIXME: use `hir::Path::from_src` instead.
|
||||||
|
#[allow(deprecated)]
|
||||||
let hir_path = hir::Path::from_ast(p.clone());
|
let hir_path = hir::Path::from_ast(p.clone());
|
||||||
let resolution = self.source_scope.resolve_hir_path(&hir_path?)?;
|
let resolution = self.source_scope.resolve_hir_path(&hir_path?)?;
|
||||||
match resolution {
|
match resolution {
|
||||||
|
|
|
@ -154,7 +154,7 @@ pub enum GenericArg {
|
||||||
|
|
||||||
impl Path {
|
impl Path {
|
||||||
/// Converts an `ast::Path` to `Path`. Works with use trees.
|
/// Converts an `ast::Path` to `Path`. Works with use trees.
|
||||||
/// DEPRECATED: It does not handle `$crate` from macro call.
|
#[deprecated = "Doesn't handle hygiene, don't add new calls, remove old ones"]
|
||||||
pub fn from_ast(path: ast::Path) -> Option<Path> {
|
pub fn from_ast(path: ast::Path) -> Option<Path> {
|
||||||
lower::lower_path(path, &Hygiene::new_unhygienic())
|
lower::lower_path(path, &Hygiene::new_unhygienic())
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,6 +381,7 @@ impl<'a> CompletionContext<'a> {
|
||||||
self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some();
|
self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some();
|
||||||
self.has_type_args = segment.type_arg_list().is_some();
|
self.has_type_args = segment.type_arg_list().is_some();
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
if let Some(path) = hir::Path::from_ast(path.clone()) {
|
if let Some(path) = hir::Path::from_ast(path.clone()) {
|
||||||
if let Some(path_prefix) = path.qualifier() {
|
if let Some(path_prefix) = path.qualifier() {
|
||||||
self.path_prefix = Some(path_prefix);
|
self.path_prefix = Some(path_prefix);
|
||||||
|
|
|
@ -50,10 +50,8 @@ fn expr_no_struct(p: &mut Parser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_expr_stmt_attr_allowed(kind: SyntaxKind) -> bool {
|
fn is_expr_stmt_attr_allowed(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
let forbid = matches!(kind, BIN_EXPR | RANGE_EXPR);
|
||||||
BIN_EXPR | RANGE_EXPR | IF_EXPR => false,
|
!forbid
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
|
pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
|
||||||
|
|
|
@ -56,4 +56,3 @@ SOURCE_FILE@0..48
|
||||||
R_CURLY@46..47 "}"
|
R_CURLY@46..47 "}"
|
||||||
WHITESPACE@47..48 "\n"
|
WHITESPACE@47..48 "\n"
|
||||||
error 24..24: attributes are not allowed on BIN_EXPR
|
error 24..24: attributes are not allowed on BIN_EXPR
|
||||||
error 44..44: attributes are not allowed on IF_EXPR
|
|
||||||
|
|
|
@ -10,17 +10,17 @@
|
||||||
pub mod mark;
|
pub mod mark;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
env, fs,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use ra_cfg::CfgOptions;
|
use serde_json::Value;
|
||||||
use stdx::split1;
|
use stdx::split1;
|
||||||
|
use text_size::{TextRange, TextSize};
|
||||||
|
|
||||||
|
pub use ra_cfg::CfgOptions;
|
||||||
pub use relative_path::{RelativePath, RelativePathBuf};
|
pub use relative_path::{RelativePath, RelativePathBuf};
|
||||||
pub use rustc_hash::FxHashMap;
|
pub use rustc_hash::FxHashMap;
|
||||||
use serde_json::Value;
|
|
||||||
use text_size::{TextRange, TextSize};
|
|
||||||
|
|
||||||
pub use difference::Changeset as __Changeset;
|
pub use difference::Changeset as __Changeset;
|
||||||
|
|
||||||
|
@ -625,8 +625,6 @@ pub fn skip_slow_tests() -> bool {
|
||||||
should_skip
|
should_skip
|
||||||
}
|
}
|
||||||
|
|
||||||
const REWRITE: bool = false;
|
|
||||||
|
|
||||||
/// Asserts that `expected` and `actual` strings are equal. If they differ only
|
/// Asserts that `expected` and `actual` strings are equal. If they differ only
|
||||||
/// in trailing or leading whitespace the test won't fail and
|
/// in trailing or leading whitespace the test won't fail and
|
||||||
/// the contents of `actual` will be written to the file located at `path`.
|
/// the contents of `actual` will be written to the file located at `path`.
|
||||||
|
@ -642,7 +640,7 @@ fn assert_equal_text(expected: &str, actual: &str, path: &Path) {
|
||||||
fs::write(path, actual).unwrap();
|
fs::write(path, actual).unwrap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if REWRITE {
|
if env::var("UPDATE_EXPECTATIONS").is_ok() {
|
||||||
println!("rewriting {}", pretty_path.display());
|
println!("rewriting {}", pretty_path.display());
|
||||||
fs::write(path, actual).unwrap();
|
fs::write(path, actual).unwrap();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -342,6 +342,12 @@ There are two kinds of tests:
|
||||||
The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for.
|
The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for.
|
||||||
If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test.
|
If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test.
|
||||||
|
|
||||||
|
To update test data, run with `UPDATE_EXPECTATIONS` variable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
env UPDATE_EXPECTATIONS=1 cargo qt
|
||||||
|
```
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
||||||
Logging is done by both rust-analyzer and VS Code, so it might be tricky to
|
Logging is done by both rust-analyzer and VS Code, so it might be tricky to
|
||||||
|
|
Loading…
Reference in a new issue