From b3cbf290c8b6c052b3753d0f9635cdf758c16484 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 16 Dec 2019 12:07:05 -0500 Subject: [PATCH] remove misleading documentation --- doc/langref.html.in | 205 +------------------------------------------- 1 file changed, 2 insertions(+), 203 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index dc1811d60a3f..e2ae64342cf9 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -8315,216 +8315,15 @@ pub const TypeId = enum { {#header_close#} {#header_open|@typeInfo#} -
{#syntax#}@typeInfo(comptime T: type) @import("builtin").TypeInfo{#endsyntax#}
+
{#syntax#}@typeInfo(comptime T: type) @import("std").builtin.TypeInfo{#endsyntax#}

- Returns information on the type. Returns a value of the following union: + Provides type reflection.

- {#code_begin|syntax#} -pub const TypeInfo = union(TypeId) { - Type: void, - Void: void, - Bool: void, - NoReturn: void, - Int: Int, - Float: Float, - Pointer: Pointer, - Array: Array, - Struct: Struct, - ComptimeFloat: void, - ComptimeInt: void, - Undefined: void, - Null: void, - Optional: Optional, - ErrorUnion: ErrorUnion, - ErrorSet: ErrorSet, - Enum: Enum, - Union: Union, - Fn: Fn, - BoundFn: Fn, - Opaque: void, - Promise: Promise, - Vector: Vector, - EnumLiteral: void, - - - pub const Int = struct { - is_signed: bool, - bits: comptime_int, - }; - - pub const Float = struct { - bits: comptime_int, - }; - - pub const Pointer = struct { - size: Size, - is_const: bool, - is_volatile: bool, - alignment: comptime_int, - child: type, - is_allowzero: bool, - sentinel: var, - - pub const Size = enum { - One, - Many, - Slice, - C, - }; - }; - - pub const Array = struct { - len: comptime_int, - child: type, - sentinel: var, - }; - - pub const ContainerLayout = enum { - Auto, - Extern, - Packed, - }; - - pub const StructField = struct { - name: []const u8, - offset: ?comptime_int, - field_type: type, - }; - - pub const Struct = struct { - layout: ContainerLayout, - fields: []StructField, - decls: []Declaration, - }; - - pub const Optional = struct { - child: type, - }; - - pub const ErrorUnion = struct { - error_set: type, - payload: type, - }; - - pub const Error = struct { - name: []const u8, - value: comptime_int, - }; - - pub const ErrorSet = ?[]Error; - - pub const EnumField = struct { - name: []const u8, - value: comptime_int, - }; - - pub const Enum = struct { - layout: ContainerLayout, - tag_type: type, - fields: []EnumField, - decls: []Declaration, - }; - - pub const UnionField = struct { - name: []const u8, - enum_field: ?EnumField, - field_type: type, - }; - - pub const Union = struct { - layout: ContainerLayout, - tag_type: ?type, - fields: []UnionField, - decls: []Declaration, - }; - - pub const CallingConvention = enum { - Unspecified, - C, - Cold, - Naked, - Stdcall, - Async, - }; - - pub const FnArg = struct { - is_generic: bool, - is_noalias: bool, - arg_type: ?type, - }; - - pub const Fn = struct { - calling_convention: CallingConvention, - is_generic: bool, - is_var_args: bool, - return_type: ?type, - async_allocator_type: ?type, - args: []FnArg, - }; - - pub const Promise = struct { - child: ?type, - }; - - pub const Vector = struct { - len: comptime_int, - child: type, - }; - - pub const Declaration = struct { - name: []const u8, - is_pub: bool, - data: Data, - - pub const Data = union(enum) { - Type: type, - Var: type, - Fn: FnDecl, - - pub const FnDecl = struct { - fn_type: type, - inline_type: Inline, - calling_convention: CallingConvention, - is_var_args: bool, - is_extern: bool, - is_export: bool, - lib_name: ?[]const u8, - return_type: type, - arg_names: [][] const u8, - - pub const Inline = enum { - Auto, - Always, - Never, - }; - }; - }; - }; -}; - {#code_end#}

For {#link|structs|struct#}, {#link|unions|union#}, {#link|enums|enum#}, and {#link|error sets|Error Set Type#}, the fields are guaranteed to be in the same order as declared. For declarations, the order is unspecified.

-

- Note that the {#syntax#}sentinel{#endsyntax#} field in {#syntax#}TypeInfo.Pointer{#endsyntax#} - and {#syntax#}TypeInfo.Array{#endsyntax#} is of type {#syntax#}var{#endsyntax#} rather - than {#syntax#}?child{#endsyntax#}. {#syntax#}TypeInfo.Pointer{#endsyntax#} - and {#syntax#}TypeInfo.Array{#endsyntax#} can be constructed with any comptime value for the - {#syntax#}sentinel{#endsyntax#} field. However, the {#syntax#}@Type{#endsyntax#} builtin will - only accept the TypeInfo struct if the sentinel value is implicitly convertible to - {#syntax#}child{#endsyntax#}. Furthermore, any {#syntax#}TypeInfo.Pointer{#endsyntax#} - or {#syntax#}TypeInfo.Array{#endsyntax#} retreived from {#syntax#}@typeInfo{#endsyntax#} will - guarantee that {#syntax#}@typeOf(sentinel){#endsyntax#} is equal to - {#syntax#}?child{#endsyntax#}. For example, {#syntax#}@typeOf(sentinel){#endsyntax#} for a - {#syntax#}TypeInfo.Pointer{#endsyntax#} constructed with - {#syntax#}TypeInfo.Pointer { ... .sentinel = 0; ... }{#endsyntax#} would be - {#syntax#}comptime_int{#endsyntax#} rather than {#syntax#}?u8{#endsyntax#}. However, if you - passed that {#syntax#}TypeInfo.Pointer{#endsyntax#} struct to - {#syntax#}@typeInfo(@Type(myPointerInfo)){#endsyntax#} then {#syntax#}@typeOf(sentinel){#endsyntax#} - would be {#syntax#}?u8{#endsyntax#}. -

{#header_close#} {#header_open|@typeName#}