Merge commit 'ddf105b646' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2024-02-11 08:40:19 +02:00
parent 0816d49d83
commit e41ab350d6
378 changed files with 14720 additions and 3111 deletions

View file

@ -206,7 +206,7 @@ impl Definition {
// docs are missing, for assoc items of trait impls try to fall back to the docs of the
// original item of the trait
let assoc = self.as_assoc_item(db)?;
let trait_ = assoc.containing_trait_impl(db)?;
let trait_ = assoc.implemented_trait(db)?;
let name = Some(assoc.name(db)?);
let item = trait_.items(db).into_iter().find(|it| it.name(db) == name)?;
item.docs(db)

View file

@ -1,7 +1,7 @@
//! See [`FamousDefs`].
use base_db::{CrateOrigin, LangCrateOrigin, SourceDatabase};
use hir::{Crate, Enum, Macro, Module, ScopeDef, Semantics, Trait};
use hir::{Crate, Enum, Function, Macro, Module, ScopeDef, Semantics, Trait};
use crate::RootDatabase;
@ -110,6 +110,10 @@ impl FamousDefs<'_, '_> {
self.find_macro("core:macros:builtin:derive")
}
pub fn core_mem_drop(&self) -> Option<Function> {
self.find_function("core:mem:drop")
}
pub fn builtin_crates(&self) -> impl Iterator<Item = Crate> {
IntoIterator::into_iter([
self.std(),
@ -149,6 +153,13 @@ impl FamousDefs<'_, '_> {
}
}
fn find_function(&self, path: &str) -> Option<Function> {
match self.find_def(path)? {
hir::ScopeDef::ModuleDef(hir::ModuleDef::Function(it)) => Some(it),
_ => None,
}
}
fn find_lang_crate(&self, origin: LangCrateOrigin) -> Option<Crate> {
let krate = self.1;
let db = self.0.db;

View file

@ -5044,17 +5044,6 @@ against are compatible with those of the `#[ffi_pure]`.
[ARM C/C++ compiler]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/Cacigdac.html
[GCC]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
[IBM ILE C/C++]: https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_71/rzarg/fn_attrib_pure.htm
"##,
},
Lint {
label: "ffi_returns_twice",
description: r##"# `ffi_returns_twice`
The tracking issue for this feature is: [#58314]
[#58314]: https://github.com/rust-lang/rust/issues/58314
------------------------
"##,
},
Lint {

View file

@ -529,7 +529,7 @@ fn trait_applicable_items(
return None;
}
let assoc_item_trait = assoc.containing_trait(db)?;
let assoc_item_trait = assoc.container_trait(db)?;
if related_traits.contains(&assoc_item_trait) {
return None;
}
@ -550,8 +550,7 @@ fn trait_applicable_items(
None,
|assoc| {
if required_assoc_items.contains(&assoc) {
let located_trait =
assoc.containing_trait(db).filter(|&it| scope_filter(it))?;
let located_trait = assoc.container_trait(db).filter(|&it| scope_filter(it))?;
let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
let import_path = trait_import_paths
.entry(trait_item)
@ -576,8 +575,7 @@ fn trait_applicable_items(
|function| {
let assoc = function.as_assoc_item(db)?;
if required_assoc_items.contains(&assoc) {
let located_trait =
assoc.containing_trait(db).filter(|&it| scope_filter(it))?;
let located_trait = assoc.container_trait(db).filter(|&it| scope_filter(it))?;
let trait_item = ItemInNs::from(ModuleDef::from(located_trait));
let import_path = trait_import_paths
.entry(trait_item)
@ -605,6 +603,7 @@ fn assoc_to_item(assoc: AssocItem) -> ItemInNs {
}
}
#[tracing::instrument(skip_all)]
fn get_mod_path(
db: &RootDatabase,
item_to_search: ItemInNs,

View file

@ -214,7 +214,7 @@ fn insert_use_with_alias_option(
};
}
let mut use_tree = make::use_tree(path.clone(), None, alias, false);
let mut use_tree = make::use_tree(path, None, alias, false);
if mb == Some(MergeBehavior::One) && use_tree.path().is_some() {
use_tree = use_tree.clone_for_update();
use_tree.wrap_in_tree_list();

View file

@ -203,7 +203,7 @@ mod tests {
use expect_test::{expect, Expect};
fn check(input: &str, expect: &Expect) {
let (output, exprs) = parse_format_exprs(input).unwrap_or(("-".to_string(), vec![]));
let (output, exprs) = parse_format_exprs(input).unwrap_or(("-".to_owned(), vec![]));
let outcome_repr = if !exprs.is_empty() {
format!("{output}; {}", with_placeholders(exprs).join(", "))
} else {

View file

@ -52,7 +52,7 @@ pub struct LintGroup {
generate_lint_descriptor(sh, &mut contents);
contents.push('\n');
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_owned());
let unstable_book = project_root().join("./target/unstable-book-gen");
cmd!(
sh,
@ -241,6 +241,7 @@ fn unescape(s: &str) -> String {
s.replace(r#"\""#, "").replace(r#"\n"#, "\n").replace(r#"\r"#, "")
}
#[allow(clippy::print_stderr)]
fn generate_descriptor_clippy(buf: &mut String, path: &Path) {
let file_content = std::fs::read_to_string(path).unwrap();
let mut clippy_lints: Vec<ClippyLint> = Vec::new();
@ -282,7 +283,7 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) {
let line = &line[..up_to];
let clippy_lint = clippy_lints.last_mut().expect("clippy lint must already exist");
clippy_lint.help = unescape(line).trim().to_string();
clippy_lint.help = unescape(line).trim().to_owned();
}
}
clippy_lints.sort_by(|lint, lint2| lint.id.cmp(&lint2.id));

View file

@ -75,7 +75,7 @@ pub fn get_missing_assoc_items(
pub(crate) fn convert_to_def_in_trait(db: &dyn HirDatabase, def: Definition) -> Definition {
(|| {
let assoc = def.as_assoc_item(db)?;
let trait_ = assoc.containing_trait_impl(db)?;
let trait_ = assoc.implemented_trait(db)?;
assoc_item_of_trait(db, assoc, trait_)
})()
.unwrap_or(def)