mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-13 13:57:25 +00:00
fix: Allow flyimport to import primitive shadowing modules
This commit is contained in:
parent
062822ce91
commit
0851d21d1e
4 changed files with 28 additions and 2 deletions
|
@ -1618,3 +1618,18 @@ pub struct FooStruct;
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn primitive_mod() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
//- minicore: str
|
||||||
|
fn main() {
|
||||||
|
str::from$0
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
fn from_utf8_unchecked(…) (use core::str) const unsafe fn(&[u8]) -> &str
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -703,7 +703,7 @@ fn path_import_candidate(
|
||||||
) -> Option<ImportCandidate> {
|
) -> Option<ImportCandidate> {
|
||||||
Some(match qualifier {
|
Some(match qualifier {
|
||||||
Some(qualifier) => match sema.resolve_path(&qualifier) {
|
Some(qualifier) => match sema.resolve_path(&qualifier) {
|
||||||
None => {
|
Some(PathResolution::Def(ModuleDef::BuiltinType(_))) | None => {
|
||||||
if qualifier.first_qualifier().map_or(true, |it| sema.resolve_path(&it).is_none()) {
|
if qualifier.first_qualifier().map_or(true, |it| sema.resolve_path(&it).is_none()) {
|
||||||
let qualifier = qualifier
|
let qualifier = qualifier
|
||||||
.segments()
|
.segments()
|
||||||
|
|
|
@ -197,7 +197,9 @@ fn structure_token(token: SyntaxToken) -> Option<StructureNode> {
|
||||||
if let Some(comment) = ast::Comment::cast(token) {
|
if let Some(comment) = ast::Comment::cast(token) {
|
||||||
let text = comment.text().trim();
|
let text = comment.text().trim();
|
||||||
|
|
||||||
if let Some(region_name) = text.strip_prefix("// region:").map(str::trim) {
|
if let Some(region_name) =
|
||||||
|
text.strip_prefix("// region:").map(str::trim).filter(|it| !it.is_empty())
|
||||||
|
{
|
||||||
return Some(StructureNode {
|
return Some(StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
label: region_name.to_owned(),
|
label: region_name.to_owned(),
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
//! size_of: sized
|
//! size_of: sized
|
||||||
//! sized:
|
//! sized:
|
||||||
//! slice:
|
//! slice:
|
||||||
|
//! str:
|
||||||
//! sync: sized
|
//! sync: sized
|
||||||
//! transmute:
|
//! transmute:
|
||||||
//! try: infallible
|
//! try: infallible
|
||||||
|
@ -1368,6 +1369,14 @@ pub mod iter {
|
||||||
}
|
}
|
||||||
// endregion:iterator
|
// endregion:iterator
|
||||||
|
|
||||||
|
// region:str
|
||||||
|
pub mod str {
|
||||||
|
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// endregion:str
|
||||||
|
|
||||||
// region:panic
|
// region:panic
|
||||||
mod panic {
|
mod panic {
|
||||||
pub macro panic_2021 {
|
pub macro panic_2021 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue