Skip to content
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

Rollup of 11 pull requests #84899

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 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
e40faef
Deduplicate native libs before they are passed to the linker
ChrisDenton May 1, 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
2e559c8
use `else if` in std library
wcampbell0x2a 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
f84b4c5
Valid underscores in hex/octal/binary literal docs
syvb Apr 8, 2021
df4d22a
Rollup merge of #83004 - sunjay:field-never-read-issue-81658, r=pnkfelix
Dylan-DPC May 4, 2021
cab0020
Rollup merge of #83553 - jfrimmel:addr-of, r=m-ou-se
Dylan-DPC May 4, 2021
b08f9c9
Rollup merge of #84017 - Smittyvb:int-literal-underscores, r=jyn514
Dylan-DPC May 4, 2021
12deb2b
Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkov
Dylan-DPC May 4, 2021
0f0b7c7
Rollup merge of #84468 - iladin:iladin/fix-84467, r=petrochenkov
Dylan-DPC May 4, 2021
a1a0e8c
Rollup merge of #84712 - joshtriplett:simplify-chdir, r=yaahc
Dylan-DPC May 4, 2021
355f19a
Rollup merge of #84794 - ChrisDenton:dedup-native-libs, r=petrochenkov
Dylan-DPC May 4, 2021
438bf55
Rollup merge of #84797 - richkadel:cover-unreachable-statements, r=tm…
Dylan-DPC May 4, 2021
4a410d4
Rollup merge of #84803 - jyn514:duplicate-macros, r=petrochenkov
Dylan-DPC May 4, 2021
eb5ee09
Rollup merge of #84808 - estebank:issue-84769, r=petrochenkov
Dylan-DPC May 4, 2021
7e3cb45
Rollup merge of #84843 - wcampbell0x2a:use-else-if-let, r=dtolnay
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`.