Skip to content

Commit dc309d7

Browse files
committed
Auto merge of #26686 - arielb1:associated-type-defaults-actually-work, r=eddyb
Fixes #26636. r? @eddyb
2 parents fdf219d + cebb118 commit dc309d7

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,10 @@ fn encode_info_for_item(ecx: &EncodeContext,
14511451
encode_item_sort(rbml_w, 't');
14521452
encode_family(rbml_w, 'y');
14531453

1454+
if let Some(ty) = associated_type.ty {
1455+
encode_type(ecx, rbml_w, ty);
1456+
}
1457+
14541458
is_nonstatic_method = false;
14551459
}
14561460
}

src/librustc/middle/traits/project.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,9 @@ fn confirm_impl_candidate<'cx,'tcx>(
904904
// ought to be reported by the type checker method
905905
// `check_impl_items_against_trait`, so here we
906906
// just return TyError.
907+
debug!("confirm_impl_candidate: no associated type {:?} for {:?}",
908+
assoc_ty.name,
909+
trait_ref);
907910
return (selcx.tcx().types.err, vec!());
908911
}
909912
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 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+
pub trait Foo {
12+
type Input = usize;
13+
fn bar(&self, _: Self::Input) {}
14+
}
15+
16+
impl Foo for () {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 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+
// aux-build:xcrate_associated_type_defaults.rs
12+
13+
extern crate xcrate_associated_type_defaults;
14+
use xcrate_associated_type_defaults::Foo;
15+
16+
fn main() {
17+
().bar(5);
18+
}

0 commit comments

Comments
 (0)