From b423a0f9ef488ca4cd9ff620a44566bb441eb21f Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 13 Jun 2015 13:15:03 -0700 Subject: Split TyBareFn into TyFnDef and TyFnPtr. There's a lot of stuff wrong with the representation of these types: TyFnDef doesn't actually uniquely identify a function, TyFnPtr is used to represent method calls, TyFnDef in the sub-expression of a cast isn't correctly reified, and probably some other stuff I haven't discovered yet. Splitting them seems like the right first step, though. --- src/test/auxiliary/issue13507.rs | 72 ++++++++++++++++-------------- src/test/compile-fail/invalid-intrinsic.rs | 16 +++++++ src/test/compile-fail/variadic-ffi-3.rs | 2 +- src/test/run-pass/issue-13507-2.rs | 34 ++++++++------ 4 files changed, 75 insertions(+), 49 deletions(-) create mode 100644 src/test/compile-fail/invalid-intrinsic.rs (limited to 'src/test') diff --git a/src/test/auxiliary/issue13507.rs b/src/test/auxiliary/issue13507.rs index 78d0394a6e5..4cb846b5186 100644 --- a/src/test/auxiliary/issue13507.rs +++ b/src/test/auxiliary/issue13507.rs @@ -14,26 +14,26 @@ pub mod testtypes { use std::any::TypeId; pub fn type_ids() -> Vec { - let mut ids = vec!(); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::<&'static FooTrait>()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids + vec![ + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::() + ] } - // Tests ty_nil - pub type FooNil = (); - - // Skipping ty_bot - // Tests TyBool pub type FooBool = bool; @@ -49,25 +49,26 @@ pub mod testtypes { // Tests TyFloat (does not test all variants of FloatTy) pub type FooFloat = f64; - // For TyStr, what kind of string should I use? &'static str? String? Raw str? + // Tests TyStr + pub type FooStr = str; - // Tests TyEnum - pub enum FooEnum { - VarA(usize), - VarB(usize, usize) - } + // Tests TyArray + pub type FooArray = [u8; 1]; - // Tests TyBox (of u8) - pub type FooUniq = Box; + // Tests TySlice + pub type FooSlice = [u8]; - // As with TyStr, what type should be used for TyArray? + // Tests TyBox (of u8) + pub type FooBox = Box; // Tests TyRawPtr pub type FooPtr = *const u8; - // Skipping TyRef + // Tests TyRef + pub type FooRef = &'static u8; - // Skipping TyBareFn (how do you get a bare function type, rather than proc or closure?) + // Tests TyFnPtr + pub type FooFnPtr = fn(u8) -> bool; // Tests TyTrait pub trait FooTrait { @@ -80,14 +81,17 @@ pub mod testtypes { foo_field: usize } + // Tests TyEnum + pub enum FooEnum { + VarA(usize), + VarB(usize, usize) + } + // Tests TyTuple + pub type FooNil = (); pub type FooTuple = (u8, i8, bool); - // Skipping ty_param - - // Skipping ty_self - - // Skipping ty_self + // Skipping TyParam // Skipping TyInfer diff --git a/src/test/compile-fail/invalid-intrinsic.rs b/src/test/compile-fail/invalid-intrinsic.rs new file mode 100644 index 00000000000..2aa2546cb9f --- /dev/null +++ b/src/test/compile-fail/invalid-intrinsic.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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. + +#![feature(intrinsics)] +extern "rust-intrinsic" { + pub static breakpoint : unsafe extern "rust-intrinsic" fn(); + //~^ ERROR intrinsic has wrong type +} +fn main() { unsafe { breakpoint(); } } \ No newline at end of file diff --git a/src/test/compile-fail/variadic-ffi-3.rs b/src/test/compile-fail/variadic-ffi-3.rs index 94055450bc6..1d5ebdbae3e 100644 --- a/src/test/compile-fail/variadic-ffi-3.rs +++ b/src/test/compile-fail/variadic-ffi-3.rs @@ -22,7 +22,7 @@ fn main() { let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~^ ERROR: mismatched types //~| expected `unsafe extern "C" fn(isize, u8)` - //~| found `unsafe extern "C" fn(isize, u8, ...)` + //~| found `unsafe extern "C" fn(isize, u8, ...) {foo}` //~| expected non-variadic fn //~| found variadic function diff --git a/src/test/run-pass/issue-13507-2.rs b/src/test/run-pass/issue-13507-2.rs index 91ec3e85404..084b7a166cd 100644 --- a/src/test/run-pass/issue-13507-2.rs +++ b/src/test/run-pass/issue-13507-2.rs @@ -19,23 +19,29 @@ use issue13507::testtypes; use std::any::TypeId; pub fn type_ids() -> Vec { - let mut ids = vec!(); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::<&'static testtypes::FooTrait>()); - ids.push(TypeId::of::()); - ids.push(TypeId::of::()); - ids + use issue13507::testtypes::*; + vec![ + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::() + ] } pub fn main() { - let othercrate = testtypes::type_ids(); + let othercrate = issue13507::testtypes::type_ids(); let thiscrate = type_ids(); assert_eq!(thiscrate, othercrate); } -- cgit 1.4.1-3-g733a5