Skip to content

Commit d65444f

Browse files
committed
fixup warnings around the compiler
1 parent 699184b commit d65444f

File tree

10 files changed

+23
-16
lines changed

10 files changed

+23
-16
lines changed

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ impl MetadataLoader for DefaultMetadataLoader {
8686
format!("failed to parse aix dylib '{}': {}", path.display(), e)
8787
})?;
8888

89-
match archive.members().exactly_one() {
89+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
90+
match Itertools::exactly_one(archive.members()) {
9091
Ok(lib) => {
9192
let lib = lib.map_err(|e| {
9293
format!("failed to parse aix dylib '{}': {}", path.display(), e)

src/librustdoc/html/format.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,8 @@ pub(crate) fn print_impl(
11261126
}
11271127
if impl_.kind.is_fake_variadic()
11281128
&& let Some(generics) = ty.generics()
1129-
&& let Ok(inner_type) = generics.exactly_one()
1129+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
1130+
&& let Ok(inner_type) = Itertools::exactly_one(generics)
11301131
{
11311132
let last = ty.last();
11321133
if f.alternate() {
@@ -1206,7 +1207,8 @@ impl clean::Impl {
12061207
}
12071208
} else if let clean::Type::Path { path } = type_
12081209
&& let Some(generics) = path.generics()
1209-
&& let Ok(ty) = generics.exactly_one()
1210+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
1211+
&& let Ok(ty) = Itertools::exactly_one(generics)
12101212
&& self.kind.is_fake_variadic()
12111213
{
12121214
print_anchor(path.def_id(), path.last(), cx).fmt(f)?;

src/tools/clippy/clippy_lints/src/manual_non_exhaustive.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
9292
(matches!(v.data, VariantData::Unit(_, _)) && is_doc_hidden(cx.tcx.hir_attrs(v.hir_id)))
9393
.then_some((v.def_id, v.span))
9494
});
95-
if let Ok((id, span)) = iter.exactly_one()
95+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
96+
if let Ok((id, span)) = Itertools::exactly_one(iter)
9697
&& !find_attr!(cx.tcx.hir_attrs(item.hir_id()), AttributeKind::NonExhaustive(..))
9798
{
9899
self.potential_enums.push((item.owner_id.def_id, id, item.span, span));
@@ -104,7 +105,8 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustive {
104105
.iter()
105106
.filter(|field| !cx.effective_visibilities.is_exported(field.def_id));
106107
if fields.len() > 1
107-
&& let Ok(field) = private_fields.exactly_one()
108+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
109+
&& let Ok(field) = Itertools::exactly_one(private_fields)
108110
&& let TyKind::Tup([]) = field.ty.kind
109111
{
110112
span_lint_and_then(

src/tools/rust-analyzer/crates/hir-expand/src/builtin/fn_macro.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ fn parse_string(tt: &tt::TopSubtree) -> Result<(Symbol, Span), ExpandError> {
786786
&& let DelimiterKind::Parenthesis | DelimiterKind::Invisible = sub.delimiter.kind
787787
{
788788
tt =
789-
tt_iter.exactly_one().map_err(|_| sub.delimiter.open.cover(sub.delimiter.close))?;
789+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
790+
Itertools::exactly_one(tt_iter).map_err(|_| sub.delimiter.open.cover(sub.delimiter.close))?;
790791
}
791792

792793
match tt {

src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_bool_then.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ pub(crate) fn convert_bool_then_to_if(acc: &mut Assists, ctx: &AssistContext<'_>
163163
let name_ref = ctx.find_node_at_offset::<ast::NameRef>()?;
164164
let mcall = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast)?;
165165
let receiver = mcall.receiver()?;
166-
let closure_body = mcall.arg_list()?.args().exactly_one().ok()?;
166+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
167+
let closure_body = Itertools::exactly_one(mcall.arg_list()?.args()).ok()?;
167168
let closure_body = match closure_body {
168169
ast::Expr::ClosureExpr(expr) => expr.body()?,
169170
_ => return None,

src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_range_for_to_while.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn extract_range(iterable: &ast::Expr) -> Option<(ast::Expr, Option<ast::Expr>,
113113
(range.start()?, range.end(), make::expr_literal("1").into(), inclusive)
114114
}
115115
ast::Expr::MethodCallExpr(call) if call.name_ref()?.text() == "step_by" => {
116-
let [step] = call.arg_list()?.args().collect_array()?;
116+
let [step] = Itertools::collect_array(call.arg_list()?.args())?;
117117
let (start, end, _, inclusive) = extract_range(&call.receiver()?)?;
118118
(start, end, step, inclusive)
119119
}

src/tools/rust-analyzer/crates/ide-completion/src/tests/raw_identifiers.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ fn check(#[rust_analyzer::rust_fixture] ra_fixture: &str, expect: Expect) {
88
let completions = completion_list_with_config_raw(TEST_CONFIG, ra_fixture, true, None);
99
let (db, position) = position(ra_fixture);
1010
let mut actual = db.file_text(position.file_id).text(&db).to_string();
11-
completions
12-
.into_iter()
13-
.exactly_one()
11+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
12+
Itertools::exactly_one(completions.into_iter())
1413
.expect("more than one completion")
1514
.text_edit
1615
.apply(&mut actual);

src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/support.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ impl Project<'_> {
113113
let mut buf = Vec::new();
114114
flags::Lsif::run(
115115
flags::Lsif {
116-
path: tmp_dir_path.join(self.roots.iter().exactly_one().unwrap()).into(),
116+
// FIXME: rewrite in terms of `#![feature(exact_length_collection)]`. See: #149266
117+
path: tmp_dir_path.join(Itertools::exactly_one(self.roots.iter()).unwrap()).into(),
117118
exclude_vendored_libraries: false,
118119
},
119120
&mut buf,

tests/ui/const-generics/type-dependent/issue-71805.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ where
3434

3535
fn main() {
3636
let mut foos = [0u64; 9].iter().cloned();
37-
let _bar: [u64; 9] = foos.collect_array::<9_usize>();
37+
let _bar: [u64; 9] = CollectSlice::collect_array::<9_usize>(foos);
3838
}

tests/ui/mir/mir-inlining/ice-issue-77564.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ where
2929

3030
fn main() {
3131
assert_eq!(
32-
[[1, 2], [3, 4]]
32+
CollectArray::collect_array([[1, 2], [3, 4]]
3333
.iter()
34-
.map(|row| row.iter().collect_array())
35-
.collect_array(),
34+
.map(|row| CollectArray::collect_array(row.iter()))
35+
),
3636
[[&1, &2], [&3, &4]]
3737
);
3838
}

0 commit comments

Comments
 (0)