Auto merge of #54810 - 1aim:unused-impl-trait, r=oli-obk
Fix dead code lint for functions using impl Trait Fixes https://github.com/rust-lang/rust/issues/54754 This is a minimal fix that doesn't add any new queries or touches unnecessary code. Please nominate for beta backport if wanted.
This commit is contained in:
commit
b2d6ea98b0
@ -398,7 +398,13 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
krate: &hir::Crate)
|
||||
-> Vec<ast::NodeId>
|
||||
{
|
||||
let worklist = access_levels.map.iter().map(|(&id, _)| id).chain(
|
||||
let worklist = access_levels.map.iter().filter_map(|(&id, level)| {
|
||||
if level >= &privacy::AccessLevel::Reachable {
|
||||
Some(id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).chain(
|
||||
// Seed entry point
|
||||
tcx.sess.entry_fn.borrow().map(|(id, _, _)| id)
|
||||
).collect::<Vec<_>>();
|
||||
|
@ -170,6 +170,7 @@ macro_rules! test_with_borrow {
|
||||
async_closure,
|
||||
async_fn,
|
||||
async_fn_with_internal_borrow,
|
||||
Foo::async_method,
|
||||
|x| {
|
||||
async move {
|
||||
unsafe { await!(unsafe_async_fn(x)) }
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
// compile-pass
|
||||
|
||||
fn main() {}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
// compile-pass
|
||||
|
||||
use std::iter::once;
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
// compile-pass
|
||||
|
||||
// Tests for nested self-reference which caused a stack overflow.
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
// compile-pass
|
||||
fn iter<'a>(data: &'a [usize]) -> impl Iterator<Item = usize> + 'a {
|
||||
data.iter()
|
||||
.map(
|
@ -109,6 +109,10 @@ fn bar() { //~ ERROR: function is never used
|
||||
foo();
|
||||
}
|
||||
|
||||
fn baz() -> impl Copy { //~ ERROR: function is never used
|
||||
"I'm unused, too"
|
||||
}
|
||||
|
||||
// Code with #[allow(dead_code)] should be marked live (and thus anything it
|
||||
// calls is marked live)
|
||||
#[allow(dead_code)]
|
||||
|
@ -58,5 +58,11 @@ error: function is never used: `bar`
|
||||
LL | fn bar() { //~ ERROR: function is never used
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error: function is never used: `baz`
|
||||
--> $DIR/lint-dead-code-1.rs:112:1
|
||||
|
|
||||
LL | fn baz() -> impl Copy { //~ ERROR: function is never used
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
// compile-pass
|
||||
// #39665
|
||||
|
||||
fn batches(n: &u32) -> impl Iterator<Item=&u32> {
|
Loading…
Reference in New Issue
Block a user