Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8a2e67e
Simplify chdir implementation and minimize unsafe block
joshtriplett Apr 29, 2021
fe68b1a
Fix linker_args with --target=sparcv9-sun-solaris
iladin Apr 30, 2021
0b0d293
Report coverage `0` of dead blocks
richkadel May 1, 2021
3fca198
Move coverage tests from run-make-fulldeps to run-make
richkadel May 1, 2021
dd43d13
Reduce duplication in `impl_dep_tracking_hash` macros
jyn514 Apr 22, 2021
1e89b58
Account for unsatisfied bounds in E0599
estebank May 2, 2021
367c1db
:arrow_up: rust-analyzer
lnicola May 3, 2021
2e559c8
use `else if` in std library
wcampbell0x2a May 3, 2021
b4bfb0e
Update RELEASES.md for 1.52.0
XAMPPRocky Apr 14, 2021
03c763e
manually crafted revert of PR #80653, to address issue #82465.
pnkfelix May 3, 2021
86e3f76
regression test for issue 82465.
pnkfelix May 3, 2021
6eb4735
Unify rustc and rustdoc parsing of `cfg()`
jyn514 Apr 22, 2021
389333a
Update `ptr` docs with regards to `ptr::addr_of!`
jfrimmel Mar 27, 2021
450d121
Tests for field is never read diagnostic
sunjay Mar 11, 2021
67f228e
Added suggestion and note for when a field is never used
sunjay Mar 12, 2021
715a2d4
Updating test stderr files
sunjay Mar 12, 2021
d4c1ade
Trying out a new message that works a little better for values *and* …
sunjay Mar 12, 2021
bacfc34
New shorter diagnostic note that is different for items versus fields
sunjay Mar 13, 2021
0ba2c6a
Putting help message only under the identifier that needs to be prefixed
sunjay Mar 25, 2021
c4b1dda
Rollup merge of #83004 - sunjay:field-never-read-issue-81658, r=pnkfelix
Dylan-DPC May 4, 2021
c0bd4b1
Rollup merge of #83553 - jfrimmel:addr-of, r=m-ou-se
Dylan-DPC May 4, 2021
e5351f2
Rollup merge of #84183 - rust-lang:relnotes-1.52.0, r=pietroalbini
Dylan-DPC May 4, 2021
eb45cff
Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkov
Dylan-DPC May 4, 2021
6120214
Rollup merge of #84468 - iladin:iladin/fix-84467, r=petrochenkov
Dylan-DPC May 4, 2021
12699ab
Rollup merge of #84712 - joshtriplett:simplify-chdir, r=yaahc
Dylan-DPC May 4, 2021
5d5ba5a
Rollup merge of #84797 - richkadel:cover-unreachable-statements, r=tm…
Dylan-DPC May 4, 2021
89f38a0
Rollup merge of #84803 - jyn514:duplicate-macros, r=petrochenkov
Dylan-DPC May 4, 2021
7ac6a01
Rollup merge of #84808 - estebank:issue-84769, r=petrochenkov
Dylan-DPC May 4, 2021
ba2e809
Rollup merge of #84843 - wcampbell0x2a:use-else-if-let, r=dtolnay
Dylan-DPC May 4, 2021
cfa2c21
Rollup merge of #84851 - lnicola:rust-analyzer-2021-05-03, r=jonas-sc…
Dylan-DPC May 4, 2021
12a95b0
Rollup merge of #84867 - pnkfelix:rustdoc-revert-deref-recur, r=jyn514
Dylan-DPC May 4, 2021
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
Account for unsatisfied bounds in E0599
Fix #84769, follow up to #84499, #83667.
  • Loading branch information
estebank committed May 2, 2021
commit 1e89b583c3bcf1757f57250a089450165e886049
6 changes: 5 additions & 1 deletion compiler/rustc_typeck/src/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

let mut restrict_type_params = false;
let mut unsatisfied_bounds = false;
if !unsatisfied_predicates.is_empty() {
let def_span = |def_id| {
self.tcx.sess.source_map().guess_head_span(self.tcx.def_span(def_id))
Expand Down Expand Up @@ -739,6 +740,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.note(&format!(
"the following trait bounds were not satisfied:\n{bound_list}"
));
unsatisfied_bounds = true;
}
}

Expand All @@ -752,6 +754,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source,
out_of_scope_traits,
&unsatisfied_predicates,
unsatisfied_bounds,
);
}

Expand Down Expand Up @@ -984,9 +987,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source: SelfSource<'tcx>,
valid_out_of_scope_traits: Vec<DefId>,
unsatisfied_predicates: &[(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)],
unsatisfied_bounds: bool,
) {
let mut alt_rcvr_sugg = false;
if let SelfSource::MethodCall(rcvr) = source {
if let (SelfSource::MethodCall(rcvr), false) = (source, unsatisfied_bounds) {
debug!(?span, ?item_name, ?rcvr_ty, ?rcvr);
let skippable = [
self.tcx.lang_items().clone_trait(),
Expand Down
9 changes: 8 additions & 1 deletion src/test/ui/suggestions/import-trait-for-method-call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ fn next_u64() -> u64 {
h.finish() //~ ERROR no method named `finish` found for struct `DefaultHasher`
}

fn main() {}
trait Bar {}
impl Bar for String {}

fn main() {
let s = String::from("hey");
let x: &dyn Bar = &s;
x.as_ref(); //~ ERROR the method `as_ref` exists for reference `&dyn Bar`, but its trait bounds
}
18 changes: 17 additions & 1 deletion src/test/ui/suggestions/import-trait-for-method-call.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ help: the following trait is implemented but not in scope; perhaps add a `use` f
LL | use std::hash::Hasher;
|

error: aborting due to previous error
error[E0599]: the method `as_ref` exists for reference `&dyn Bar`, but its trait bounds were not satisfied
--> $DIR/import-trait-for-method-call.rs:15:7
|
LL | trait Bar {}
| --------- doesn't satisfy `dyn Bar: AsRef<_>`
...
LL | x.as_ref();
| ^^^^^^ method cannot be called on `&dyn Bar` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`dyn Bar: AsRef<_>`
which is required by `&dyn Bar: AsRef<_>`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `as_ref`, perhaps you need to implement it:
candidate #1: `AsRef`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0599`.