Skip to content

Commit 7f5c568

Browse files
committed
Auto merge of #32344 - aturon:issue-32324, r=eddyb
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 r? @nikomatsakis
2 parents 399b522 + 09263a6 commit 7f5c568

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/librustc/middle/ty/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
133133
let infcx = infer::new_infer_ctxt(tcx,
134134
&tcx.tables,
135135
Some(self.clone()),
136-
ProjectionMode::AnyFinal);
136+
ProjectionMode::Topmost);
137137

138138
let adt = match self_type.sty {
139139
ty::TyStruct(struct_def, substs) => {
@@ -548,7 +548,7 @@ impl<'tcx> ty::TyS<'tcx> {
548548
let infcx = infer::new_infer_ctxt(tcx,
549549
&tcx.tables,
550550
Some(param_env.clone()),
551-
ProjectionMode::AnyFinal);
551+
ProjectionMode::Topmost);
552552

553553
let is_impld = traits::type_known_to_meet_builtin_bound(&infcx,
554554
self, bound, span);

src/test/run-pass/issue-32324.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![allow(dead_code)]
12+
13+
trait Resources {
14+
type Buffer: Copy;
15+
}
16+
17+
#[derive(Copy, Clone)]
18+
struct ConstantBufferSet<R: Resources>(
19+
pub R::Buffer
20+
);
21+
22+
#[derive(Copy, Clone)]
23+
enum It {}
24+
impl Resources for It {
25+
type Buffer = u8;
26+
}
27+
28+
#[derive(Copy, Clone)]
29+
enum Command {
30+
BindConstantBuffers(ConstantBufferSet<It>)
31+
}
32+
33+
fn main() {}

0 commit comments

Comments
 (0)