Thanks to visit codestin.com
Credit goes to github.com

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
25ab022
move `tests/ui/resolve/suggest*` to `tests/ui/resolve/suggestions/`
xizheyin Jun 29, 2025
000f038
Add ui test resolve/false-self-in-macro-issue-143134.rs
xizheyin Jun 29, 2025
236b392
Return early when `self` resolve failure because of `let self = ...`
xizheyin Jun 29, 2025
1a1b52a
clippy fix: indentation
hkBst Jul 4, 2025
995eeeb
Don't call predicates_of on a dummy obligation cause's body id
compiler-errors Jul 5, 2025
b63f920
More carefully consider span context when suggesting remove &mut
compiler-errors Jul 6, 2025
b4e68e2
Respect endianness correctly in CheckEnums test suite
1c3t3a Jul 2, 2025
e2891c0
configure.py: Write last key in each section
lambdageek Jul 7, 2025
b6d2130
Add docstring
lambdageek Jul 7, 2025
0455577
fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuild…
dillona Jul 8, 2025
3ba8e33
Rewrite for clarity
lambdageek Jul 8, 2025
c4bf37d
Always inline InterpCx::layout_of after perf regression
Stypox Jul 2, 2025
07143af
Replace TRACING_ENABLED with enter_trace_span()
Stypox Jul 5, 2025
3cacaa7
Add inline(always) to Machine::enter_trace_span
Stypox Jul 6, 2025
e8c8330
Make enter_trace_span take a closure for better optimization
Stypox Jul 6, 2025
e5f7d4d
Implement enter_trace_span() in MiriMachine
Stypox Jul 8, 2025
fab9c64
Add triagebot stdarch mention ping
Kobzol Jul 8, 2025
7c8a6d9
Spelling
lambdageek Jul 8, 2025
96cdbb9
Win: Use exceptions with empty data for SEH panic exception copies
Fulgen301 Jul 8, 2025
87e7539
Disable docs for `compiler-builtins` and `sysroot`
cuviper Jul 8, 2025
c8b2c78
Rollup merge of #143177 - xizheyin:143134, r=lcnr
jhpratt Jul 9, 2025
f205b45
Rollup merge of #143339 - 1c3t3a:issue-143332, r=RalfJung
jhpratt Jul 9, 2025
6d9f589
Rollup merge of #143426 - hkBst:clippy-fix-indent-1, r=jhpratt
jhpratt Jul 9, 2025
3b0f873
Rollup merge of #143499 - compiler-errors:predicates-of-crate, r=davi…
jhpratt Jul 9, 2025
8222dd3
Rollup merge of #143520 - Stypox:enter_trace_span-closure, r=RalfJung
jhpratt Jul 9, 2025
95b0f9e
Rollup merge of #143532 - compiler-errors:mut-ref-sugg, r=davidtwco
jhpratt Jul 9, 2025
ecea8e7
Rollup merge of #143606 - lambdageek:configure-write-last-key, r=Kobzol
jhpratt Jul 9, 2025
9e6fc2d
Rollup merge of #143632 - dillona:ffi-param-names, r=jieyouxu
jhpratt Jul 9, 2025
8989c62
Rollup merge of #143644 - Kobzol:stdarch-mention, r=Amanieu
jhpratt Jul 9, 2025
ae874bc
Rollup merge of #143651 - Fulgen301:seh-exception-ptr, r=ChrisDenton
jhpratt Jul 9, 2025
c29423e
Rollup merge of #143660 - cuviper:lib-doc-false, r=tgross35
jhpratt Jul 9, 2025
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
Don't call predicates_of on a dummy obligation cause's body id
  • Loading branch information
compiler-errors committed Jul 5, 2025
commit 995eeeb54cda2f3c7884e14a82bbe1f279143388
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_errors::{Applicability, Diag, E0283, E0284, E0790, MultiSpan, struct_s
use rustc_hir as hir;
use rustc_hir::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
use rustc_hir::intravisit::Visitor as _;
use rustc_infer::infer::{BoundRegionConversionTime, InferCtxt};
use rustc_infer::traits::util::elaborate;
Expand Down Expand Up @@ -128,19 +128,26 @@ pub fn compute_applicable_impls_for_diagnostics<'tcx>(
},
);

let predicates =
tcx.predicates_of(obligation.cause.body_id.to_def_id()).instantiate_identity(tcx);
for (pred, span) in elaborate(tcx, predicates.into_iter()) {
let kind = pred.kind();
if let ty::ClauseKind::Trait(trait_pred) = kind.skip_binder()
&& param_env_candidate_may_apply(kind.rebind(trait_pred))
{
if kind.rebind(trait_pred.trait_ref)
== ty::Binder::dummy(ty::TraitRef::identity(tcx, trait_pred.def_id()))
// If our `body_id` has been set (and isn't just from a dummy obligation cause),
// then try to look for a param-env clause that would apply. The way we compute
// this is somewhat manual, since we need the spans, so we elaborate this directly
// from `predicates_of` rather than actually looking at the param-env which
// otherwise would be more appropriate.
let body_id = obligation.cause.body_id;
if body_id != CRATE_DEF_ID {
let predicates = tcx.predicates_of(body_id.to_def_id()).instantiate_identity(tcx);
for (pred, span) in elaborate(tcx, predicates.into_iter()) {
let kind = pred.kind();
if let ty::ClauseKind::Trait(trait_pred) = kind.skip_binder()
&& param_env_candidate_may_apply(kind.rebind(trait_pred))
{
ambiguities.push(CandidateSource::ParamEnv(tcx.def_span(trait_pred.def_id())))
} else {
ambiguities.push(CandidateSource::ParamEnv(span))
if kind.rebind(trait_pred.trait_ref)
== ty::Binder::dummy(ty::TraitRef::identity(tcx, trait_pred.def_id()))
{
ambiguities.push(CandidateSource::ParamEnv(tcx.def_span(trait_pred.def_id())))
} else {
ambiguities.push(CandidateSource::ParamEnv(span))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Regression test for #143481, where we were calling `predicates_of` on
// a Crate HIR node because we were using a dummy obligation cause's body id
// without checking that it was meaningful first.

trait Role {
type Inner;
}
struct HandshakeCallback<C>(C);
impl<C: Clone> Role for HandshakeCallback {
//~^ ERROR missing generics
type Inner = usize;
}
struct Handshake<R: Role>(R::Inner);
fn accept() -> Handshake<HandshakeCallback<()>> {
todo!()
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0107]: missing generics for struct `HandshakeCallback`
--> $DIR/ambiguity-in-dropck-err-reporting.rs:9:25
|
LL | impl<C: Clone> Role for HandshakeCallback {
| ^^^^^^^^^^^^^^^^^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `C`
--> $DIR/ambiguity-in-dropck-err-reporting.rs:8:8
|
LL | struct HandshakeCallback<C>(C);
| ^^^^^^^^^^^^^^^^^ -
help: add missing generic argument
|
LL | impl<C: Clone> Role for HandshakeCallback<C> {
| +++

error: aborting due to 1 previous error

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