-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal: Update match checking algorithm #10484
Conversation
0d43b44
to
3f63ff1
Compare
I'll probably continue on this before the extraction into a library rust-lang/rust#89570 lands. Anyway this represents the current rustc nightly, except some recent fixes I want to catch up. |
3f63ff1
to
3a7531d
Compare
Tested 6942dd4 (outdated):
ui test detailsdiff --git a/crates/ide_diagnostics/src/tests.rs b/crates/ide_diagnostics/src/tests.rs
index a2b92c4ff..59d0d9eb3 100644
--- a/crates/ide_diagnostics/src/tests.rs
+++ b/crates/ide_diagnostics/src/tests.rs
@@ -1,4 +1,13 @@
mod sourcegen;
+mod ui {
+ mod pattern;
+ mod or_patterns;
+ mod rfc_2008;
+ mod match_;
+ mod binding;
+ mod rfc_2005;
+ mod rfcs_rfc_2005;
+}
use expect_test::Expect;
use ide_db::{
@@ -126,6 +135,20 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
}
}
+#[track_caller]
+pub(crate) fn scan_diagnostics(ra_fixture: &str) {
+ let fixture = format!(
+ r"
+//- minicore: option, sized
+{}
+",
+ ra_fixture
+ );
+
+ let (db, file) = RootDatabase::with_single_file(&fixture);
+ super::diagnostics(&db, &DiagnosticsConfig::default(), &AssistResolveStrategy::All, file);
+}
+
#[test]
fn test_disabled_diagnostics() {
let mut config = DiagnosticsConfig::default();
diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs
index 3d303a123..1f07538d0 100644
--- a/crates/test_utils/src/fixture.rs
+++ b/crates/test_utils/src/fixture.rs
@@ -150,7 +150,7 @@ impl Fixture {
&& !line.contains(".")
&& line.chars().all(|it| !it.is_uppercase())
{
- panic!("looks like invalid metadata line: {:?}", line);
+ // panic!("looks like invalid metadata line: {:?}", line);
}
if let Some(entry) = res.last_mut() {
diff --git a/ui b/ui
new file mode 100644
index 000000000..97ecea6cd
--- /dev/null
+++ b/ui
@@ -0,0 +1,23 @@
+ui/pattern/
+ui/or-patterns/
+ui/rfc-2008-non-exhaustive/
+ui/match/
+ui/binding/
+ui/rfc-2005-default-binding-mode/
+ui/rfcs/rfc-2005-default-binding-mode/
+
+
+#!/bin/bash
+echo "use crate::tests::scan_diagnostics;"
+for file in $(find $1 -name "*.rs")
+do
+ test_name=__$(basename "$file" ".rs" | sed -e 's/[^a-zA-Z0-9_]/_/g')
+ echo "\
+#[test]
+fn $test_name() {
+ scan_diagnostics(include_str!(
+ \"$file\"
+ ));
+}
+"
+done
|
6942dd4
to
a1e67d4
Compare
Tested on rebased a1e67d4 (update: rebased again a9ad7be, results should be the same)
|
@iDawer can you please rebase? There's been a couple of mechanical changes related to |
Original version: rust-lang/rust 68b76a483 2021-10-01
a1e67d4
to
a9ad7be
Compare
Done! It is simply |
(Slice(self_slice), Slice(other_slice)) | ||
if self_slice.arity() != other_slice.arity() => | ||
{ | ||
unimplemented!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can people hit this currently? We don't wanna panic if that is the case I'd say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, Slice
is void struct. It is here just to preserve semantics of catchall arms
/// A constructor for array and slice patterns.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub(super) struct Slice {
_unimplemented: Void,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To 'preserve' in relation of rustc
Thanks! Let's merge this to avoid further conflicts. bors r+ |
Sync match checking algorithm with rust-lang/rust f31622a50 2021-11-12 (rust-lang/rust#90813)
This update brings huge simplification to the match checking and introduces an easy to use machinery for pattern destructuring and also:
hir_ty::infer::normalize(...)
.InferenceResult
.Todo: