Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d7152f8
Allow actual AVX512-related feature names in the case of some mislead…
calebzulawski Oct 30, 2022
1122400
Update compiler/rustc_codegen_llvm/src/llvm_util.rs
calebzulawski Nov 12, 2022
0b6dce4
Issue error when `-C link-self-contained` option is used on unsupport…
StackDoubleFlow Nov 8, 2022
83cc620
Flip a boolean that was used wrongly (has no effect though)
oli-obk Nov 9, 2022
44c4a7b
Remove an unnecessary `resolve_vars_if_possible`
oli-obk Nov 9, 2022
c3c3719
Remove some redundant span arguments
oli-obk Nov 9, 2022
e694ef5
Remove the fishy need for a PartialEq impl
oli-obk Nov 9, 2022
e656883
Pull the unstable name collision hint emission out of method probing
oli-obk Nov 11, 2022
d06aac1
Expose the fallibilty of the unstable lint emission in the method name
oli-obk Nov 14, 2022
e2fbd01
Compare picks via `Self` type and associated item id
oli-obk Nov 14, 2022
b7b6722
Only do parser recovery on retried macro matching
Noratrieb Nov 12, 2022
5649cbb
rustdoc: remove unused JS IIFE from main.js
notriddle Nov 15, 2022
74969ac
rustdoc: remove pointless CSS `.rightside { padding-right: 2px }`
notriddle Nov 15, 2022
7854883
rustdoc: remove no-op CSS `#crate-search-div { display: inline-block }`
notriddle Nov 15, 2022
1115ec6
cleanup and dedupe CTFE and Miri error reporting
RalfJung Nov 15, 2022
56a28a6
Rollup merge of #103750 - calebzulawski:master, r=workingjubilee
matthiaskrgr Nov 16, 2022
fbcd751
Rollup merge of #104137 - StackDoubleFlow:err-lsc-unsupported, r=bjorn3
matthiaskrgr Nov 16, 2022
353b915
Rollup merge of #104317 - RalfJung:ctfe-error-reporting, r=oli-obk
matthiaskrgr Nov 16, 2022
e033a38
Rollup merge of #104335 - Nilstrieb:macrowo, r=compiler-errors
matthiaskrgr Nov 16, 2022
163a709
Rollup merge of #104394 - oli-obk:suggest_method_call, r=lcnr
matthiaskrgr Nov 16, 2022
baf1cbb
Rollup merge of #104459 - notriddle:notriddle/main-js-iife, r=Guillau…
matthiaskrgr Nov 16, 2022
938948e
Rollup merge of #104462 - notriddle:notriddle/rightside-padding-right…
matthiaskrgr Nov 16, 2022
972ad00
Rollup merge of #104466 - notriddle:notriddle/crate-search-div-displa…
matthiaskrgr Nov 16, 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
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// method lookup.
let Ok(pick) = self
.probe_for_name(
call_expr.span,
Mode::MethodCall,
segment.ident,
IsSuggestion(true),
Expand Down
77 changes: 38 additions & 39 deletions compiler/rustc_hir_typeck/src/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_expr_id: hir::HirId,
allow_private: bool,
) -> bool {
let mode = probe::Mode::MethodCall;
match self.probe_for_name(
method_name.span,
mode,
probe::Mode::MethodCall,
method_name,
IsSuggestion(false),
self_ty,
call_expr_id,
ProbeScope::TraitsInScope,
) {
Ok(..) => true,
Ok(pick) => {
pick.maybe_emit_unstable_name_collision_hint(
self.tcx,
method_name.span,
call_expr_id,
);
true
}
Err(NoMatch(..)) => false,
Err(Ambiguity(..)) => true,
Err(PrivateMatch(..)) => allow_private,
Expand All @@ -125,10 +130,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) {
let params = self
.probe_for_name(
method_name.span,
probe::Mode::MethodCall,
method_name,
IsSuggestion(false),
IsSuggestion(true),
self_ty,
call_expr.hir_id,
ProbeScope::TraitsInScope,
Expand Down Expand Up @@ -175,7 +179,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
args: &'tcx [hir::Expr<'tcx>],
) -> Result<MethodCallee<'tcx>, MethodError<'tcx>> {
let pick =
self.lookup_probe(span, segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope)?;
self.lookup_probe(segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope)?;

self.lint_dot_call_from_2018(self_ty, segment, span, call_expr, self_expr, &pick, args);

Expand All @@ -200,42 +204,38 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.mk_ref(*region, ty::TypeAndMut { ty: *t_type, mutbl: mutability.invert() });
// We probe again to see if there might be a borrow mutability discrepancy.
match self.lookup_probe(
span,
segment.ident,
trait_type,
call_expr,
ProbeScope::TraitsInScope,
) {
Ok(ref new_pick) if *new_pick != pick => {
Ok(ref new_pick) if pick.differs_from(new_pick) => {
needs_mut = true;
}
_ => {}
}
}

// We probe again, taking all traits into account (not only those in scope).
let mut candidates = match self.lookup_probe(
span,
segment.ident,
self_ty,
call_expr,
ProbeScope::AllTraits,
) {
// If we find a different result the caller probably forgot to import a trait.
Ok(ref new_pick) if *new_pick != pick => vec![new_pick.item.container_id(self.tcx)],
Err(Ambiguity(ref sources)) => sources
.iter()
.filter_map(|source| {
match *source {
// Note: this cannot come from an inherent impl,
// because the first probing succeeded.
CandidateSource::Impl(def) => self.tcx.trait_id_of_impl(def),
CandidateSource::Trait(_) => None,
}
})
.collect(),
_ => Vec::new(),
};
let mut candidates =
match self.lookup_probe(segment.ident, self_ty, call_expr, ProbeScope::AllTraits) {
// If we find a different result the caller probably forgot to import a trait.
Ok(ref new_pick) if pick.differs_from(new_pick) => {
vec![new_pick.item.container_id(self.tcx)]
}
Err(Ambiguity(ref sources)) => sources
.iter()
.filter_map(|source| {
match *source {
// Note: this cannot come from an inherent impl,
// because the first probing succeeded.
CandidateSource::Impl(def) => self.tcx.trait_id_of_impl(def),
CandidateSource::Trait(_) => None,
}
})
.collect(),
_ => Vec::new(),
};
candidates.retain(|candidate| *candidate != self.tcx.parent(result.callee.def_id));

return Err(IllegalSizedBound(candidates, needs_mut, span));
Expand All @@ -247,23 +247,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
#[instrument(level = "debug", skip(self, call_expr))]
pub fn lookup_probe(
&self,
span: Span,
method_name: Ident,
self_ty: Ty<'tcx>,
call_expr: &'tcx hir::Expr<'tcx>,
scope: ProbeScope,
) -> probe::PickResult<'tcx> {
let mode = probe::Mode::MethodCall;
let self_ty = self.resolve_vars_if_possible(self_ty);
self.probe_for_name(
span,
mode,
let pick = self.probe_for_name(
probe::Mode::MethodCall,
method_name,
IsSuggestion(false),
self_ty,
call_expr.hir_id,
scope,
)
)?;
pick.maybe_emit_unstable_name_collision_hint(self.tcx, method_name.span, call_expr.hir_id);
Ok(pick)
}

pub(super) fn obligation_for_method(
Expand Down Expand Up @@ -587,7 +585,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

let pick = self.probe_for_name(
span,
probe::Mode::Path,
method_name,
IsSuggestion(false),
Expand All @@ -596,6 +593,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ProbeScope::TraitsInScope,
)?;

pick.maybe_emit_unstable_name_collision_hint(self.tcx, span, expr_id);

self.lint_fully_qualified_call_from_2018(
span,
method_name,
Expand Down
Loading