Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jun 26, 2020
1 parent ae7828a commit a23a444
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
def_id: DefId,
substs: SubstsRef<'tcx>,
) -> InterpResult<'tcx, ty::Instance<'tcx>> {
self.resolve_const_arg(self.tcx.with_opt_param(def_id), substs)
self.resolve_const_arg(ty::WithOptParam::dummy(def_id), substs)
}

pub(super) fn resolve_const_arg(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
ty::ConstKind::Param(_) => throw_inval!(TooGeneric),
ty::ConstKind::Error(_) => throw_inval!(TypeckError(ErrorReported)),
ty::ConstKind::Unevaluated(def, substs, promoted) => {
let instance = self.resolve(def, substs)?;
let instance = self.resolve_const_arg(def, substs)?;
// We use `const_eval` here and `const_eval_raw` elsewhere in mir interpretation.
// The reason we use `const_eval_raw` everywhere else is to prevent cycles during
// validation, because validation automatically reads through any references, thus
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/instrument_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct InstrumentCoverage;
/// constructing the arguments for `llvm.instrprof.increment`.
pub(crate) fn provide(providers: &mut Providers<'_>) {
providers.coverage_data = |tcx, def_id| {
let mir_body = tcx.optimized_mir(def_id);
let mir_body = tcx.optimized_mir(ty::WithOptParam::dummy(def_id));
// FIXME(richkadel): The current implementation assumes the MIR for the given DefId
// represents a single function. Validate and/or correct if inlining and/or monomorphization
// invalidates these assumptions.
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {

let mut label = false;
if let Some((hir_id, visitor)) = get_owner_return_paths(tcx, def_id) {
let tables = tcx.typeck_tables_of(tcx.hir().local_def_id(hir_id));
let tables = tcx.typeck_tables_of(ty::WithOptParam::dummy(tcx.hir().local_def_id(hir_id)));
if visitor
.returns
.iter()
Expand Down Expand Up @@ -1854,8 +1854,9 @@ fn binding_opaque_type_cycle_error(
..
}) => {
let hir_id = tcx.hir().as_local_hir_id(def_id);
let tables =
tcx.typeck_tables_of(tcx.hir().local_def_id(tcx.hir().get_parent_item(hir_id)));
let tables = tcx.typeck_tables_of(ty::WithOptParam::dummy(
tcx.hir().local_def_id(tcx.hir().get_parent_item(hir_id)),
));
if let Some(ty) = tables.node_type_opt(expr.hir_id) {
err.span_label(
expr.span,
Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/const-generics/type-dependent/issue-71382.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass
#![feature(const_generics)]
#![allow(incomplete_features)]
#![feature(const_compare_raw_pointers)]
//~^ WARN the feature `const_generics` is incomplete

struct Test;

Expand All @@ -15,6 +13,7 @@ impl Test {
}

fn test<const FN: fn() -> u8>(&self) -> u8 {
//~^ ERROR using function pointers as const generic parameters is forbidden
FN()
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/const-generics/type-dependent/issue-71382.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-71382.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71382.rs:15:23
|
LL | fn test<const FN: fn() -> u8>(&self) -> u8 {
| ^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted

0 comments on commit a23a444

Please sign in to comment.