Skip to content

Handle Sized? in type items. #17114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3936,6 +3936,7 @@ impl<'a> Resolver<'a> {
item.id,
ItemRibKind),
|this| {
this.resolve_type_parameters(&generics.ty_params);
visit::walk_item(this, item, ());
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/middle/typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
generics: &ast::Generics,
thing: &'static str) {
for ty_param in generics.ty_params.iter() {
for bound in ty_param.bounds.iter() {
let bounds = ty_param.bounds.iter();
let mut bounds = bounds.chain(ty_param.unbound.iter());
for bound in bounds {
match *bound {
ast::TraitTyParamBound(..) | ast::UnboxedFnTyParamBound(..) => {
// According to accepted RFC #XXX, we should
Expand Down Expand Up @@ -1076,9 +1078,10 @@ fn add_unsized_bound(ccx: &CrateCtxt,
desc: &str,
span: Span) {
let kind_id = ccx.tcx.lang_items.require(SizedTraitLangItem);

match unbound {
&Some(ast::TraitTyParamBound(ref tpb)) => {
// #FIXME(8559) currently requires the unbound to be built-in.
// FIXME(#8559) currently requires the unbound to be built-in.
let trait_def_id = ty::trait_ref_to_def_id(ccx.tcx, tpb);
match kind_id {
Ok(kind_id) if trait_def_id != kind_id => {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/unsized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct S1<Sized? X>;
enum E<Sized? X> {}
impl <Sized? X> T1 for S1<X> {}
fn f<Sized? X>() {}
type TT<Sized? T> = T;

pub fn main() {
}