Skip to content

Rollup of 6 pull requests #103344

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

Merged
merged 20 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6d947e6
Account for hygiene when suggesting typos.
cjgillot Oct 16, 2022
4bbb163
Point to shadowed name when it exists.
cjgillot Oct 16, 2022
7fbaf27
macros: support doc comments in diag derives
davidtwco Oct 14, 2022
1045e69
macros: allow subdiagnostic-kind-less variants
davidtwco Oct 14, 2022
feeeb11
macros: fully specify path to `Fn`
davidtwco Oct 14, 2022
2a4b587
ast_lowering: use derive more
davidtwco Oct 14, 2022
ea5d258
ast_passes: use derive more
davidtwco Oct 14, 2022
21d3bbd
lint: use derive more
davidtwco Oct 14, 2022
f8b628b
session: use derive more
davidtwco Oct 14, 2022
913f597
infer: use derive more
davidtwco Oct 14, 2022
f8e157b
Fixup a few tests needing asm support
cuviper Oct 19, 2022
28d0312
Implement assertions and fixes to not emit empty spans without sugges…
kper Oct 11, 2022
8509819
Elaborate supertrait bounds when triggering unused_must_use on impl T…
compiler-errors Sep 25, 2022
f6dd470
rustdoc: improve appearance of source page navigation bar
notriddle Oct 20, 2022
66d91d8
Rollup merge of #102287 - compiler-errors:unused-must-use-also-supert…
Dylan-DPC Oct 21, 2022
0a0e9f7
Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obk
Dylan-DPC Oct 21, 2022
e11511d
Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compile…
Dylan-DPC Oct 21, 2022
41a1cfd
Rollup merge of #103111 - cjgillot:shadow-label, r=estebank
Dylan-DPC Oct 21, 2022
3055eb9
Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-dead
Dylan-DPC Oct 21, 2022
325e920
Rollup merge of #103321 - notriddle:notriddle/source-page-top-bar-lay…
Dylan-DPC Oct 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Elaborate supertrait bounds when triggering unused_must_use on impl T…
…rait
  • Loading branch information
compiler-errors committed Oct 20, 2022
commit 8509819aef02c28c3f636dc04ad7b6087f7dc334
8 changes: 6 additions & 2 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rustc_errors::{fluent, pluralize, Applicability, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_infer::traits::util::elaborate_predicates_with_span;
use rustc_middle::ty::adjustment;
use rustc_middle::ty::{self, Ty};
use rustc_span::symbol::Symbol;
Expand Down Expand Up @@ -204,10 +205,13 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
ty::Adt(def, _) => check_must_use_def(cx, def.did(), span, descr_pre, descr_post),
ty::Opaque(def, _) => {
let mut has_emitted = false;
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
for obligation in elaborate_predicates_with_span(
cx.tcx,
cx.tcx.explicit_item_bounds(def).iter().cloned(),
) {
// We only look at the `DefId`, so it is safe to skip the binder here.
if let ty::PredicateKind::Trait(ref poly_trait_predicate) =
predicate.kind().skip_binder()
obligation.predicate.kind().skip_binder()
{
let def_id = poly_trait_predicate.trait_ref.def_id;
let descr_pre =
Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/lint/unused/unused-supertrait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![deny(unused_must_use)]

fn it() -> impl ExactSizeIterator<Item = ()> {
let x: Box<dyn ExactSizeIterator<Item = ()>> = todo!();
x
}

fn main() {
it();
//~^ ERROR unused implementer of `Iterator` that must be used
}
15 changes: 15 additions & 0 deletions src/test/ui/lint/unused/unused-supertrait.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: unused implementer of `Iterator` that must be used
--> $DIR/unused-supertrait.rs:9:5
|
LL | it();
| ^^^^^
|
= note: iterators are lazy and do nothing unless consumed
note: the lint level is defined here
--> $DIR/unused-supertrait.rs:1:9
|
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^

error: aborting due to previous error