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

fix: mock ConstParm when encounter LateBound during convert path expr #108206

Closed
wants to merge 1 commit into from

Conversation

bvanjoi
Copy link
Contributor

@bvanjoi bvanjoi commented Feb 18, 2023

close #108194

@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 18, 2023
@compiler-errors
Copy link
Member

Can you explain why this fixes the issue? I don't know if this is the right approach for this ICE.

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Feb 18, 2023

Can you explain why this fixes the issue? I don't know if this is the right approach for this ICE.

The current method is problematic and I am trying new ideas.

@compiler-errors
Copy link
Member

I'll mark this as waiting on author then.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2023
@bvanjoi bvanjoi changed the title fix(hir): add generic param def from where for fix: mock ConstParm when encounter LateBound during convert path expr Feb 18, 2023
@bvanjoi
Copy link
Contributor Author

bvanjoi commented Feb 18, 2023

please review it when you have time @compiler-errors

bug!("unexpected bound var resolution for {:?}: {arg:?}", expr.hir_id)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should be this one

match tcx.named_bound_var(hir_id) {
Some(rbv::ResolvedArg::LateBound(debruijn, index, _)) => {
let name =
tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id.expect_local()));
let br = ty::BoundTy {
var: ty::BoundVar::from_u32(index),
kind: ty::BoundTyKind::Param(def_id, name),
};
tcx.mk_ty(ty::Bound(debruijn, br))
}
Some(rbv::ResolvedArg::EarlyBound(_)) => {
let def_id = def_id.expect_local();
let item_def_id = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id))
}
arg => bug!("unexpected bound var resolution for {hir_id:?}: {arg:?}"),
}

but with Const instead of Ty where relevant.

Copy link
Member

@compiler-errors compiler-errors Feb 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constructing a ParamConst like the code is currently doing is incorrect, and I think would be problematic because we'll be treating it like an early-bound const param.

There currently isn't a THIR representation for a bound const that's been "liberated" like a placeholder (or a free region). I'm not really sure what that would look like, either. This probably needs a more involved solution than what's curently implemented.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-14 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
Download action repository 'rust-lang/simpleinfra@master' (SHA:75573f9759179a720f4c3af6c9fb518ac0061dca)
Complete job name: PR (x86_64-gnu-llvm-14, false, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: x86_64-gnu-llvm-14
---
To only update this specific test, also pass `--test-args traits/non_lifetime_binders/path-expr.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/traits/non_lifetime_binders/path-expr.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/traits/non_lifetime_binders/path-expr" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/traits/non_lifetime_binders/path-expr/auxiliary"
stdout: none
--- stderr -------------------------------
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
  --> fake-test-src-base/traits/non_lifetime_binders/path-expr.rs:3:12
LL | #![feature(non_lifetime_binders)]
   |            ^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information

@bvanjoi bvanjoi closed this Mar 20, 2023
@bvanjoi bvanjoi deleted the issue-108194 branch April 3, 2023 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: no entry found for key
5 participants