mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
01118928fc
typestrong const integers ~~It would be great if someone could run crater on this PR, as this has a high danger of breaking valid code~~ Crater ran. Good to go. ---- So this PR does a few things: 1. ~~const eval array values when const evaluating an array expression~~ 2. ~~const eval repeat value when const evaluating a repeat expression~~ 3. ~~const eval all struct and tuple fields when evaluating a struct/tuple expression~~ 4. remove the `ConstVal::Int` and `ConstVal::Uint` variants and replace them with a single enum (`ConstInt`) which has variants for all integral types * `usize`/`isize` are also enums with variants for 32 and 64 bit. At creation and various usage steps there are assertions in place checking if the target bitwidth matches with the chosen enum variant 5. enum discriminants (`ty::Disr`) are now `ConstInt` 6. trans has its own `Disr` type now (newtype around `u64`) This obviously can't be done without breaking changes (the ones that are noticable in stable) We could probably write lints that find those situations and error on it for a cycle or two. But then again, those situations are rare and really bugs imo anyway: ```rust let v10 = 10 as i8; let v4 = 4 as isize; assert_eq!(v10 << v4 as usize, 160 as i8); ``` stops compiling because 160 is not a valid i8 ```rust struct S<T, S> { a: T, b: u8, c: S } let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 }; ``` stops compiling because `0xaa_aa_aa_aa` is not a valid i32 ---- cc @eddyb @pnkfelix related: https://github.com/rust-lang/rfcs/issues/1071
205 lines
7.7 KiB
Makefile
205 lines
7.7 KiB
Makefile
# Copyright 2014 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 <LICENSE-APACHE or
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
# option. This file may not be copied, modified, or distributed
|
|
# except according to those terms.
|
|
|
|
################################################################################
|
|
# Rust's standard distribution of crates and tools
|
|
#
|
|
# The crates outlined below are the standard distribution of libraries provided
|
|
# in a rust installation. These rules are meant to abstract over the
|
|
# dependencies (both native and rust) of crates and basically generate all the
|
|
# necessary makefile rules necessary to build everything.
|
|
#
|
|
# Here's an explanation of the variables below
|
|
#
|
|
# TARGET_CRATES
|
|
# This list of crates will be built for all targets, including
|
|
# cross-compiled targets
|
|
#
|
|
# HOST_CRATES
|
|
# This list of crates will be compiled for only host targets. Note that
|
|
# this set is explicitly *not* a subset of TARGET_CRATES, but rather it is
|
|
# a disjoint set. Nothing in the TARGET_CRATES set can depend on crates in
|
|
# the HOST_CRATES set, but the HOST_CRATES set can depend on target
|
|
# crates.
|
|
#
|
|
# TOOLS
|
|
# A list of all tools which will be built as part of the compilation
|
|
# process. It is currently assumed that most tools are built through
|
|
# src/driver/driver.rs with a particular configuration (there's a
|
|
# corresponding library providing the implementation)
|
|
#
|
|
# DEPS_<crate>
|
|
# These lists are the dependencies of the <crate> that is to be built.
|
|
# Rust dependencies are listed bare (i.e. std) and native
|
|
# dependencies have a "native:" prefix (i.e. native:hoedown). All deps
|
|
# will be built before the crate itself is built.
|
|
#
|
|
# TOOL_DEPS_<tool>/TOOL_SOURCE_<tool>
|
|
# Similar to the DEPS variable, this is the library crate dependencies
|
|
# list for tool as well as the source file for the specified tool
|
|
#
|
|
# You shouldn't need to modify much other than these variables. Crates are
|
|
# automatically generated for all stage/host/target combinations.
|
|
################################################################################
|
|
|
|
TARGET_CRATES := libc std term \
|
|
getopts collections test rand \
|
|
core alloc \
|
|
rustc_unicode rustc_bitflags \
|
|
alloc_system alloc_jemalloc rustc_const_eval
|
|
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
|
|
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
|
|
rustc_data_structures rustc_front rustc_platform_intrinsics \
|
|
rustc_plugin rustc_metadata rustc_passes
|
|
HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \
|
|
flate arena graphviz rbml log serialize
|
|
TOOLS := compiletest rustdoc rustc rustbook error_index_generator
|
|
|
|
DEPS_core :=
|
|
DEPS_alloc := core libc alloc_system
|
|
DEPS_alloc_system := core libc
|
|
DEPS_alloc_jemalloc := core libc native:jemalloc
|
|
DEPS_collections := core alloc rustc_unicode
|
|
DEPS_libc := core
|
|
DEPS_rand := core
|
|
DEPS_rustc_bitflags := core
|
|
DEPS_rustc_unicode := core
|
|
|
|
DEPS_std := core libc rand alloc collections rustc_unicode \
|
|
native:backtrace \
|
|
alloc_system
|
|
DEPS_arena := std
|
|
DEPS_glob := std
|
|
DEPS_flate := std native:miniz
|
|
DEPS_fmt_macros = std
|
|
DEPS_getopts := std
|
|
DEPS_graphviz := std
|
|
DEPS_log := std
|
|
DEPS_num := std
|
|
DEPS_rbml := std log serialize
|
|
DEPS_serialize := std log
|
|
DEPS_term := std
|
|
DEPS_test := std getopts term native:rust_test_helpers
|
|
|
|
DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode
|
|
DEPS_syntax_ext := syntax fmt_macros
|
|
|
|
DEPS_rustc_const_eval := std syntax
|
|
|
|
DEPS_rustc := syntax fmt_macros flate arena serialize getopts rbml rustc_front\
|
|
log graphviz rustc_llvm rustc_back rustc_data_structures\
|
|
rustc_const_eval
|
|
DEPS_rustc_back := std syntax rustc_llvm rustc_front flate log libc
|
|
DEPS_rustc_borrowck := rustc rustc_front log graphviz syntax
|
|
DEPS_rustc_data_structures := std log serialize
|
|
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
|
|
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
|
|
rustc_trans rustc_privacy rustc_lint rustc_front rustc_plugin \
|
|
rustc_metadata syntax_ext rustc_passes
|
|
DEPS_rustc_front := std syntax log serialize
|
|
DEPS_rustc_lint := rustc log syntax
|
|
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
|
|
DEPS_rustc_metadata := rustc rustc_front syntax rbml rustc_const_eval
|
|
DEPS_rustc_passes := syntax rustc core rustc_front
|
|
DEPS_rustc_mir := rustc rustc_front syntax rustc_const_eval
|
|
DEPS_rustc_resolve := arena rustc rustc_front log syntax
|
|
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
|
|
DEPS_rustc_plugin := rustc rustc_metadata syntax rustc_mir
|
|
DEPS_rustc_privacy := rustc rustc_front log syntax
|
|
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
|
|
log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics \
|
|
rustc_const_eval
|
|
DEPS_rustc_typeck := rustc syntax rustc_front rustc_platform_intrinsics rustc_const_eval
|
|
|
|
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
|
|
test rustc_lint rustc_front
|
|
|
|
|
|
TOOL_DEPS_compiletest := test getopts
|
|
TOOL_DEPS_rustdoc := rustdoc
|
|
TOOL_DEPS_rustc := rustc_driver
|
|
TOOL_DEPS_rustbook := std rustdoc
|
|
TOOL_DEPS_error_index_generator := rustdoc syntax serialize
|
|
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
|
|
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
|
|
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
|
|
TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
|
|
TOOL_SOURCE_error_index_generator := $(S)src/tools/error_index_generator/main.rs
|
|
|
|
ONLY_RLIB_core := 1
|
|
ONLY_RLIB_libc := 1
|
|
ONLY_RLIB_alloc := 1
|
|
ONLY_RLIB_rand := 1
|
|
ONLY_RLIB_collections := 1
|
|
ONLY_RLIB_rustc_unicode := 1
|
|
ONLY_RLIB_rustc_bitflags := 1
|
|
ONLY_RLIB_alloc_system := 1
|
|
ONLY_RLIB_alloc_jemalloc := 1
|
|
|
|
TARGET_SPECIFIC_alloc_jemalloc := 1
|
|
|
|
# Documented-by-default crates
|
|
DOC_CRATES := std alloc collections core libc rustc_unicode
|
|
|
|
ifeq ($(CFG_DISABLE_JEMALLOC),)
|
|
RUSTFLAGS_rustc_back := --cfg 'feature="jemalloc"'
|
|
endif
|
|
|
|
################################################################################
|
|
# You should not need to edit below this line
|
|
################################################################################
|
|
|
|
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
|
|
|
|
# This macro creates some simple definitions for each crate being built, just
|
|
# some munging of all of the parameters above.
|
|
#
|
|
# $(1) is the crate to generate variables for
|
|
define RUST_CRATE
|
|
CRATEFILE_$(1) := $$(SREL)src/lib$(1)/lib.rs
|
|
RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
|
|
NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
|
|
endef
|
|
|
|
$(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
|
|
|
|
# $(1) - crate
|
|
# $(2) - target
|
|
define RUST_CRATE_DEPS
|
|
RUST_DEPS_$(1)_T_$(2) := $$(filter-out native:%,$$(DEPS_$(1)))
|
|
endef
|
|
|
|
$(foreach target,$(CFG_TARGET),\
|
|
$(foreach crate,$(CRATES),$(eval $(call RUST_CRATE_DEPS,$(crate),$(target)))))
|
|
|
|
# $(1) - target
|
|
# $(2) - crate
|
|
define DEFINE_TARGET_CRATES
|
|
ifndef TARGET_SPECIFIC_$(2)
|
|
TARGET_CRATES_$(1) += $(2)
|
|
endif
|
|
endef
|
|
|
|
$(foreach target,$(CFG_TARGET),\
|
|
$(foreach crate,$(TARGET_CRATES),\
|
|
$(eval $(call DEFINE_TARGET_CRATES,$(target),$(crate)))))
|
|
|
|
# Similar to the macro above for crates, this macro is for tools
|
|
#
|
|
# $(1) is the crate to generate variables for
|
|
define RUST_TOOL
|
|
TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
|
|
endef
|
|
|
|
$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
|
|
|
|
CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
|
|
RUSTFLAGS_libc := --cfg stdbuild
|