Skip to content

Commit 58a2851

Browse files
committed
Reword expects
1 parent e66144e commit 58a2851

File tree

23 files changed

+47
-44
lines changed

23 files changed

+47
-44
lines changed

crates/analysis/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ where
7878
if !ignore_after_syntax || !has_any_error {
7979
ret.extend(file.statics_errors.iter().filter_map(|err| {
8080
let idx = err.idx();
81-
let syntax = file.syntax.lower.ptrs.hir_to_ast(idx).expect("no pointer for idx");
81+
let syntax = file.syntax.lower.ptrs.hir_to_ast(idx).expect("should have a pointer for idx");
8282
let node = syntax.to_node(file.syntax.parse.root.syntax());
8383
let range = f(&file.syntax.pos_db, sml_syntax::node_range(&node))?;
8484
let message = err.display(syms_tys, options.lines).to_string();

crates/analysis/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Analysis {
9090
std::iter::empty()
9191
.chain(res.mlb_errors.into_iter().filter_map(|err| {
9292
let path = err.path();
93-
let group = input.groups.get(&path).expect("no such group");
93+
let group = input.groups.get(&path).expect("should have a group for path");
9494
let err = Diagnostic {
9595
range: f(&group.pos_db, err.range())?,
9696
message: err.to_string(),
@@ -124,8 +124,8 @@ impl Analysis {
124124
///
125125
/// If we couldn't find the source file for this path.
126126
pub fn update_one(&mut self, input: &input::Input, path: paths::PathId) {
127-
let source_file = self.source_files.get_mut(&path).expect("no source file");
128-
let contents = input.sources.get(&path).expect("no contents");
127+
let source_file = self.source_files.get_mut(&path).expect("should have a source file for path");
128+
let contents = input.sources.get(&path).expect("should have source for path");
129129
mlb_statics::update_one(&mut self.syms_tys, &input.lang, source_file, path, contents);
130130
}
131131

crates/input/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Input {
5050
ret.lang = root.config.lang;
5151
for group in root.groups {
5252
let path = paths.get_path(group.path).as_path();
53-
let parent = path.parent().expect("group path with no parent");
53+
let parent = path.parent().expect("should have parent for group path");
5454
let parent = match util::str_path(ErrorSource::default(), parent) {
5555
Ok(x) => x,
5656
Err(e) => {

crates/input/src/lower_cm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ where
315315
F: paths::FileSystem,
316316
{
317317
for (path_id, _) in cx.sml_paths {
318-
let contents = st.sources.get(path_id).expect("sml file should be set").as_str();
318+
let contents = st.sources.get(path_id).expect("should have sml contents for path").as_str();
319319
get_top_defs(contents, ac, range);
320320
}
321321
}
@@ -352,7 +352,7 @@ fn extend_with<F>(st: &mut St<'_, F>, path: paths::PathId, range: TextRange, ac:
352352
where
353353
F: paths::FileSystem,
354354
{
355-
let other = st.cm_files.get(&path).expect("cm file should be set after successful get_one");
355+
let other = st.cm_files.get(&path).expect("should set cm file after successful get_one");
356356
ac.extend(other.exports.keys().map(|ex| (ex.clone(), range)));
357357
}
358358

crates/input/src/root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn disallow(
198198
continue;
199199
};
200200
if !allowed {
201-
let p = sml_path::Path::try_new(parts).expect("split always returns non-empty iter");
201+
let p = sml_path::Path::try_new(parts).expect("should not get empty iter from split");
202202
set.insert(p);
203203
}
204204
}

crates/input/src/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ pub(crate) fn get_path_id_in_group(
199199
path: Some(group.path.as_path().to_owned()),
200200
range: group.pos_db.range_utf16(range),
201201
};
202-
let path = group.path.as_clean_path().parent().expect("group path with no parent").join(path);
202+
let path =
203+
group.path.as_clean_path().parent().expect("should have parent for group path").join(path);
203204
let id = paths.get_id(path.as_clean_path());
204205
(id, path, source)
205206
}

crates/lang-srv/src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) fn diagnostics(
3434
}
3535

3636
pub(crate) fn error_url(code: diagnostic::Code) -> Url {
37-
Url::parse(&format!("{}/{code}.md", analysis::URL)).expect("couldn't parse diagnostic URL")
37+
Url::parse(&format!("{}/{code}.md", analysis::URL)).expect("should parse diagnostic URL")
3838
}
3939

4040
struct ClickCodeHint {

crates/millet-cli/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ impl<'a> codespan_reporting::files::Files<'a> for Files<'a> {
216216
if end.line > file_end.line || end.line == file_end.line && end.col > file_end.col {
217217
end = file_end;
218218
}
219-
let tr =
220-
db.text_range_utf16(text_pos::RangeUtf16 { start, end }).expect("line range out of range");
219+
let tr = db
220+
.text_range_utf16(text_pos::RangeUtf16 { start, end })
221+
.expect("should have line range be in range");
221222
Ok(tr.into())
222223
}
223224
}

crates/mlb-statics/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ fn get_bas_dec(
245245
},
246246
mlb_hir::BasDec::Path(path, kind) => match kind {
247247
mlb_hir::PathKind::Source(file_kind) => {
248-
let contents = cx.source_file_contents.get(path).expect("no source file");
248+
let contents = cx.source_file_contents.get(path).expect("should have source file for path");
249249
let mut fix_env = scope.fix_env.clone();
250250
let syntax = SourceFileSyntax::new(&mut fix_env, cx.lang, *file_kind, contents);
251251
get_source_file(st, cx.lang, *path, scope, ac, fix_env, syntax);
@@ -259,7 +259,8 @@ fn get_bas_dec(
259259
let mut syntaxes: paths::PathMap<_> = paths
260260
.iter()
261261
.map(|&(path, kind)| {
262-
let contents = cx.source_file_contents.get(&path).expect("no source file");
262+
let contents =
263+
cx.source_file_contents.get(&path).expect("should have source file for path");
263264
let mut fix_env = scope.fix_env.clone();
264265
let syntax = SourceFileSyntax::new(&mut fix_env, cx.lang, kind, contents);
265266
(path, (fix_env, syntax))
@@ -278,7 +279,8 @@ fn get_bas_dec(
278279
let mut scope = scope.clone();
279280
for path in order {
280281
let mut one_m_basis = MBasis::default();
281-
let (fix_env, syntax) = syntaxes.remove(&path).expect("path from order is in syntaxes");
282+
let (fix_env, syntax) =
283+
syntaxes.remove(&path).expect("should have path from order be present");
282284
get_source_file(st, cx.lang, path, &scope, &mut one_m_basis, fix_env, syntax);
283285
scope.append(one_m_basis.clone());
284286
ac.append(one_m_basis);
@@ -371,7 +373,7 @@ pub fn add_all_doc_comments(
371373
.chain(low.arenas.str_dec.iter().map(|(x, _)| sml_hir::Idx::StrDec(x)))
372374
.chain(low.arenas.spec.iter().map(|(x, _)| sml_hir::Idx::Spec(x)));
373375
for idx in indices {
374-
let ptr = low.ptrs.hir_to_ast(idx).expect("no syntax ptr");
376+
let ptr = low.ptrs.hir_to_ast(idx).expect("should have syntax ptr");
375377
let node = ptr.to_node(root);
376378
if let Some(doc) = sml_comment::doc_comment_above(&node) {
377379
info.add_doc(idx, doc);

crates/sml-dynamics-tests/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ fn check(s: &str, steps: &[&str]) {
4444
bind,
4545
match_,
4646
};
47-
let mut dynamics = sml_dynamics::Dynamics::new(cx, sf.lower.root.clone()).expect("no str decs");
47+
let mut dynamics =
48+
sml_dynamics::Dynamics::new(cx, sf.lower.root.clone()).expect("should have str decs");
4849
let mut stdin = std::io::stdin().lock();
4950
let mut buf = String::new();
5051
let mut steps = steps.iter();
@@ -59,11 +60,11 @@ fn check(s: &str, steps: &[&str]) {
5960
println!("{dynamics:#}");
6061
}
6162
if manually_advance {
62-
stdin.read_line(&mut buf).expect("couldn't read");
63+
stdin.read_line(&mut buf).expect("should be able to read line");
6364
buf.clear();
6465
}
6566
if check_steps {
66-
let want = rm_whitespace(steps.next().expect("missing step").trim());
67+
let want = rm_whitespace(steps.next().expect("should not be missing step").trim());
6768
let got = rm_whitespace(&dynamics.to_string());
6869
pretty_assertions::assert_str_eq!(want, got);
6970
}

0 commit comments

Comments
 (0)