Skip to content

Rollup of 8 pull requests #103727

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 26 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
47703d3
compiletest: refactor rustcflags to Vec
andrewpollack Oct 3, 2022
4216cae
filter candidates in pick probe for diagnostics
compiler-errors Oct 22, 2022
e521a8d
Prevent foreign Rust exceptions from being caught
nbdd0121 Oct 5, 2022
86c65d2
Implement Rust foreign exception protection for EMCC and SEH
nbdd0121 Oct 5, 2022
daf3063
Add test case for foreign Rust exceptions
nbdd0121 Oct 5, 2022
979d1a2
Apply suggestion
nbdd0121 Oct 11, 2022
4e6d60c
Fix alloc size
nbdd0121 Oct 12, 2022
c9cca33
Fix windows compilation
nbdd0121 Oct 23, 2022
f01608c
Update src/tools/compiletest/src/runtest.rs
andrewpollack Oct 24, 2022
a17ccfa
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions
WaffleLapkin Oct 27, 2022
dc53c8f
Update tooling
WaffleLapkin Oct 27, 2022
c8c4971
Update miri
WaffleLapkin Oct 27, 2022
bfac2da
Ignore test on mingw32
nbdd0121 Oct 26, 2022
c442013
Emit proper error when casting to Ddyn-star
compiler-errors Oct 28, 2022
4b35313
fix typo in hashmap and hashset try_reserve method
joseluis Oct 29, 2022
c8c25ce
Rename some `OwnerId` fields.
nnethercote Oct 27, 2022
f0234f1
Add missing impl blocks for item reexported from private mod in JSON …
GuillaumeGomez Oct 27, 2022
0ef36b8
Add regression test for missing item from private mod in JSON output
GuillaumeGomez Oct 27, 2022
73e7c3a
Rollup merge of #102634 - andrewpollack:refactor-test-rustcflags, r=M…
GuillaumeGomez Oct 29, 2022
6dd64d3
Rollup merge of #102721 - nbdd0121:panic, r=Amanieu
GuillaumeGomez Oct 29, 2022
07b5c6b
Rollup merge of #103415 - compiler-errors:tiny-perf-increase-on-diagn…
GuillaumeGomez Oct 29, 2022
692a22e
Rollup merge of #103618 - nnethercote:rename-OwnerId-fields, r=compil…
GuillaumeGomez Oct 29, 2022
2414a4c
Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=comp…
GuillaumeGomez Oct 29, 2022
05ab16b
Rollup merge of #103653 - GuillaumeGomez:missing-impl-private-json, r…
GuillaumeGomez Oct 29, 2022
679771f
Rollup merge of #103699 - compiler-errors:dyn-star-cast-bad, r=TaKO8Ki
GuillaumeGomez Oct 29, 2022
6425764
Rollup merge of #103719 - joseluis:fix-typos-try-reserve, r=the8472
GuillaumeGomez Oct 29, 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
41 changes: 23 additions & 18 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,24 +530,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
checked_ty: Ty<'tcx>,
hir_id: hir::HirId,
) -> Vec<AssocItem> {
let mut methods =
self.probe_for_return_type(span, probe::Mode::MethodCall, expected, checked_ty, hir_id);
methods.retain(|m| {
self.has_only_self_parameter(m)
&& self
.tcx
// This special internal attribute is used to permit
// "identity-like" conversion methods to be suggested here.
//
// FIXME (#46459 and #46460): ideally
// `std::convert::Into::into` and `std::borrow:ToOwned` would
// also be `#[rustc_conversion_suggestion]`, if not for
// method-probing false-positives and -negatives (respectively).
//
// FIXME? Other potential candidate methods: `as_ref` and
// `as_mut`?
.has_attr(m.def_id, sym::rustc_conversion_suggestion)
});
let methods = self.probe_for_return_type(
span,
probe::Mode::MethodCall,
expected,
checked_ty,
hir_id,
|m| {
self.has_only_self_parameter(m)
&& self
.tcx
// This special internal attribute is used to permit
// "identity-like" conversion methods to be suggested here.
//
// FIXME (#46459 and #46460): ideally
// `std::convert::Into::into` and `std::borrow:ToOwned` would
// also be `#[rustc_conversion_suggestion]`, if not for
// method-probing false-positives and -negatives (respectively).
//
// FIXME? Other potential candidate methods: `as_ref` and
// `as_mut`?
.has_attr(m.def_id, sym::rustc_conversion_suggestion)
},
);

methods
}
Expand Down
13 changes: 9 additions & 4 deletions compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// would result in an error (basically, the same criteria we
/// would use to decide if a method is a plausible fit for
/// ambiguity purposes).
#[instrument(level = "debug", skip(self))]
#[instrument(level = "debug", skip(self, candidate_filter))]
pub fn probe_for_return_type(
&self,
span: Span,
mode: Mode,
return_type: Ty<'tcx>,
self_ty: Ty<'tcx>,
scope_expr_id: hir::HirId,
candidate_filter: impl Fn(&ty::AssocItem) -> bool,
) -> Vec<ty::AssocItem> {
let method_names = self
.probe_op(
Expand All @@ -271,7 +272,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self_ty,
scope_expr_id,
ProbeScope::AllTraits,
|probe_cx| Ok(probe_cx.candidate_method_names()),
|probe_cx| Ok(probe_cx.candidate_method_names(candidate_filter)),
)
.unwrap_or_default();
method_names
Expand Down Expand Up @@ -966,12 +967,16 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
}
}

fn candidate_method_names(&self) -> Vec<Ident> {
fn candidate_method_names(
&self,
candidate_filter: impl Fn(&ty::AssocItem) -> bool,
) -> Vec<Ident> {
let mut set = FxHashSet::default();
let mut names: Vec<_> = self
.inherent_candidates
.iter()
.chain(&self.extension_candidates)
.filter(|candidate| candidate_filter(&candidate.item))
.filter(|candidate| {
if let Some(return_ty) = self.return_type {
self.matches_return_type(&candidate.item, None, return_ty)
Expand Down Expand Up @@ -1689,7 +1694,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
pcx.allow_similar_names = true;
pcx.assemble_inherent_candidates();

let method_names = pcx.candidate_method_names();
let method_names = pcx.candidate_method_names(|_| true);
pcx.allow_similar_names = false;
let applicable_close_candidates: Vec<ty::AssocItem> = method_names
.iter()
Expand Down