on master help sign in
Derive debug without feature

Note that this also removed those `finish_non_exhaustive()`.

commit7cc13fefe9bd09ea778a0eb8c26bf133e6ad2476 authorIvan Tham <pickfire@riseup.net> dateMon 7 Jun 2021, 22:34 (5 years ago) parent1a3a924
19 files changed+36−61
helix-core/Cargo.toml−1 helix-core/src/diagnostic.rs+3−4 helix-core/src/graphemes.rs+1−2 helix-core/src/history.rs+1−1 helix-core/src/movement.rs+1−2 helix-core/src/state.rs+1−2 helix-core/src/syntax.rs+13−21 helix-core/src/transaction.rs+1−2 helix-lsp/Cargo.toml−3 helix-lsp/src/client.rs+1−1 helix-lsp/src/lib.rs+1−1 helix-lsp/src/transport.rs+1−1 helix-term/Cargo.toml−1 helix-tui/Cargo.toml−1 helix-view/Cargo.toml−1 helix-view/src/document.rs+2−5 helix-view/src/editor.rs+2−3 helix-view/src/tree.rs+6−7 helix-view/src/view.rs+2−2
helix-core/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
1010
1111[features]
1212embed_runtime = ["rust-embed"]
13−debug = []
1413
1514[dependencies]
1615helix-syntax = { path = "../helix-syntax" }
helix-core/src/diagnostic.rs+3−4
@@ -1,5 +1,4 @@
1−#[cfg_attr(feature = "debug", derive(Debug))]
2−#[derive(Eq, PartialEq)]
1+#[derive(Debug, Eq, PartialEq)]
32pub enum Severity {
43 Error,
54 Warning,
@@ -7,13 +6,13 @@ pub enum Severity {
76 Hint,
87}
98
10−#[cfg_attr(feature = "debug", derive(Debug))]
9+#[derive(Debug)]
1110pub struct Range {
1211 pub start: usize,
1312 pub end: usize,
1413}
1514
16−#[cfg_attr(feature = "debug", derive(Debug))]
15+#[derive(Debug)]
1716pub struct Diagnostic {
1817 pub range: Range,
1918 pub line: usize,
helix-core/src/graphemes.rs+1−2
@@ -147,8 +147,7 @@ pub fn is_grapheme_boundary(slice: RopeSlice, char_idx: usize) -> bool {
147147}
148148
149149/// An iterator over the graphemes of a `RopeSlice`.
150−#[cfg_attr(feature = "debug", derive(Debug))]
151−#[derive(Clone)]
150+#[derive(Debug, Clone)]
152151pub struct RopeGraphemes<'a> {
153152 text: RopeSlice<'a>,
154153 chunks: Chunks<'a>,
helix-core/src/history.rs+1−1
@@ -2,7 +2,7 @@ use crate::{ChangeSet, Rope, State, Transaction};
22use smallvec::{smallvec, SmallVec};
33
44/// Undo-tree style history store.
5−#[cfg_attr(feature = "debug", derive(Debug))]
5+#[derive(Debug)]
66pub struct History {
77 revisions: Vec<Revision>,
88 cursor: usize,
helix-core/src/movement.rs+1−2
@@ -1,8 +1,7 @@
11use crate::graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary, RopeGraphemes};
22use crate::{coords_at_pos, pos_at_coords, ChangeSet, Position, Range, Rope, RopeSlice, Selection};
33
4−#[cfg_attr(feature = "debug", derive(Debug))]
5−#[derive(Copy, Clone, PartialEq, Eq)]
4+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
65pub enum Direction {
76 Forward,
87 Backward,
helix-core/src/state.rs+1−2
@@ -1,8 +1,7 @@
11use crate::{Rope, Selection};
22
33/// A state represents the current editor state of a single buffer.
4−#[cfg_attr(feature = "debug", derive(Debug))]
5−#[derive(Clone)]
4+#[derive(Debug, Clone)]
65pub struct State {
76 pub doc: Rope,
87 pub selection: Selection,
helix-core/src/syntax.rs+13−21
@@ -1,12 +1,11 @@
11use crate::{regex::Regex, Change, Rope, RopeSlice, Transaction};
22pub use helix_syntax::{get_language, get_language_name, Lang};
33
4−#[cfg(feature = "debug")]
5−use std::fmt;
64use std::{
75 borrow::Cow,
86 cell::RefCell,
97 collections::{HashMap, HashSet},
8+ fmt,
109 path::{Path, PathBuf},
1110 sync::Arc,
1211};
@@ -14,15 +13,13 @@ use std::{
1413use once_cell::sync::{Lazy, OnceCell};
1514use serde::{Deserialize, Serialize};
1615
17−#[cfg_attr(feature = "debug", derive(Debug))]
18−#[derive(Serialize, Deserialize)]
16+#[derive(Debug, Serialize, Deserialize)]
1917pub struct Configuration {
2018 pub language: Vec<LanguageConfiguration>,
2119}
2220
2321// largely based on tree-sitter/cli/src/loader.rs
24−#[cfg_attr(feature = "debug", derive(Debug))]
25−#[derive(Serialize, Deserialize)]
22+#[derive(Debug, Serialize, Deserialize)]
2623#[serde(rename_all = "kebab-case")]
2724pub struct LanguageConfiguration {
2825 #[serde(rename = "name")]
@@ -50,8 +47,7 @@ pub struct LanguageConfiguration {
5047 pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
5148}
5249
53−#[cfg_attr(feature = "debug", derive(Debug))]
54−#[derive(Serialize, Deserialize)]
50+#[derive(Debug, Serialize, Deserialize)]
5551#[serde(rename_all = "kebab-case")]
5652pub struct LanguageServerConfiguration {
5753 pub command: String,
@@ -60,16 +56,14 @@ pub struct LanguageServerConfiguration {
6056 pub args: Vec<String>,
6157}
6258
63−#[cfg_attr(feature = "debug", derive(Debug))]
64−#[derive(Serialize, Deserialize)]
59+#[derive(Debug, Serialize, Deserialize)]
6560#[serde(rename_all = "kebab-case")]
6661pub struct IndentationConfiguration {
6762 pub tab_width: usize,
6863 pub unit: String,
6964}
7065
71−#[cfg_attr(feature = "debug", derive(Debug))]
72−#[derive(Serialize, Deserialize)]
66+#[derive(Debug, Serialize, Deserialize)]
7367#[serde(rename_all = "kebab-case")]
7468pub struct IndentQuery {
7569 #[serde(default)]
@@ -196,7 +190,7 @@ impl LanguageConfiguration {
196190
197191pub static LOADER: OnceCell<Loader> = OnceCell::new();
198192
199−#[cfg_attr(feature = "debug", derive(Debug))]
193+#[derive(Debug)]
200194pub struct Loader {
201195 // highlight_names ?
202196 language_configs: Vec<Arc<LanguageConfiguration>>,
@@ -264,10 +258,9 @@ pub struct TsParser {
264258 cursors: Vec<QueryCursor>,
265259}
266260
267−#[cfg(feature = "debug")]
268261impl fmt::Debug for TsParser {
269262 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
270− f.debug_struct("TsParser").finish_non_exhaustive()
263+ f.debug_struct("TsParser").finish()
271264 }
272265}
273266
@@ -279,7 +272,7 @@ thread_local! {
279272 })
280273}
281274
282−#[cfg_attr(feature = "debug", derive(Debug))]
275+#[derive(Debug)]
283276pub struct Syntax {
284277 config: Arc<HighlightConfiguration>,
285278
@@ -460,7 +453,7 @@ impl Syntax {
460453 // buffer_range_for_scope_at_pos
461454}
462455
463−#[cfg_attr(feature = "debug", derive(Debug))]
456+#[derive(Debug)]
464457pub struct LanguageLayer {
465458 // mode
466459 // grammar
@@ -769,7 +762,7 @@ pub enum HighlightEvent {
769762/// Contains the data neeeded to higlight code written in a particular language.
770763///
771764/// This struct is immutable and can be shared between threads.
772−#[cfg_attr(feature = "debug", derive(Debug))]
765+#[derive(Debug)]
773766pub struct HighlightConfiguration {
774767 pub language: Grammar,
775768 pub query: Query,
@@ -800,7 +793,7 @@ struct LocalScope<'a> {
800793 local_defs: Vec<LocalDef<'a>>,
801794}
802795
803−#[cfg_attr(feature = "debug", derive(Debug))]
796+#[derive(Debug)]
804797struct HighlightIter<'a, 'tree: 'a, F>
805798where
806799 F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
@@ -826,10 +819,9 @@ struct HighlightIterLayer<'a, 'tree: 'a> {
826819 depth: usize,
827820}
828821
829−#[cfg(feature = "debug")]
830822impl<'a, 'tree: 'a> fmt::Debug for HighlightIterLayer<'a, 'tree> {
831823 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
832− f.debug_struct("HighlightIterLayer").finish_non_exhaustive()
824+ f.debug_struct("HighlightIterLayer").finish()
833825 }
834826}
835827
helix-core/src/transaction.rs+1−2
@@ -15,8 +15,7 @@ pub enum Operation {
1515 Insert(Tendril),
1616}
1717
18−#[cfg_attr(feature = "debug", derive(Debug))]
19−#[derive(Copy, Clone, PartialEq, Eq)]
18+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
2019pub enum Assoc {
2120 Before,
2221 After,
helix-lsp/Cargo.toml−3
@@ -7,9 +7,6 @@ license = "MPL-2.0"
77
88# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99
10−[features]
11−debug = ["helix-core/debug"]
12−
1310[dependencies]
1411helix-core = { path = "../helix-core" }
1512
helix-lsp/src/client.rs+1−1
@@ -16,7 +16,7 @@ use tokio::{
1616 sync::mpsc::{channel, UnboundedReceiver, UnboundedSender},
1717};
1818
19−#[cfg_attr(feature = "debug", derive(Debug))]
19+#[derive(Debug)]
2020pub struct Client {
2121 _process: Child,
2222 server_tx: UnboundedSender<Payload>,
helix-lsp/src/lib.rs+1−1
@@ -172,7 +172,7 @@ impl Notification {
172172 }
173173}
174174
175−#[cfg_attr(feature = "debug", derive(Debug))]
175+#[derive(Debug)]
176176pub struct Registry {
177177 inner: HashMap<LanguageId, Arc<Client>>,
178178
helix-lsp/src/transport.rs+1−1
@@ -31,7 +31,7 @@ enum ServerMessage {
3131 Call(jsonrpc::Call),
3232}
3333
34−#[cfg_attr(feature = "debug", derive(Debug))]
34+#[derive(Debug)]
3535pub struct Transport {
3636 client_tx: UnboundedSender<jsonrpc::Call>,
3737 client_rx: UnboundedReceiver<Payload>,
helix-term/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
1010
1111[features]
1212embed_runtime = ["helix-core/embed_runtime"]
13−debug = ["helix-core/debug", "helix-view/debug"]
1413
1514[[bin]]
1615name = "hx"
helix-tui/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
1010
1111[features]
1212default = ["crossterm"]
13−debug = []
1413
1514[dependencies]
1615bitflags = "1.0"
helix-view/Cargo.toml−1
@@ -10,7 +10,6 @@ license = "MPL-2.0"
1010[features]
1111term = ["tui", "crossterm"]
1212default = ["term"]
13−debug = ["helix-core/debug", "helix-lsp/debug"]
1413
1514[dependencies]
1615anyhow = "1"
helix-view/src/document.rs+2−5
@@ -13,8 +13,7 @@ use crate::{DocumentId, ViewId};
1313
1414use std::collections::HashMap;
1515
16−#[cfg_attr(feature = "debug", derive(Debug))]
17−#[derive(Copy, Clone, PartialEq, Eq, Hash)]
16+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1817pub enum Mode {
1918 Normal,
2019 Select,
@@ -53,9 +52,7 @@ pub struct Document {
5352 language_server: Option<Arc<helix_lsp::Client>>,
5453}
5554
56−#[cfg(feature = "debug")]
5755use std::fmt;
58−#[cfg(feature = "debug")]
5956impl fmt::Debug for Document {
6057 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6158 f.debug_struct("Document")
@@ -74,7 +71,7 @@ impl fmt::Debug for Document {
7471 .field("version", &self.version)
7572 .field("diagnostics", &self.diagnostics)
7673 // .field("language_server", &self.language_server)
77− .finish_non_exhaustive()
74+ .finish()
7875 }
7976}
8077
helix-view/src/editor.rs+2−3
@@ -9,7 +9,7 @@ use anyhow::Error;
99
1010pub use helix_core::diagnostic::Severity;
1111
12−#[cfg_attr(feature = "debug", derive(Debug))]
12+#[derive(Debug)]
1313pub struct Editor {
1414 pub tree: Tree,
1515 pub documents: SlotMap<DocumentId, Document>,
@@ -21,8 +21,7 @@ pub struct Editor {
2121 pub status_msg: Option<(String, Severity)>,
2222}
2323
24−#[cfg_attr(feature = "debug", derive(Debug))]
25−#[derive(Copy, Clone)]
24+#[derive(Debug, Copy, Clone)]
2625pub enum Action {
2726 Replace,
2827 HorizontalSplit,
helix-view/src/tree.rs+6−7
@@ -4,7 +4,7 @@ use tui::layout::Rect;
44
55// the dimensions are recomputed on windo resize/tree change.
66//
7−#[cfg_attr(feature = "debug", derive(Debug))]
7+#[derive(Debug)]
88pub struct Tree {
99 root: ViewId,
1010 // (container, index inside the container)
@@ -18,13 +18,13 @@ pub struct Tree {
1818 stack: Vec<(ViewId, Rect)>,
1919}
2020
21−#[cfg_attr(feature = "debug", derive(Debug))]
21+#[derive(Debug)]
2222pub struct Node {
2323 parent: ViewId,
2424 content: Content,
2525}
2626
27−#[cfg_attr(feature = "debug", derive(Debug))]
27+#[derive(Debug)]
2828pub enum Content {
2929 View(Box<View>),
3030 Container(Box<Container>),
@@ -48,15 +48,14 @@ impl Node {
4848
4949// TODO: screen coord to container + container coordinate helpers
5050
51−#[cfg_attr(feature = "debug", derive(Debug))]
52−#[derive(PartialEq, Eq)]
51+#[derive(Debug, PartialEq, Eq)]
5352pub enum Layout {
5453 Horizontal,
5554 Vertical,
5655 // could explore stacked/tabbed
5756}
5857
59−#[cfg_attr(feature = "debug", derive(Debug))]
58+#[derive(Debug)]
6059pub struct Container {
6160 layout: Layout,
6261 children: Vec<ViewId>,
@@ -437,7 +436,7 @@ impl Tree {
437436 }
438437}
439438
440−#[cfg_attr(feature = "debug", derive(Debug))]
439+#[derive(Debug)]
441440pub struct Traverse<'a> {
442441 tree: &'a Tree,
443442 stack: Vec<ViewId>, // TODO: reuse the one we use on update
helix-view/src/view.rs+2−2
@@ -12,7 +12,7 @@ pub const PADDING: usize = 5;
1212
1313type Jump = (DocumentId, Selection);
1414
15−#[cfg_attr(feature = "debug", derive(Debug))]
15+#[derive(Debug)]
1616pub struct JumpList {
1717 jumps: Vec<Jump>,
1818 current: usize,
@@ -59,7 +59,7 @@ impl JumpList {
5959 }
6060}
6161
62−#[cfg_attr(feature = "debug", derive(Debug))]
62+#[derive(Debug)]
6363pub struct View {
6464 pub id: ViewId,
6565 pub doc: DocumentId,