Skip to content

Commit 769ac42

Browse files
committed
Auto merge of #33099 - eddyb:issue-33096, r=michaelwoerister
Normalize types before using them in debuginfo. Small oversight, fixes #33096 - odd thing is that the old code doesn't look like it should've ever worked, although it wasn't using all of the type parameters, so maybe that's what changed.
2 parents 41028de + 4e1cf9a commit 769ac42

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/librustc_trans/debuginfo/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use rustc::hir;
3434
use abi::Abi;
3535
use common::{NodeIdAndSpan, CrateContext, FunctionContext, Block, BlockAndBuilder};
3636
use monomorphize::Instance;
37+
use rustc::infer::normalize_associated_type;
3738
use rustc::ty::{self, Ty};
3839
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
3940
use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet};
@@ -368,6 +369,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
368369

369370
name_to_append_suffix_to.push('<');
370371
for (i, &actual_type) in actual_types.iter().enumerate() {
372+
let actual_type = normalize_associated_type(cx.tcx(), &actual_type);
371373
// Add actual type name to <...> clause of function name
372374
let actual_type_name = compute_debuginfo_type_name(cx,
373375
actual_type,
@@ -383,7 +385,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
383385
// Again, only create type information if full debuginfo is enabled
384386
let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo {
385387
generics.types.as_slice().iter().enumerate().map(|(i, param)| {
386-
let actual_type = actual_types[i];
388+
let actual_type = normalize_associated_type(cx.tcx(), &actual_types[i]);
387389
let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP);
388390
let name = CString::new(param.name.as_str().as_bytes()).unwrap();
389391
unsafe {

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2016 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+
// compile-flags: -g
12+
13+
use std::ops::Deref;
14+
15+
trait Foo {
16+
fn foo() {}
17+
}
18+
19+
impl Foo for u8 {}
20+
21+
fn bar<T: Deref>() where T::Target: Foo {
22+
<<T as Deref>::Target as Foo>::foo()
23+
}
24+
25+
fn main() {
26+
bar::<&u8>();
27+
}

0 commit comments

Comments
 (0)