Auto merge of #14604 - HKalbasi:dev3, r=Veykril
internal: Add minicore smoke test fix #14501
This commit is contained in:
commit
112464fd6b
@ -8,7 +8,7 @@ use ide_db::{
|
|||||||
RootDatabase,
|
RootDatabase,
|
||||||
};
|
};
|
||||||
use stdx::trim_indent;
|
use stdx::trim_indent;
|
||||||
use test_utils::{assert_eq_text, extract_annotations};
|
use test_utils::{assert_eq_text, extract_annotations, MiniCore};
|
||||||
|
|
||||||
use crate::{DiagnosticsConfig, ExprFillDefaultMode, Severity};
|
use crate::{DiagnosticsConfig, ExprFillDefaultMode, Severity};
|
||||||
|
|
||||||
@ -143,3 +143,23 @@ fn test_disabled_diagnostics() {
|
|||||||
);
|
);
|
||||||
assert!(!diagnostics.is_empty());
|
assert!(!diagnostics.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn minicore_smoke_test() {
|
||||||
|
fn check(minicore: MiniCore) {
|
||||||
|
let source = minicore.source_code();
|
||||||
|
let mut config = DiagnosticsConfig::test_sample();
|
||||||
|
// This should be ignored since we conditionaly remove code which creates single item use with braces
|
||||||
|
config.disabled.insert("unnecessary-braces".to_string());
|
||||||
|
check_diagnostics_with_config(config, &source);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks that there is no diagnostic in minicore for each flag.
|
||||||
|
for flag in MiniCore::available_flags() {
|
||||||
|
eprintln!("Checking minicore flag {flag}");
|
||||||
|
check(MiniCore::from_flags([flag]));
|
||||||
|
}
|
||||||
|
// And one time for all flags, to check codes which are behind multiple flags + prevent name collisions
|
||||||
|
eprintln!("Checking all minicore flags");
|
||||||
|
check(MiniCore::from_flags(MiniCore::available_flags()))
|
||||||
|
}
|
||||||
|
@ -444,7 +444,7 @@ fn main() {
|
|||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 5805..5813,
|
range: 5768..5776,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
@ -457,7 +457,7 @@ fn main() {
|
|||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 5837..5841,
|
range: 5800..5804,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
@ -478,7 +478,7 @@ fn main() {
|
|||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 5805..5813,
|
range: 5768..5776,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
@ -491,7 +491,7 @@ fn main() {
|
|||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 5837..5841,
|
range: 5800..5804,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
@ -512,7 +512,7 @@ fn main() {
|
|||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 5805..5813,
|
range: 5768..5776,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
@ -525,7 +525,7 @@ fn main() {
|
|||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 5837..5841,
|
range: 5800..5804,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
|
@ -254,10 +254,19 @@ impl FixtureWithProjectMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MiniCore {
|
impl MiniCore {
|
||||||
|
const RAW_SOURCE: &str = include_str!("./minicore.rs");
|
||||||
|
|
||||||
fn has_flag(&self, flag: &str) -> bool {
|
fn has_flag(&self, flag: &str) -> bool {
|
||||||
self.activated_flags.iter().any(|it| it == flag)
|
self.activated_flags.iter().any(|it| it == flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_flags<'a>(flags: impl IntoIterator<Item = &'a str>) -> Self {
|
||||||
|
MiniCore {
|
||||||
|
activated_flags: flags.into_iter().map(|x| x.to_owned()).collect(),
|
||||||
|
valid_flags: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn assert_valid_flag(&self, flag: &str) {
|
fn assert_valid_flag(&self, flag: &str) {
|
||||||
if !self.valid_flags.iter().any(|it| it == flag) {
|
if !self.valid_flags.iter().any(|it| it == flag) {
|
||||||
@ -278,13 +287,21 @@ impl MiniCore {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn available_flags() -> impl Iterator<Item = &'static str> {
|
||||||
|
let lines = MiniCore::RAW_SOURCE.split_inclusive('\n');
|
||||||
|
lines
|
||||||
|
.map_while(|x| x.strip_prefix("//!"))
|
||||||
|
.skip_while(|line| !line.contains("Available flags:"))
|
||||||
|
.skip(1)
|
||||||
|
.map(|x| x.split_once(':').unwrap().0.trim())
|
||||||
|
}
|
||||||
|
|
||||||
/// Strips parts of minicore.rs which are flagged by inactive flags.
|
/// Strips parts of minicore.rs which are flagged by inactive flags.
|
||||||
///
|
///
|
||||||
/// This is probably over-engineered to support flags dependencies.
|
/// This is probably over-engineered to support flags dependencies.
|
||||||
pub fn source_code(mut self) -> String {
|
pub fn source_code(mut self) -> String {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
let raw_mini_core = include_str!("./minicore.rs");
|
let mut lines = MiniCore::RAW_SOURCE.split_inclusive('\n');
|
||||||
let mut lines = raw_mini_core.split_inclusive('\n');
|
|
||||||
|
|
||||||
let mut implications = Vec::new();
|
let mut implications = Vec::new();
|
||||||
|
|
||||||
|
@ -32,8 +32,9 @@
|
|||||||
//! iterator: option
|
//! iterator: option
|
||||||
//! iterators: iterator, fn
|
//! iterators: iterator, fn
|
||||||
//! non_zero:
|
//! non_zero:
|
||||||
//! option:
|
//! option: panic
|
||||||
//! ord: eq, option
|
//! ord: eq, option
|
||||||
|
//! panic:
|
||||||
//! pin:
|
//! pin:
|
||||||
//! range:
|
//! range:
|
||||||
//! result:
|
//! result:
|
||||||
@ -191,6 +192,12 @@ pub mod convert {
|
|||||||
// endregion:infallible
|
// endregion:infallible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// region:drop
|
||||||
|
pub mod mem {
|
||||||
|
pub fn drop<T>(_x: T) {}
|
||||||
|
}
|
||||||
|
// endregion:drop
|
||||||
|
|
||||||
pub mod ops {
|
pub mod ops {
|
||||||
// region:coerce_unsized
|
// region:coerce_unsized
|
||||||
mod unsize {
|
mod unsize {
|
||||||
@ -315,12 +322,6 @@ pub mod ops {
|
|||||||
pub use self::index::{Index, IndexMut};
|
pub use self::index::{Index, IndexMut};
|
||||||
// endregion:index
|
// endregion:index
|
||||||
|
|
||||||
// region:drop
|
|
||||||
pub mod mem {
|
|
||||||
pub fn drop<T>(_x: T) {}
|
|
||||||
}
|
|
||||||
// endregion:drop
|
|
||||||
|
|
||||||
// region:range
|
// region:range
|
||||||
mod range {
|
mod range {
|
||||||
#[lang = "RangeFull"]
|
#[lang = "RangeFull"]
|
||||||
@ -473,12 +474,24 @@ pub mod ops {
|
|||||||
impl<B, C> Try for ControlFlow<B, C> {
|
impl<B, C> Try for ControlFlow<B, C> {
|
||||||
type Output = C;
|
type Output = C;
|
||||||
type Residual = ControlFlow<B, Infallible>;
|
type Residual = ControlFlow<B, Infallible>;
|
||||||
fn from_output(output: Self::Output) -> Self {}
|
fn from_output(output: Self::Output) -> Self {
|
||||||
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {}
|
ControlFlow::Continue(output)
|
||||||
|
}
|
||||||
|
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
|
||||||
|
match self {
|
||||||
|
ControlFlow::Continue(x) => ControlFlow::Continue(x),
|
||||||
|
ControlFlow::Break(x) => ControlFlow::Break(ControlFlow::Break(x)),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B, C> FromResidual for ControlFlow<B, C> {
|
impl<B, C> FromResidual for ControlFlow<B, C> {
|
||||||
fn from_residual(residual: ControlFlow<B, Infallible>) -> Self {}
|
fn from_residual(residual: ControlFlow<B, Infallible>) -> Self {
|
||||||
|
match residual {
|
||||||
|
ControlFlow::Break(b) => ControlFlow::Break(b),
|
||||||
|
ControlFlow::Continue(_) => loop {},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// region:option
|
// region:option
|
||||||
impl<T> Try for Option<T> {
|
impl<T> Try for Option<T> {
|
||||||
@ -499,6 +512,7 @@ pub mod ops {
|
|||||||
fn from_residual(x: Option<Infallible>) -> Self {
|
fn from_residual(x: Option<Infallible>) -> Self {
|
||||||
match x {
|
match x {
|
||||||
None => None,
|
None => None,
|
||||||
|
Some(_) => loop {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,6 +541,7 @@ pub mod ops {
|
|||||||
fn from_residual(residual: Result<Infallible, E>) -> Self {
|
fn from_residual(residual: Result<Infallible, E>) -> Self {
|
||||||
match residual {
|
match residual {
|
||||||
Err(e) => Err(From::from(e)),
|
Err(e) => Err(From::from(e)),
|
||||||
|
Ok(_) => loop {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -840,8 +855,6 @@ pub mod iter {
|
|||||||
|
|
||||||
mod traits {
|
mod traits {
|
||||||
mod iterator {
|
mod iterator {
|
||||||
use super::super::Take;
|
|
||||||
|
|
||||||
pub trait Iterator {
|
pub trait Iterator {
|
||||||
type Item;
|
type Item;
|
||||||
#[lang = "next"]
|
#[lang = "next"]
|
||||||
@ -903,7 +916,7 @@ pub mod iter {
|
|||||||
type Item = T;
|
type Item = T;
|
||||||
type IntoIter = IntoIter<T, N>;
|
type IntoIter = IntoIter<T, N>;
|
||||||
fn into_iter(self) -> I {
|
fn into_iter(self) -> I {
|
||||||
IntoIter { data: self, range: IndexRange { start: 0, end: self.len() } }
|
IntoIter { data: self, range: IndexRange { start: 0, end: loop {} } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T, const N: usize> Iterator for IntoIter<T, N> {
|
impl<T, const N: usize> Iterator for IntoIter<T, N> {
|
||||||
@ -919,16 +932,38 @@ pub mod iter {
|
|||||||
}
|
}
|
||||||
// endregion:iterator
|
// endregion:iterator
|
||||||
|
|
||||||
// region:derive
|
// region:panic
|
||||||
|
mod panic {
|
||||||
|
pub macro panic_2021 {
|
||||||
|
($($t:tt)+) => (
|
||||||
|
/* Nothing yet */
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// endregion:panic
|
||||||
|
|
||||||
mod macros {
|
mod macros {
|
||||||
|
// region:panic
|
||||||
|
#[macro_export]
|
||||||
|
#[rustc_builtin_macro(std_panic)]
|
||||||
|
macro_rules! panic {
|
||||||
|
($($arg:tt)*) => {
|
||||||
|
/* compiler built-in */
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use panic;
|
||||||
|
// endregion:panic
|
||||||
|
|
||||||
|
// region:derive
|
||||||
pub(crate) mod builtin {
|
pub(crate) mod builtin {
|
||||||
#[rustc_builtin_macro]
|
#[rustc_builtin_macro]
|
||||||
pub macro derive($item:item) {
|
pub macro derive($item:item) {
|
||||||
/* compiler built-in */
|
/* compiler built-in */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// endregion:derive
|
||||||
}
|
}
|
||||||
// endregion:derive
|
|
||||||
|
|
||||||
// region:non_zero
|
// region:non_zero
|
||||||
pub mod num {
|
pub mod num {
|
||||||
@ -983,6 +1018,7 @@ pub mod prelude {
|
|||||||
ops::{Fn, FnMut, FnOnce}, // :fn
|
ops::{Fn, FnMut, FnOnce}, // :fn
|
||||||
option::Option::{self, None, Some}, // :option
|
option::Option::{self, None, Some}, // :option
|
||||||
result::Result::{self, Err, Ok}, // :result
|
result::Result::{self, Err, Ok}, // :result
|
||||||
|
panic, // :panic
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user