internal: re-generate lints.rs

This commit is contained in:
DaniPopes 2023-09-29 02:44:40 +02:00
parent f19479a2ad
commit 53f5c1c13f
No known key found for this signature in database
GPG key ID: 0F09640DDB7AC692
5 changed files with 2057 additions and 1283 deletions

View file

@ -89,7 +89,7 @@ impl fmt::Debug for CompletionItem {
let mut s = f.debug_struct("CompletionItem");
s.field("label", &self.label).field("source_range", &self.source_range);
if self.text_edit.len() == 1 {
let atom = &self.text_edit.iter().next().unwrap();
let atom = self.text_edit.iter().next().unwrap();
s.field("delete", &atom.delete);
s.field("insert", &atom.insert);
} else {

File diff suppressed because it is too large Load diff

View file

@ -51,7 +51,7 @@ pub struct LintGroup {
let contents = sourcegen::add_preamble("sourcegen_lints", sourcegen::reformat(contents));
let destination = project_root().join("crates/ide_db/src/generated/lints.rs");
let destination = project_root().join("crates/ide-db/src/generated/lints.rs");
sourcegen::ensure_file_contents(destination.as_path(), &contents);
}
@ -196,7 +196,7 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) {
let mut clippy_lints: Vec<ClippyLint> = Vec::new();
let mut clippy_groups: std::collections::BTreeMap<String, Vec<String>> = Default::default();
for line in file_content.lines().map(|line| line.trim()) {
for line in file_content.lines().map(str::trim) {
if let Some(line) = line.strip_prefix(r#""id": ""#) {
let clippy_lint = ClippyLint {
id: line.strip_suffix(r#"","#).expect("should be suffixed by comma").into(),
@ -211,12 +211,19 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) {
.push(clippy_lints.last().unwrap().id.clone());
}
} else if let Some(line) = line.strip_prefix(r#""docs": ""#) {
let prefix_to_strip = r#" ### What it does"#;
let line = match line.strip_prefix(prefix_to_strip) {
Some(line) => line,
let header = "### What it does";
let line = match line.find(header) {
Some(idx) => &line[idx + header.len()..],
None => {
eprintln!("unexpected clippy prefix for {}", clippy_lints.last().unwrap().id);
continue;
let id = &clippy_lints.last().unwrap().id;
// these just don't have the common header
let allowed = ["allow_attributes", "read_line_without_trim"];
if allowed.contains(&id.as_str()) {
line
} else {
eprintln!("\nunexpected clippy prefix for {id}, line={line:?}\n",);
continue;
}
}
};
// Only take the description, any more than this is a lot of additional data we would embed into the exe

View file

@ -5266,38 +5266,46 @@ pub fn foo() {}
#[test]
fn hover_feature() {
check(
r#"#![feature(box_syntax$0)]"#,
expect![[r##"
*box_syntax*
```
box_syntax
```
___
r#"#![feature(intrinsics$0)]"#,
expect![[r#"
*intrinsics*
```
intrinsics
```
___
# `box_syntax`
# `intrinsics`
The tracking issue for this feature is: [#49733]
The tracking issue for this feature is: None.
[#49733]: https://github.com/rust-lang/rust/issues/49733
Intrinsics are never intended to be stable directly, but intrinsics are often
exported in some sort of stable manner. Prefer using the stable interfaces to
the intrinsic directly when you can.
See also [`box_patterns`](box-patterns.md)
------------------------
------------------------
Currently the only stable way to create a `Box` is via the `Box::new` method.
Also it is not possible in stable Rust to destructure a `Box` in a match
pattern. The unstable `box` keyword can be used to create a `Box`. An example
usage would be:
These are imported as if they were FFI functions, with the special
`rust-intrinsic` ABI. For example, if one was in a freestanding
context, but wished to be able to `transmute` between types, and
perform efficient pointer arithmetic, one would import those functions
via a declaration like
```rust
#![feature(box_syntax)]
```rust
#![feature(intrinsics)]
#![allow(internal_features)]
# fn main() {}
fn main() {
let b = box 5;
}
```
extern "rust-intrinsic" {
fn transmute<T, U>(x: T) -> U;
"##]],
fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
}
```
As with any other FFI functions, these are always `unsafe` to call.
"#]],
)
}

View file

@ -300,6 +300,8 @@ fn check_test_attrs(path: &Path, text: &str) {
// This file.
"slow-tests/tidy.rs",
"test-utils/src/fixture.rs",
// Generated code from lints contains doc tests in string literals.
"ide-db/src/generated/lints.rs",
];
if text.contains("#[should_panic") && !need_panic.iter().any(|p| path.ends_with(p)) {
panic!(