From 09263a6137f27ef82e36225683c5f320c9163b17 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Fri, 18 Mar 2016 17:01:33 -0700 Subject: [PATCH] Fix mis-uses of projection mode A couple of places where we construct a fresh inference context were incorrectly assuming that we were past coherence checking. This commit corrects them to use `Topmost` rather than `AnyFinal` as the projection mode. Fixes #32324 --- src/librustc/middle/ty/util.rs | 4 ++-- src/test/run-pass/issue-32324.rs | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/issue-32324.rs diff --git a/src/librustc/middle/ty/util.rs b/src/librustc/middle/ty/util.rs index 5af40a3675ff7..6a91592dbd52a 100644 --- a/src/librustc/middle/ty/util.rs +++ b/src/librustc/middle/ty/util.rs @@ -133,7 +133,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(self.clone()), - ProjectionMode::AnyFinal); + ProjectionMode::Topmost); let adt = match self_type.sty { ty::TyStruct(struct_def, substs) => { @@ -548,7 +548,7 @@ impl<'tcx> ty::TyS<'tcx> { let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env.clone()), - ProjectionMode::AnyFinal); + ProjectionMode::Topmost); let is_impld = traits::type_known_to_meet_builtin_bound(&infcx, self, bound, span); diff --git a/src/test/run-pass/issue-32324.rs b/src/test/run-pass/issue-32324.rs new file mode 100644 index 0000000000000..ca9dd6ada80b5 --- /dev/null +++ b/src/test/run-pass/issue-32324.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +trait Resources { + type Buffer: Copy; +} + +#[derive(Copy, Clone)] +struct ConstantBufferSet( + pub R::Buffer +); + +#[derive(Copy, Clone)] +enum It {} +impl Resources for It { + type Buffer = u8; +} + +#[derive(Copy, Clone)] +enum Command { + BindConstantBuffers(ConstantBufferSet) +} + +fn main() {}