diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index bdc00295a2041..ce30d1f4cec42 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -419,7 +419,8 @@ impl<'a> Builder<'a> { .env("RUSTC_LIBDIR", self.sysroot_libdir(compiler, self.build.build)) .env("CFG_RELEASE_CHANNEL", &self.build.config.channel) .env("RUSTDOC_REAL", self.rustdoc(host)) - .env("RUSTDOC_CRATE_VERSION", self.build.rust_version()); + .env("RUSTDOC_CRATE_VERSION", self.build.rust_version()) + .env("RUSTC_BOOTSTRAP", "1"); if let Some(linker) = self.build.linker(host) { cmd.env("RUSTC_TARGET_LINKER", linker); } @@ -483,8 +484,8 @@ impl<'a> Builder<'a> { } else { PathBuf::from("/path/to/nowhere/rustdoc/not/required") }) - .env("TEST_MIRI", self.config.test_miri.to_string()); - + .env("TEST_MIRI", self.config.test_miri.to_string()) + .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir()); if let Some(n) = self.config.rust_codegen_units { cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); } diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 0485ebe17fb00..4e3f3a00b15ee 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -24,7 +24,7 @@ use Build; use config::Config; // The version number -pub const CFG_RELEASE_NUM: &str = "1.24.0"; +pub const CFG_RELEASE_NUM: &str = "1.25.0"; // An optional number to put after the label, e.g. '.2' -> '-beta.2' // Be sure to make this starts with a dot to conform to semver pre-release diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 714c01aa50446..cc9be3cec3476 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -975,7 +975,8 @@ impl Step for ErrorIndex { build.run(builder.tool_cmd(Tool::ErrorIndex) .arg("markdown") .arg(&output) - .env("CFG_BUILD", &build.build)); + .env("CFG_BUILD", &build.build) + .env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir())); markdown_test(builder, compiler, &output); } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 3c12cfc4c7ffd..832da24c994db 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -671,7 +671,8 @@ impl Step for ErrorIndex { index.arg(out.join("error-index.html")); // FIXME: shouldn't have to pass this env var - index.env("CFG_BUILD", &build.build); + index.env("CFG_BUILD", &build.build) + .env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()); build.run(&mut index); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index d6dc44034a708..948bf29bbacc3 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -718,6 +718,11 @@ impl Build { self.config.python.as_ref().unwrap() } + /// Temporary directory that extended error information is emitted to. + fn extended_error_dir(&self) -> PathBuf { + self.out.join("tmp/extended-error-metadata") + } + /// Tests whether the `compiler` compiling for `target` should be forced to /// use a stage1 compiler instead. /// diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 874065f21d080..07941e588387c 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -315,7 +315,7 @@ pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> { let mut data = [0u8; MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; let db = data.as_mut_ptr() as *mut REPARSE_MOUNTPOINT_DATA_BUFFER; - let buf = &mut (*db).ReparseTarget as *mut _; + let buf = &mut (*db).ReparseTarget as *mut u16; let mut i = 0; // FIXME: this conversion is very hacky let v = br"\??\"; diff --git a/src/ci/docker/x86_64-gnu-incremental/Dockerfile b/src/ci/docker/x86_64-gnu-incremental/Dockerfile index d323677698cce..7304ed6015cc9 100644 --- a/src/ci/docker/x86_64-gnu-incremental/Dockerfile +++ b/src/ci/docker/x86_64-gnu-incremental/Dockerfile @@ -19,3 +19,4 @@ RUN sh /scripts/sccache.sh ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu ENV RUSTFLAGS -Zincremental=/tmp/rust-incr-cache ENV RUST_CHECK_TARGET check +ENV CARGO_INCREMENTAL 0 diff --git a/src/liballoc/btree/set.rs b/src/liballoc/btree/set.rs index 2807bbaca0c89..e094070fc3dd1 100644 --- a/src/liballoc/btree/set.rs +++ b/src/liballoc/btree/set.rs @@ -415,6 +415,16 @@ impl BTreeSet { /// The value may be any borrowed form of the set's value type, /// but the ordering on the borrowed form *must* match the /// ordering on the value type. + /// + /// # Examples + /// + /// ``` + /// use std::collections::BTreeSet; + /// + /// let set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect(); + /// assert_eq!(set.get(&2), Some(&2)); + /// assert_eq!(set.get(&4), None); + /// ``` #[stable(feature = "set_recovery", since = "1.9.0")] pub fn get(&self, value: &Q) -> Option<&T> where T: Borrow, @@ -540,6 +550,19 @@ impl BTreeSet { /// Adds a value to the set, replacing the existing value, if any, that is equal to the given /// one. Returns the replaced value. + /// + /// # Examples + /// + /// ``` + /// use std::collections::BTreeSet; + /// + /// let mut set = BTreeSet::new(); + /// set.insert(Vec::::new()); + /// + /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 0); + /// set.replace(Vec::with_capacity(10)); + /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 10); + /// ``` #[stable(feature = "set_recovery", since = "1.9.0")] pub fn replace(&mut self, value: T) -> Option { Recover::replace(&mut self.map, value) @@ -576,6 +599,16 @@ impl BTreeSet { /// The value may be any borrowed form of the set's value type, /// but the ordering on the borrowed form *must* match the /// ordering on the value type. + /// + /// # Examples + /// + /// ``` + /// use std::collections::BTreeSet; + /// + /// let mut set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect(); + /// assert_eq!(set.take(&2), Some(2)); + /// assert_eq!(set.take(&2), None); + /// ``` #[stable(feature = "set_recovery", since = "1.9.0")] pub fn take(&mut self, value: &Q) -> Option where T: Borrow, diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index f1e51e995c238..a611dc02469e8 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1390,6 +1390,5 @@ extern "rust-intrinsic" { /// Emits a `!nontemporal` store according to LLVM (see their docs). /// Probably will never become stable. - #[cfg(not(stage0))] pub fn nontemporal_store(ptr: *mut T, val: T); } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index b89aa134e7344..b5d24203b5e81 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -439,7 +439,7 @@ macro_rules! int_impl { } /// Checked integer division. Computes `self / rhs`, returning `None` - /// if `rhs == 0` or the operation results in overflow. + /// if `rhs == 0` or the division results in overflow. /// /// # Examples /// @@ -461,7 +461,7 @@ macro_rules! int_impl { } /// Checked integer remainder. Computes `self % rhs`, returning `None` - /// if `rhs == 0` or the operation results in overflow. + /// if `rhs == 0` or the division results in overflow. /// /// # Examples /// @@ -1607,7 +1607,7 @@ macro_rules! uint_impl { } /// Checked integer division. Computes `self / rhs`, returning `None` - /// if `rhs == 0` or the operation results in overflow. + /// if `rhs == 0`. /// /// # Examples /// @@ -1627,7 +1627,7 @@ macro_rules! uint_impl { } /// Checked integer remainder. Computes `self % rhs`, returning `None` - /// if `rhs == 0` or the operation results in overflow. + /// if `rhs == 0`. /// /// # Examples /// diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 29a9e1aadaf3c..c3bd6a2bc187d 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -53,7 +53,7 @@ pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8), pub unsafe extern fn __rust_start_panic(_data: usize, _vtable: usize) -> u32 { abort(); - #[cfg(unix)] + #[cfg(any(unix, target_os = "cloudabi"))] unsafe fn abort() -> ! { extern crate libc; libc::abort(); diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index 6b8da7a51ceb8..92e40e8f26d40 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -68,6 +68,7 @@ mod imp; // i686-pc-windows-gnu and all others #[cfg(any(all(unix, not(target_os = "emscripten")), + target_os = "cloudabi", target_os = "redox", all(windows, target_arch = "x86", target_env = "gnu")))] #[path = "gcc.rs"] diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 4300c97d0ff66..50e70e3bce70b 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -221,6 +221,21 @@ impl Span { } } + /// The `Span` for the tokens in the previous macro expansion from which + /// `self` was generated from, if any. + #[unstable(feature = "proc_macro", issue = "38356")] + pub fn parent(&self) -> Option { + self.0.ctxt().outer().expn_info().map(|i| Span(i.call_site)) + } + + /// The span for the origin source code that `self` was generated from. If + /// this `Span` wasn't generated from other macro expansions then the return + /// value is the same as `*self`. + #[unstable(feature = "proc_macro", issue = "38356")] + pub fn source(&self) -> Span { + Span(self.0.source_callsite()) + } + /// Get the starting line/column in the source file for this span. #[unstable(feature = "proc_macro", issue = "38356")] pub fn start(&self) -> LineColumn { diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 1f7e7000d6555..059181d2a6a57 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -995,9 +995,10 @@ impl<'a> LoweringContext<'a> { ); let hir_bounds = self.lower_bounds(bounds, itctx); + // Set the name to `impl Bound1 + Bound2` + let name = Symbol::intern(&pprust::ty_to_string(t)); self.in_band_ty_params.push(hir::TyParam { - // Set the name to `impl Bound1 + Bound2` - name: Symbol::intern(&pprust::ty_to_string(t)), + name, id: def_node_id, bounds: hir_bounds, default: None, @@ -1009,7 +1010,7 @@ impl<'a> LoweringContext<'a> { hir::TyPath(hir::QPath::Resolved(None, P(hir::Path { span, def: Def::TyParam(DefId::local(def_index)), - segments: vec![].into(), + segments: hir_vec![hir::PathSegment::from_name(name)], }))) }, ImplTraitContext::Disallowed => { diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 57120d61e7c7b..c31a5c9d86d77 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -155,8 +155,8 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind { Bool(value) }); -impl_stable_hash_for!(enum ::syntax::ast::IntTy { Is, I8, I16, I32, I64, I128 }); -impl_stable_hash_for!(enum ::syntax::ast::UintTy { Us, U8, U16, U32, U64, U128 }); +impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 }); +impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 }); impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 }); impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal }); impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst }); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index becaf78f7eca5..44f23c11b04c3 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -175,4 +175,5 @@ fn noop() { // Build the diagnostics array at the end so that the metadata includes error use sites. +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc, DIAGNOSTICS } diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 054cb2340ada3..8ffea62f6be51 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -145,7 +145,7 @@ impl<'tcx> MemoryPointer { } -#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)] +#[derive(Copy, Clone, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)] pub struct AllocId(pub u64); impl fmt::Display for AllocId { diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 6ad9bd94bf25c..05b1d584e9c4e 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1082,6 +1082,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "gather borrowck statistics"), no_landing_pads: bool = (false, parse_bool, [TRACKED], "omit landing pads for unwinding"), + fewer_names: bool = (false, parse_bool, [TRACKED], + "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR)"), debug_llvm: bool = (false, parse_bool, [UNTRACKED], "enable debug output from LLVM"), meta_stats: bool = (false, parse_bool, [UNTRACKED], @@ -2811,6 +2813,10 @@ mod tests { opts.debugging_opts.no_landing_pads = true; assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); + opts = reference.clone(); + opts.debugging_opts.fewer_names = true; + assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); + opts = reference.clone(); opts.debugging_opts.no_trans = true; assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 54bcc64d0685d..43dbb8d7e1375 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -18,7 +18,7 @@ use lint; use middle::allocator::AllocatorKind; use middle::dependency_format; use session::search_paths::PathKind; -use session::config::{BorrowckMode, DebugInfoLevel}; +use session::config::{BorrowckMode, DebugInfoLevel, OutputType}; use ty::tls; use util::nodemap::{FxHashMap, FxHashSet}; use util::common::{duration_to_secs_str, ErrorReported}; @@ -504,6 +504,13 @@ impl Session { pub fn linker_flavor(&self) -> LinkerFlavor { self.opts.debugging_opts.linker_flavor.unwrap_or(self.target.target.linker_flavor) } + + pub fn fewer_names(&self) -> bool { + let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly) || + self.opts.output_types.contains_key(&OutputType::Bitcode); + self.opts.debugging_opts.fewer_names || !more_names + } + pub fn no_landing_pads(&self) -> bool { self.opts.debugging_opts.no_landing_pads || self.panic_strategy() == PanicStrategy::Abort } @@ -642,6 +649,7 @@ impl Session { IncrCompSession::Active { ref session_directory, .. } => { session_directory.clone() } + IncrCompSession::InvalidBecauseOfErrors { .. } => return, _ => bug!("Trying to invalidate IncrCompSession `{:?}`", *incr_comp_session), }; diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index e21eb8bbf8ad2..87742fe91627e 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -754,13 +754,13 @@ impl<'tcx> CommonTypes<'tcx> { char: mk(TyChar), never: mk(TyNever), err: mk(TyError), - isize: mk(TyInt(ast::IntTy::Is)), + isize: mk(TyInt(ast::IntTy::Isize)), i8: mk(TyInt(ast::IntTy::I8)), i16: mk(TyInt(ast::IntTy::I16)), i32: mk(TyInt(ast::IntTy::I32)), i64: mk(TyInt(ast::IntTy::I64)), i128: mk(TyInt(ast::IntTy::I128)), - usize: mk(TyUint(ast::UintTy::Us)), + usize: mk(TyUint(ast::UintTy::Usize)), u8: mk(TyUint(ast::UintTy::U8)), u16: mk(TyUint(ast::UintTy::U16)), u32: mk(TyUint(ast::UintTy::U32)), @@ -895,31 +895,29 @@ pub struct InterpretInterner<'tcx> { allocs: FxHashSet<&'tcx interpret::Allocation>, /// Allows obtaining function instance handles via a unique identifier - functions: FxHashMap>, + functions: FxHashMap>, /// Inverse map of `interpret_functions`. /// Used so we don't allocate a new pointer every time we need one - function_cache: FxHashMap, u64>, + function_cache: FxHashMap, interpret::AllocId>, /// Allows obtaining const allocs via a unique identifier - alloc_by_id: FxHashMap, + alloc_by_id: FxHashMap, /// The AllocId to assign to the next new regular allocation. /// Always incremented, never gets smaller. - next_id: u64, + next_id: interpret::AllocId, /// Allows checking whether a constant already has an allocation - /// - /// The pointers are to the beginning of an `alloc_by_id` allocation - alloc_cache: FxHashMap, interpret::Pointer>, + alloc_cache: FxHashMap, interpret::AllocId>, /// A cache for basic byte allocations keyed by their contents. This is used to deduplicate /// allocations for string and bytestring literals. - literal_alloc_cache: FxHashMap, u64>, + literal_alloc_cache: FxHashMap, interpret::AllocId>, } impl<'tcx> InterpretInterner<'tcx> { - pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> u64 { + pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> interpret::AllocId { if let Some(&alloc_id) = self.function_cache.get(&instance) { return alloc_id; } @@ -932,14 +930,14 @@ impl<'tcx> InterpretInterner<'tcx> { pub fn get_fn( &self, - id: u64, + id: interpret::AllocId, ) -> Option> { self.functions.get(&id).cloned() } pub fn get_alloc( &self, - id: u64, + id: interpret::AllocId, ) -> Option<&'tcx interpret::Allocation> { self.alloc_by_id.get(&id).cloned() } @@ -947,14 +945,14 @@ impl<'tcx> InterpretInterner<'tcx> { pub fn get_cached( &self, global_id: interpret::GlobalId<'tcx>, - ) -> Option { + ) -> Option { self.alloc_cache.get(&global_id).cloned() } pub fn cache( &mut self, global_id: interpret::GlobalId<'tcx>, - ptr: interpret::Pointer, + ptr: interpret::AllocId, ) { if let Some(old) = self.alloc_cache.insert(global_id, ptr) { bug!("tried to cache {:?}, but was already existing as {:#?}", global_id, old); @@ -963,7 +961,7 @@ impl<'tcx> InterpretInterner<'tcx> { pub fn intern_at_reserved( &mut self, - id: u64, + id: interpret::AllocId, alloc: &'tcx interpret::Allocation, ) { if let Some(old) = self.alloc_by_id.insert(id, alloc) { @@ -975,9 +973,9 @@ impl<'tcx> InterpretInterner<'tcx> { /// yet have an allocation backing it. pub fn reserve( &mut self, - ) -> u64 { + ) -> interpret::AllocId { let next = self.next_id; - self.next_id = self.next_id + self.next_id.0 = self.next_id.0 .checked_add(1) .expect("You overflowed a u64 by incrementing by 1... \ You've just earned yourself a free drink if we ever meet. \ @@ -1069,7 +1067,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } /// Allocates a byte or string literal for `mir::interpret` - pub fn allocate_cached(self, bytes: &[u8]) -> u64 { + pub fn allocate_cached(self, bytes: &[u8]) -> interpret::AllocId { // check whether we already allocated this literal or a constant with the same memory if let Some(&alloc_id) = self.interpret_interner.borrow().literal_alloc_cache.get(bytes) { return alloc_id; @@ -1912,7 +1910,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> { match tm { - ast::IntTy::Is => self.types.isize, + ast::IntTy::Isize => self.types.isize, ast::IntTy::I8 => self.types.i8, ast::IntTy::I16 => self.types.i16, ast::IntTy::I32 => self.types.i32, @@ -1923,7 +1921,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn mk_mach_uint(self, tm: ast::UintTy) -> Ty<'tcx> { match tm { - ast::UintTy::Us => self.types.usize, + ast::UintTy::Usize => self.types.usize, ast::UintTy::U8 => self.types.u8, ast::UintTy::U16 => self.types.u16, ast::UintTy::U32 => self.types.u32, diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 2a8c259dff89b..34a7d4ad7cfd0 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -520,7 +520,7 @@ impl<'a, 'tcx> Integer { attr::SignedInt(IntTy::I32) | attr::UnsignedInt(UintTy::U32) => I32, attr::SignedInt(IntTy::I64) | attr::UnsignedInt(UintTy::U64) => I64, attr::SignedInt(IntTy::I128) | attr::UnsignedInt(UintTy::U128) => I128, - attr::SignedInt(IntTy::Is) | attr::UnsignedInt(UintTy::Us) => { + attr::SignedInt(IntTy::Isize) | attr::UnsignedInt(UintTy::Usize) => { dl.ptr_sized_integer() } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 2cea8c01cdf96..e5f6ac8853067 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1575,7 +1575,7 @@ impl ReprOptions { pub fn linear(&self) -> bool { self.flags.contains(ReprFlags::IS_LINEAR) } pub fn discr_type(&self) -> attr::IntType { - self.int.unwrap_or(attr::SignedInt(ast::IntTy::Is)) + self.int.unwrap_or(attr::SignedInt(ast::IntTy::Isize)) } /// Returns true if this `#[repr()]` should inhabit "smart enum diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 433c72f4b2ca6..cf784b7cafb87 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1478,13 +1478,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } - pub fn is_uint(&self) -> bool { - match self.sty { - TyInfer(IntVar(_)) | TyUint(ast::UintTy::Us) => true, - _ => false - } - } - pub fn is_char(&self) -> bool { match self.sty { TyChar => true, @@ -1512,7 +1505,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { pub fn is_machine(&self) -> bool { match self.sty { - TyInt(ast::IntTy::Is) | TyUint(ast::UintTy::Us) => false, + TyInt(ast::IntTy::Isize) | TyUint(ast::UintTy::Usize) => false, TyInt(..) | TyUint(..) | TyFloat(..) => true, _ => false, } diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 85052052b32f7..638859af0f7d3 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -55,7 +55,7 @@ macro_rules! typed_literal { SignedInt(ast::IntTy::I32) => ConstInt::I32($lit), SignedInt(ast::IntTy::I64) => ConstInt::I64($lit), SignedInt(ast::IntTy::I128) => ConstInt::I128($lit), - SignedInt(ast::IntTy::Is) => match $tcx.sess.target.isize_ty { + SignedInt(ast::IntTy::Isize) => match $tcx.sess.target.isize_ty { ast::IntTy::I16 => ConstInt::Isize(ConstIsize::Is16($lit)), ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32($lit)), ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64($lit)), @@ -66,7 +66,7 @@ macro_rules! typed_literal { UnsignedInt(ast::UintTy::U32) => ConstInt::U32($lit), UnsignedInt(ast::UintTy::U64) => ConstInt::U64($lit), UnsignedInt(ast::UintTy::U128) => ConstInt::U128($lit), - UnsignedInt(ast::UintTy::Us) => match $tcx.sess.target.usize_ty { + UnsignedInt(ast::UintTy::Usize) => match $tcx.sess.target.usize_ty { ast::UintTy::U16 => ConstInt::Usize(ConstUsize::Us16($lit)), ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32($lit)), ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64($lit)), @@ -84,13 +84,13 @@ impl IntTypeExt for attr::IntType { SignedInt(ast::IntTy::I32) => tcx.types.i32, SignedInt(ast::IntTy::I64) => tcx.types.i64, SignedInt(ast::IntTy::I128) => tcx.types.i128, - SignedInt(ast::IntTy::Is) => tcx.types.isize, + SignedInt(ast::IntTy::Isize) => tcx.types.isize, UnsignedInt(ast::UintTy::U8) => tcx.types.u8, UnsignedInt(ast::UintTy::U16) => tcx.types.u16, UnsignedInt(ast::UintTy::U32) => tcx.types.u32, UnsignedInt(ast::UintTy::U64) => tcx.types.u64, UnsignedInt(ast::UintTy::U128) => tcx.types.u128, - UnsignedInt(ast::UintTy::Us) => tcx.types.usize, + UnsignedInt(ast::UintTy::Usize) => tcx.types.usize, } } @@ -105,13 +105,13 @@ impl IntTypeExt for attr::IntType { (SignedInt(ast::IntTy::I32), ConstInt::I32(_)) => {}, (SignedInt(ast::IntTy::I64), ConstInt::I64(_)) => {}, (SignedInt(ast::IntTy::I128), ConstInt::I128(_)) => {}, - (SignedInt(ast::IntTy::Is), ConstInt::Isize(_)) => {}, + (SignedInt(ast::IntTy::Isize), ConstInt::Isize(_)) => {}, (UnsignedInt(ast::UintTy::U8), ConstInt::U8(_)) => {}, (UnsignedInt(ast::UintTy::U16), ConstInt::U16(_)) => {}, (UnsignedInt(ast::UintTy::U32), ConstInt::U32(_)) => {}, (UnsignedInt(ast::UintTy::U64), ConstInt::U64(_)) => {}, (UnsignedInt(ast::UintTy::U128), ConstInt::U128(_)) => {}, - (UnsignedInt(ast::UintTy::Us), ConstInt::Usize(_)) => {}, + (UnsignedInt(ast::UintTy::Usize), ConstInt::Usize(_)) => {}, _ => bug!("disr type mismatch: {:?} vs {:?}", self, val), } } diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 81cd63b5407c3..418bd4b5effc6 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -133,8 +133,8 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, (&LitKind::Int(I128_OVERFLOW, Signed(IntTy::I128)), _) => { Some(I128(i128::min_value())) }, - (&LitKind::Int(n, _), &ty::TyInt(IntTy::Is)) | - (&LitKind::Int(n, Signed(IntTy::Is)), _) => { + (&LitKind::Int(n, _), &ty::TyInt(IntTy::Isize)) | + (&LitKind::Int(n, Signed(IntTy::Isize)), _) => { match tcx.sess.target.isize_ty { IntTy::I16 => if n == I16_OVERFLOW { Some(Isize(Is16(i16::min_value()))) @@ -478,7 +478,7 @@ fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::TyInt(ast::IntTy::I32) => Ok(Integral(I32(v as i128 as i32))), ty::TyInt(ast::IntTy::I64) => Ok(Integral(I64(v as i128 as i64))), ty::TyInt(ast::IntTy::I128) => Ok(Integral(I128(v as i128))), - ty::TyInt(ast::IntTy::Is) => { + ty::TyInt(ast::IntTy::Isize) => { Ok(Integral(Isize(ConstIsize::new_truncating(v as i128, tcx.sess.target.isize_ty)))) }, ty::TyUint(ast::UintTy::U8) => Ok(Integral(U8(v as u8))), @@ -486,7 +486,7 @@ fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::TyUint(ast::UintTy::U32) => Ok(Integral(U32(v as u32))), ty::TyUint(ast::UintTy::U64) => Ok(Integral(U64(v as u64))), ty::TyUint(ast::UintTy::U128) => Ok(Integral(U128(v as u128))), - ty::TyUint(ast::UintTy::Us) => { + ty::TyUint(ast::UintTy::Usize) => { Ok(Integral(Usize(ConstUsize::new_truncating(v, tcx.sess.target.usize_ty)))) }, ty::TyFloat(fty) => { diff --git a/src/librustc_const_eval/lib.rs b/src/librustc_const_eval/lib.rs index 9d636b48bd0c5..b4563f6cf2e75 100644 --- a/src/librustc_const_eval/lib.rs +++ b/src/librustc_const_eval/lib.rs @@ -56,4 +56,5 @@ pub fn provide(providers: &mut Providers) { } // Build the diagnostics array at the end so that the metadata includes error use sites. +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_const_eval, DIAGNOSTICS } diff --git a/src/librustc_const_math/err.rs b/src/librustc_const_math/err.rs index 1e9c2badd6860..bd0a332436e64 100644 --- a/src/librustc_const_math/err.rs +++ b/src/librustc_const_math/err.rs @@ -75,13 +75,13 @@ impl ConstMathErr { ULitOutOfRange(ast::UintTy::U32) => "literal out of range for u32", ULitOutOfRange(ast::UintTy::U64) => "literal out of range for u64", ULitOutOfRange(ast::UintTy::U128) => "literal out of range for u128", - ULitOutOfRange(ast::UintTy::Us) => "literal out of range for usize", + ULitOutOfRange(ast::UintTy::Usize) => "literal out of range for usize", LitOutOfRange(ast::IntTy::I8) => "literal out of range for i8", LitOutOfRange(ast::IntTy::I16) => "literal out of range for i16", LitOutOfRange(ast::IntTy::I32) => "literal out of range for i32", LitOutOfRange(ast::IntTy::I64) => "literal out of range for i64", LitOutOfRange(ast::IntTy::I128) => "literal out of range for i128", - LitOutOfRange(ast::IntTy::Is) => "literal out of range for isize", + LitOutOfRange(ast::IntTy::Isize) => "literal out of range for isize", } } } diff --git a/src/librustc_const_math/int.rs b/src/librustc_const_math/int.rs index 08473d729e4e5..4ec27d7ade560 100644 --- a/src/librustc_const_math/int.rs +++ b/src/librustc_const_math/int.rs @@ -12,8 +12,8 @@ use std::cmp::Ordering; use syntax::attr::IntType; use syntax::ast::{IntTy, UintTy}; -use super::is::*; -use super::us::*; +use super::isize::*; +use super::usize::*; use super::err::*; #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, Hash, Eq, PartialEq)] @@ -83,7 +83,7 @@ impl ConstInt { UintTy::U16 if val <= ubounds::U16MAX => Some(U16(val as u16)), UintTy::U32 if val <= ubounds::U32MAX => Some(U32(val as u32)), UintTy::U64 if val <= ubounds::U64MAX => Some(U64(val as u64)), - UintTy::Us if val <= ubounds::U64MAX => ConstUsize::new(val as u64, usize_ty).ok() + UintTy::Usize if val <= ubounds::U64MAX => ConstUsize::new(val as u64, usize_ty).ok() .map(Usize), UintTy::U128 => Some(U128(val)), _ => None @@ -98,7 +98,7 @@ impl ConstInt { IntTy::I16 if val <= ibounds::I16MAX => Some(I16(val as i16)), IntTy::I32 if val <= ibounds::I32MAX => Some(I32(val as i32)), IntTy::I64 if val <= ibounds::I64MAX => Some(I64(val as i64)), - IntTy::Is if val <= ibounds::I64MAX => ConstIsize::new(val as i64, isize_ty).ok() + IntTy::Isize if val <= ibounds::I64MAX => ConstIsize::new(val as i64, isize_ty).ok() .map(Isize), IntTy::I128 => Some(I128(val)), _ => None @@ -112,7 +112,7 @@ impl ConstInt { UintTy::U16 => U16(val as u16), UintTy::U32 => U32(val as u32), UintTy::U64 => U64(val as u64), - UintTy::Us => Usize(ConstUsize::new_truncating(val, usize_ty)), + UintTy::Usize => Usize(ConstUsize::new_truncating(val, usize_ty)), UintTy::U128 => U128(val) } } @@ -124,7 +124,7 @@ impl ConstInt { IntTy::I16 => I16(val as i16), IntTy::I32 => I32(val as i32), IntTy::I64 => I64(val as i64), - IntTy::Is => Isize(ConstIsize::new_truncating(val, isize_ty)), + IntTy::Isize => Isize(ConstIsize::new_truncating(val, isize_ty)), IntTy::I128 => I128(val) } } @@ -280,13 +280,13 @@ impl ConstInt { ConstInt::I32(_) => IntType::SignedInt(IntTy::I32), ConstInt::I64(_) => IntType::SignedInt(IntTy::I64), ConstInt::I128(_) => IntType::SignedInt(IntTy::I128), - ConstInt::Isize(_) => IntType::SignedInt(IntTy::Is), + ConstInt::Isize(_) => IntType::SignedInt(IntTy::Isize), ConstInt::U8(_) => IntType::UnsignedInt(UintTy::U8), ConstInt::U16(_) => IntType::UnsignedInt(UintTy::U16), ConstInt::U32(_) => IntType::UnsignedInt(UintTy::U32), ConstInt::U64(_) => IntType::UnsignedInt(UintTy::U64), ConstInt::U128(_) => IntType::UnsignedInt(UintTy::U128), - ConstInt::Usize(_) => IntType::UnsignedInt(UintTy::Us), + ConstInt::Usize(_) => IntType::UnsignedInt(UintTy::Usize), } } } diff --git a/src/librustc_const_math/is.rs b/src/librustc_const_math/isize.rs similarity index 92% rename from src/librustc_const_math/is.rs rename to src/librustc_const_math/isize.rs index 50dfb60112991..18acc782775d8 100644 --- a/src/librustc_const_math/is.rs +++ b/src/librustc_const_math/isize.rs @@ -38,9 +38,9 @@ impl ConstIsize { pub fn new(i: i64, isize_ty: ast::IntTy) -> Result { match isize_ty { ast::IntTy::I16 if i as i16 as i64 == i => Ok(Is16(i as i16)), - ast::IntTy::I16 => Err(LitOutOfRange(ast::IntTy::Is)), + ast::IntTy::I16 => Err(LitOutOfRange(ast::IntTy::Isize)), ast::IntTy::I32 if i as i32 as i64 == i => Ok(Is32(i as i32)), - ast::IntTy::I32 => Err(LitOutOfRange(ast::IntTy::Is)), + ast::IntTy::I32 => Err(LitOutOfRange(ast::IntTy::Isize)), ast::IntTy::I64 => Ok(Is64(i)), _ => unreachable!(), } diff --git a/src/librustc_const_math/lib.rs b/src/librustc_const_math/lib.rs index 095b8bb50dc6c..2d98bc48d2816 100644 --- a/src/librustc_const_math/lib.rs +++ b/src/librustc_const_math/lib.rs @@ -30,12 +30,12 @@ extern crate serialize as rustc_serialize; // used by deriving mod float; mod int; -mod us; -mod is; +mod usize; +mod isize; mod err; pub use float::*; pub use int::*; -pub use us::*; -pub use is::*; +pub use usize::*; +pub use isize::*; pub use err::{ConstMathErr, Op}; diff --git a/src/librustc_const_math/us.rs b/src/librustc_const_math/usize.rs similarity index 99% rename from src/librustc_const_math/us.rs rename to src/librustc_const_math/usize.rs index 9876bc4d779a0..56995f08f05b8 100644 --- a/src/librustc_const_math/us.rs +++ b/src/librustc_const_math/usize.rs @@ -38,9 +38,9 @@ impl ConstUsize { pub fn new(i: u64, usize_ty: ast::UintTy) -> Result { match usize_ty { ast::UintTy::U16 if i as u16 as u64 == i => Ok(Us16(i as u16)), - ast::UintTy::U16 => Err(ULitOutOfRange(ast::UintTy::Us)), + ast::UintTy::U16 => Err(ULitOutOfRange(ast::UintTy::Usize)), ast::UintTy::U32 if i as u32 as u64 == i => Ok(Us32(i as u32)), - ast::UintTy::U32 => Err(ULitOutOfRange(ast::UintTy::Us)), + ast::UintTy::U32 => Err(ULitOutOfRange(ast::UintTy::Usize)), ast::UintTy::U64 => Ok(Us64(i)), _ => unreachable!(), } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 5fa823659287a..223c602ccd34a 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1268,6 +1268,14 @@ fn exit_on_err() -> ! { panic!(); } +#[cfg(stage0)] +pub fn diagnostics_registry() -> errors::registry::Registry { + use errors::registry::Registry; + + Registry::new(&[]) +} + +#[cfg(not(stage0))] pub fn diagnostics_registry() -> errors::registry::Registry { use errors::registry::Registry; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index c109a47f79867..5456b0d252b67 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -140,7 +140,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { match lit.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_)) | ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => { - let int_type = if let ast::IntTy::Is = t { + let int_type = if let ast::IntTy::Isize = t { cx.sess().target.isize_ty } else { t @@ -163,7 +163,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { }; } ty::TyUint(t) => { - let uint_type = if let ast::UintTy::Us = t { + let uint_type = if let ast::UintTy::Usize = t { cx.sess().target.usize_ty } else { t @@ -230,7 +230,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { // warnings are consistent between 32- and 64-bit platforms fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) { match int_ty { - ast::IntTy::Is => (i64::min_value() as i128, i64::max_value() as i128), + ast::IntTy::Isize => (i64::min_value() as i128, i64::max_value() as i128), ast::IntTy::I8 => (i8::min_value() as i64 as i128, i8::max_value() as i128), ast::IntTy::I16 => (i16::min_value() as i64 as i128, i16::max_value() as i128), ast::IntTy::I32 => (i32::min_value() as i64 as i128, i32::max_value() as i128), @@ -241,7 +241,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) { match uint_ty { - ast::UintTy::Us => (u64::min_value() as u128, u64::max_value() as u128), + ast::UintTy::Usize => (u64::min_value() as u128, u64::max_value() as u128), ast::UintTy::U8 => (u8::min_value() as u128, u8::max_value() as u128), ast::UintTy::U16 => (u16::min_value() as u128, u16::max_value() as u128), ast::UintTy::U32 => (u32::min_value() as u128, u32::max_value() as u128), @@ -252,7 +252,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn int_ty_bits(int_ty: ast::IntTy, isize_ty: ast::IntTy) -> u64 { match int_ty { - ast::IntTy::Is => int_ty_bits(isize_ty, isize_ty), + ast::IntTy::Isize => int_ty_bits(isize_ty, isize_ty), ast::IntTy::I8 => 8, ast::IntTy::I16 => 16 as u64, ast::IntTy::I32 => 32, @@ -263,7 +263,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn uint_ty_bits(uint_ty: ast::UintTy, usize_ty: ast::UintTy) -> u64 { match uint_ty { - ast::UintTy::Us => uint_ty_bits(usize_ty, usize_ty), + ast::UintTy::Usize => uint_ty_bits(usize_ty, usize_ty), ast::UintTy::U8 => 8, ast::UintTy::U16 => 16, ast::UintTy::U32 => 32, @@ -387,7 +387,7 @@ fn is_ffi_safe(ty: attr::IntType) -> bool { attr::SignedInt(ast::IntTy::I32) | attr::UnsignedInt(ast::UintTy::U32) | attr::SignedInt(ast::IntTy::I64) | attr::UnsignedInt(ast::UintTy::U64) | attr::SignedInt(ast::IntTy::I128) | attr::UnsignedInt(ast::UintTy::U128) => true, - attr::SignedInt(ast::IntTy::Is) | attr::UnsignedInt(ast::UintTy::Us) => false + attr::SignedInt(ast::IntTy::Isize) | attr::UnsignedInt(ast::UintTy::Usize) => false } } diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index 7d65349446516..6cb1a2b53342b 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -514,7 +514,7 @@ pub enum ModuleBuffer {} #[link(name = "rustllvm", kind = "static")] extern "C" { // Create and destroy contexts. - pub fn LLVMContextCreate() -> ContextRef; + pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> ContextRef; pub fn LLVMContextDispose(C: ContextRef); pub fn LLVMGetMDKindIDInContext(C: ContextRef, Name: *const c_char, SLen: c_uint) -> c_uint; @@ -538,9 +538,6 @@ extern "C" { /// See llvm::LLVMTypeKind::getTypeID. pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind; - /// See llvm::Value::getContext - pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef; - // Operations on integer types pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef; pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef; @@ -812,13 +809,12 @@ extern "C" { Bundle: OperandBundleDefRef, Name: *const c_char) -> ValueRef; - pub fn LLVMRustBuildLandingPad(B: BuilderRef, - Ty: TypeRef, - PersFn: ValueRef, - NumClauses: c_uint, - Name: *const c_char, - F: ValueRef) - -> ValueRef; + pub fn LLVMBuildLandingPad(B: BuilderRef, + Ty: TypeRef, + PersFn: ValueRef, + NumClauses: c_uint, + Name: *const c_char) + -> ValueRef; pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef; pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef; diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index a65ddcecf8874..18117533c18f1 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -58,4 +58,5 @@ pub mod cstore; pub mod dynamic_lib; pub mod locator; +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_metadata, DIAGNOSTICS } diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index ee0b7bb7a8bc4..d3cc952759058 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -392,7 +392,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ast::IntTy::I32 => ConstInt::I32(-1), ast::IntTy::I64 => ConstInt::I64(-1), ast::IntTy::I128 => ConstInt::I128(-1), - ast::IntTy::Is => { + ast::IntTy::Isize => { let int_ty = self.hir.tcx().sess.target.isize_ty; let val = ConstIsize::new(-1, int_ty).unwrap(); ConstInt::Isize(val) @@ -424,7 +424,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ast::IntTy::I32 => ConstInt::I32(i32::min_value()), ast::IntTy::I64 => ConstInt::I64(i64::min_value()), ast::IntTy::I128 => ConstInt::I128(i128::min_value()), - ast::IntTy::Is => { + ast::IntTy::Isize => { let int_ty = self.hir.tcx().sess.target.isize_ty; let min = match int_ty { ast::IntTy::I16 => std::i16::MIN as i64, diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index 8486c63baac66..a3350cb1671d2 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ast::UintTy::U32 => ConstInt::U32(0), ast::UintTy::U64 => ConstInt::U64(0), ast::UintTy::U128 => ConstInt::U128(0), - ast::UintTy::Us => { + ast::UintTy::Usize => { let uint_ty = self.hir.tcx().sess.target.usize_ty; let val = ConstUsize::new(0, uint_ty).unwrap(); ConstInt::Usize(val) @@ -95,7 +95,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ast::IntTy::I32 => ConstInt::I32(0), ast::IntTy::I64 => ConstInt::I64(0), ast::IntTy::I128 => ConstInt::I128(0), - ast::IntTy::Is => { + ast::IntTy::Isize => { let int_ty = self.hir.tcx().sess.target.isize_ty; let val = ConstIsize::new(0, int_ty).unwrap(); ConstInt::Isize(val) diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 6f4a28fb28f01..b476ea5685229 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -49,7 +49,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { IntTy::I32 => v as i32 as u128, IntTy::I64 => v as i64 as u128, IntTy::I128 => v as u128, - IntTy::Is => { + IntTy::Isize => { let ty = self.tcx.sess.target.isize_ty; self.int_to_int(v, ty) } @@ -62,7 +62,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { UintTy::U32 => v as u32 as u128, UintTy::U64 => v as u64 as u128, UintTy::U128 => v, - UintTy::Us => { + UintTy::Usize => { let ty = self.tcx.sess.target.usize_ty; self.int_to_uint(v, ty) } @@ -124,8 +124,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { match ty.sty { // Casting to a reference or fn pointer is not permitted by rustc, no need to support it here. TyRawPtr(_) | - TyInt(IntTy::Is) | - TyUint(UintTy::Us) => Ok(PrimVal::Ptr(ptr)), + TyInt(IntTy::Isize) | + TyUint(UintTy::Usize) => Ok(PrimVal::Ptr(ptr)), TyInt(_) | TyUint(_) => err!(ReadPointerAsBytes), _ => err!(Unimplemented(format!("ptr to {:?} cast", ty))), } diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs index a37cf41baaba3..ef27c636ce08c 100644 --- a/src/librustc_mir/interpret/const_eval.rs +++ b/src/librustc_mir/interpret/const_eval.rs @@ -12,7 +12,7 @@ use rustc_data_structures::indexed_vec::Idx; use syntax::ast::Mutability; use syntax::codemap::Span; -use rustc::mir::interpret::{EvalResult, EvalError, EvalErrorKind, GlobalId, Value, Pointer, PrimVal}; +use rustc::mir::interpret::{EvalResult, EvalError, EvalErrorKind, GlobalId, Value, MemoryPointer, Pointer, PrimVal}; use super::{Place, EvalContext, StackPopCleanup, ValTy}; use rustc_const_math::ConstInt; @@ -67,7 +67,7 @@ pub fn eval_body<'a, 'tcx>( layout.align, None, )?; - tcx.interpret_interner.borrow_mut().cache(cid, ptr.into()); + tcx.interpret_interner.borrow_mut().cache(cid, ptr.alloc_id); let cleanup = StackPopCleanup::MarkStatic(Mutability::Immutable); let name = ty::tls::with(|tcx| tcx.item_path_str(instance.def_id())); trace!("const_eval: pushing stack frame for global: {}", name); @@ -81,8 +81,8 @@ pub fn eval_body<'a, 'tcx>( while ecx.step()? {} } - let value = tcx.interpret_interner.borrow().get_cached(cid).expect("global not cached"); - Ok((value, instance_ty)) + let alloc = tcx.interpret_interner.borrow().get_cached(cid).expect("global not cached"); + Ok((MemoryPointer::new(alloc, 0).into(), instance_ty)) } pub fn eval_body_as_integer<'a, 'tcx>( @@ -106,7 +106,7 @@ pub fn eval_body_as_integer<'a, 'tcx>( TyInt(IntTy::I32) => ConstInt::I32(prim as i128 as i32), TyInt(IntTy::I64) => ConstInt::I64(prim as i128 as i64), TyInt(IntTy::I128) => ConstInt::I128(prim as i128), - TyInt(IntTy::Is) => ConstInt::Isize( + TyInt(IntTy::Isize) => ConstInt::Isize( ConstIsize::new(prim as i128 as i64, tcx.sess.target.isize_ty) .expect("miri should already have errored"), ), @@ -115,7 +115,7 @@ pub fn eval_body_as_integer<'a, 'tcx>( TyUint(UintTy::U32) => ConstInt::U32(prim as u32), TyUint(UintTy::U64) => ConstInt::U64(prim as u64), TyUint(UintTy::U128) => ConstInt::U128(prim), - TyUint(UintTy::Us) => ConstInt::Usize( + TyUint(UintTy::Usize) => ConstInt::Usize( ConstUsize::new(prim as u64, tcx.sess.target.usize_ty) .expect("miri should already have errored"), ), diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 89d0e91a7ec86..3af914a6c1360 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -950,8 +950,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { } pub fn read_global_as_value(&self, gid: GlobalId, layout: TyLayout) -> Value { - Value::ByRef(self.tcx.interpret_interner.borrow().get_cached(gid).expect("global not cached"), - layout.align) + let alloc = self.tcx.interpret_interner.borrow().get_cached(gid).expect("global not cached"); + Value::ByRef(MemoryPointer::new(alloc, 0).into(), layout.align) } pub fn force_allocation(&mut self, place: Place) -> EvalResult<'tcx, Place> { @@ -1165,7 +1165,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { I32 => 4, I64 => 8, I128 => 16, - Is => self.memory.pointer_size(), + Isize => self.memory.pointer_size(), }; PrimValKind::from_int_size(size) } @@ -1178,7 +1178,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { U32 => 4, U64 => 8, U128 => 16, - Us => self.memory.pointer_size(), + Usize => self.memory.pointer_size(), }; PrimValKind::from_uint_size(size) } @@ -1292,7 +1292,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { I32 => 4, I64 => 8, I128 => 16, - Is => self.memory.pointer_size(), + Isize => self.memory.pointer_size(), }; self.memory.read_primval(ptr, ptr_align, size, true)? } @@ -1305,7 +1305,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { U32 => 4, U64 => 8, U128 => 16, - Us => self.memory.pointer_size(), + Usize => self.memory.pointer_size(), }; self.memory.read_primval(ptr, ptr_align, size, false)? } diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 47a6bfeb37ba3..c2989dbaaf11f 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -2,7 +2,7 @@ //! This separation exists to ensure that no fancy miri features like //! interpreting common C functions leak into CTFE. -use rustc::mir::interpret::{EvalResult, PrimVal, MemoryPointer, AccessKind}; +use rustc::mir::interpret::{AllocId, EvalResult, PrimVal, MemoryPointer, AccessKind}; use super::{EvalContext, Place, ValTy, Memory}; use rustc::mir; @@ -89,12 +89,12 @@ pub trait Machine<'tcx>: Sized { fn add_lock<'a>( _mem: &mut Memory<'a, 'tcx, Self>, - _id: u64, + _id: AllocId, ) {} fn free_lock<'a>( _mem: &mut Memory<'a, 'tcx, Self>, - _id: u64, + _id: AllocId, _len: u64, ) -> EvalResult<'tcx> { Ok(()) diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 671fe29c0e1bc..3a28eae2d1c49 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -34,15 +34,15 @@ pub struct Memory<'a, 'tcx: 'a, M: Machine<'tcx>> { pub data: M::MemoryData, /// Helps guarantee that stack allocations aren't deallocated via `rust_deallocate` - alloc_kind: HashMap>, + alloc_kind: HashMap>, /// Actual memory allocations (arbitrary bytes, may contain pointers into other allocations). - alloc_map: HashMap, + alloc_map: HashMap, /// Actual memory allocations (arbitrary bytes, may contain pointers into other allocations). /// /// Stores statics while they are being processed, before they are interned and thus frozen - uninitialized_statics: HashMap, + uninitialized_statics: HashMap, /// Number of virtual bytes allocated. memory_usage: u64, @@ -73,17 +73,17 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { pub fn allocations<'x>( &'x self, ) -> impl Iterator { - self.alloc_map.iter().map(|(&id, alloc)| (AllocId(id), alloc)) + self.alloc_map.iter().map(|(&id, alloc)| (id, alloc)) } pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> MemoryPointer { let id = self.tcx.interpret_interner.borrow_mut().create_fn_alloc(instance); - MemoryPointer::new(AllocId(id), 0) + MemoryPointer::new(id, 0) } pub fn allocate_cached(&mut self, bytes: &[u8]) -> MemoryPointer { let id = self.tcx.allocate_cached(bytes); - MemoryPointer::new(AllocId(id), 0) + MemoryPointer::new(id, 0) } /// kind is `None` for statics @@ -121,7 +121,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { }, Some(MemoryKind::MutableStatic) => bug!("don't allocate mutable statics directly") } - Ok(MemoryPointer::new(AllocId(id), 0)) + Ok(MemoryPointer::new(id, 0)) } pub fn reallocate( @@ -136,8 +136,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { if ptr.offset != 0 { return err!(ReallocateNonBasePtr); } - if self.alloc_map.contains_key(&ptr.alloc_id.0) { - let alloc_kind = self.alloc_kind[&ptr.alloc_id.0]; + if self.alloc_map.contains_key(&ptr.alloc_id) { + let alloc_kind = self.alloc_kind[&ptr.alloc_id]; if alloc_kind != kind { return err!(ReallocatedWrongMemoryKind( format!("{:?}", alloc_kind), @@ -163,7 +163,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { } pub fn deallocate_local(&mut self, ptr: MemoryPointer) -> EvalResult<'tcx> { - match self.alloc_kind.get(&ptr.alloc_id.0).cloned() { + match self.alloc_kind.get(&ptr.alloc_id).cloned() { // for a constant like `const FOO: &i32 = &1;` the local containing // the `1` is referred to by the global. We transitively marked everything // the global refers to as static itself, so we don't free it here @@ -185,19 +185,19 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { return err!(DeallocateNonBasePtr); } - let alloc = match self.alloc_map.remove(&ptr.alloc_id.0) { + let alloc = match self.alloc_map.remove(&ptr.alloc_id) { Some(alloc) => alloc, - None => if self.uninitialized_statics.contains_key(&ptr.alloc_id.0) { + None => if self.uninitialized_statics.contains_key(&ptr.alloc_id) { return err!(DeallocatedWrongMemoryKind( "uninitializedstatic".to_string(), format!("{:?}", kind), )) - } else if self.tcx.interpret_interner.borrow().get_fn(ptr.alloc_id.0).is_some() { + } else if self.tcx.interpret_interner.borrow().get_fn(ptr.alloc_id).is_some() { return err!(DeallocatedWrongMemoryKind( "function".to_string(), format!("{:?}", kind), )) - } else if self.tcx.interpret_interner.borrow().get_alloc(ptr.alloc_id.0).is_some() { + } else if self.tcx.interpret_interner.borrow().get_alloc(ptr.alloc_id).is_some() { return err!(DeallocatedWrongMemoryKind( "static".to_string(), format!("{:?}", kind), @@ -207,14 +207,14 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { }, }; - let alloc_kind = self.alloc_kind.remove(&ptr.alloc_id.0).expect("alloc_map out of sync with alloc_kind"); + let alloc_kind = self.alloc_kind.remove(&ptr.alloc_id).expect("alloc_map out of sync with alloc_kind"); // It is okay for us to still holds locks on deallocation -- for example, we could store data we own // in a local, and the local could be deallocated (from StorageDead) before the function returns. // However, we should check *something*. For now, we make sure that there is no conflicting write // lock by another frame. We *have* to permit deallocation if we hold a read lock. // TODO: Figure out the exact rules here. - M::free_lock(self, ptr.alloc_id.0, alloc.bytes.len() as u64)?; + M::free_lock(self, ptr.alloc_id, alloc.bytes.len() as u64)?; if alloc_kind != kind { return err!(DeallocatedWrongMemoryKind( @@ -295,17 +295,17 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { pub fn get(&self, id: AllocId) -> EvalResult<'tcx, &Allocation> { // normal alloc? - match self.alloc_map.get(&id.0) { + match self.alloc_map.get(&id) { Some(alloc) => Ok(alloc), // uninitialized static alloc? - None => match self.uninitialized_statics.get(&id.0) { + None => match self.uninitialized_statics.get(&id) { Some(alloc) => Ok(alloc), None => { let int = self.tcx.interpret_interner.borrow(); // static alloc? - int.get_alloc(id.0) + int.get_alloc(id) // no alloc? produce an error - .ok_or_else(|| if int.get_fn(id.0).is_some() { + .ok_or_else(|| if int.get_fn(id).is_some() { EvalErrorKind::DerefFunctionPointer.into() } else { EvalErrorKind::DanglingPointerDeref.into() @@ -320,17 +320,17 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { id: AllocId, ) -> EvalResult<'tcx, &mut Allocation> { // normal alloc? - match self.alloc_map.get_mut(&id.0) { + match self.alloc_map.get_mut(&id) { Some(alloc) => Ok(alloc), // uninitialized static alloc? - None => match self.uninitialized_statics.get_mut(&id.0) { + None => match self.uninitialized_statics.get_mut(&id) { Some(alloc) => Ok(alloc), None => { let int = self.tcx.interpret_interner.borrow(); // no alloc or immutable alloc? produce an error - if int.get_alloc(id.0).is_some() { + if int.get_alloc(id).is_some() { err!(ModifiedConstantMemory) - } else if int.get_fn(id.0).is_some() { + } else if int.get_fn(id).is_some() { err!(DerefFunctionPointer) } else { err!(DanglingPointerDeref) @@ -348,7 +348,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { self.tcx .interpret_interner .borrow() - .get_fn(ptr.alloc_id.0) + .get_fn(ptr.alloc_id) .ok_or(EvalErrorKind::ExecuteMemory.into()) } @@ -372,21 +372,21 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { let (alloc, immutable) = // normal alloc? - match self.alloc_map.get(&id.0) { - Some(a) => (a, match self.alloc_kind[&id.0] { + match self.alloc_map.get(&id) { + Some(a) => (a, match self.alloc_kind[&id] { MemoryKind::Stack => " (stack)".to_owned(), MemoryKind::Machine(m) => format!(" ({:?})", m), MemoryKind::MutableStatic => " (static mut)".to_owned(), }), // uninitialized static alloc? - None => match self.uninitialized_statics.get(&id.0) { + None => match self.uninitialized_statics.get(&id) { Some(a) => (a, " (static in the process of initialization)".to_owned()), None => { let int = self.tcx.interpret_interner.borrow(); // static alloc? - match int.get_alloc(id.0) { + match int.get_alloc(id) { Some(a) => (a, "(immutable)".to_owned()), - None => if let Some(func) = int.get_fn(id.0) { + None => if let Some(func) = int.get_fn(id) { trace!("{} {}", msg, func); continue; } else { @@ -445,7 +445,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { let leaks: Vec<_> = self.alloc_map .keys() .filter_map(|key| if kinds[key] != MemoryKind::MutableStatic { - Some(AllocId(*key)) + Some(*key) } else { None }) @@ -528,7 +528,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { alloc: AllocId, mutability: Mutability, ) -> EvalResult<'tcx> { - match self.alloc_kind.get(&alloc.0) { + match self.alloc_kind.get(&alloc) { // do not go into immutable statics None | // or mutable statics @@ -550,13 +550,13 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { mutability ); if mutability == Mutability::Immutable { - let alloc = self.alloc_map.remove(&alloc_id.0); - let kind = self.alloc_kind.remove(&alloc_id.0); + let alloc = self.alloc_map.remove(&alloc_id); + let kind = self.alloc_kind.remove(&alloc_id); assert_ne!(kind, Some(MemoryKind::MutableStatic)); - let uninit = self.uninitialized_statics.remove(&alloc_id.0); + let uninit = self.uninitialized_statics.remove(&alloc_id); if let Some(alloc) = alloc.or(uninit) { let alloc = self.tcx.intern_const_alloc(alloc); - self.tcx.interpret_interner.borrow_mut().intern_at_reserved(alloc_id.0, alloc); + self.tcx.interpret_interner.borrow_mut().intern_at_reserved(alloc_id, alloc); // recurse into inner allocations for &alloc in alloc.relocations.values() { self.mark_inner_allocation_initialized(alloc, mutability)?; @@ -565,17 +565,17 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { return Ok(()); } // We are marking the static as initialized, so move it out of the uninit map - if let Some(uninit) = self.uninitialized_statics.remove(&alloc_id.0) { - self.alloc_map.insert(alloc_id.0, uninit); + if let Some(uninit) = self.uninitialized_statics.remove(&alloc_id) { + self.alloc_map.insert(alloc_id, uninit); } // do not use `self.get_mut(alloc_id)` here, because we might have already marked a // sub-element or have circular pointers (e.g. `Rc`-cycles) - let relocations = match self.alloc_map.get_mut(&alloc_id.0) { + let relocations = match self.alloc_map.get_mut(&alloc_id) { Some(&mut Allocation { ref mut relocations, .. }) => { - match self.alloc_kind.get(&alloc_id.0) { + match self.alloc_kind.get(&alloc_id) { // const eval results can refer to "locals". // E.g. `const Foo: &u32 = &1;` refers to the temp local that stores the `1` None | @@ -587,7 +587,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { }, } // overwrite or insert - self.alloc_kind.insert(alloc_id.0, MemoryKind::MutableStatic); + self.alloc_kind.insert(alloc_id, MemoryKind::MutableStatic); // take out the relocations vector to free the borrow on self, so we can call // mark recursively mem::replace(relocations, Default::default()) @@ -600,7 +600,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> { } // put back the relocations self.alloc_map - .get_mut(&alloc_id.0) + .get_mut(&alloc_id) .expect("checked above") .relocations = relocations; Ok(()) diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 097f769adcf1f..ac16118c7afd7 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -194,8 +194,9 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { promoted: None, }; let layout = self.layout_of(self.place_ty(mir_place))?; + let alloc = self.tcx.interpret_interner.borrow().get_cached(gid).expect("uncached global"); Place::Ptr { - ptr: self.tcx.interpret_interner.borrow().get_cached(gid).expect("uncached global"), + ptr: MemoryPointer::new(alloc, 0).into(), align: layout.align, extra: PlaceExtra::None, } diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs index 140da7e1097f5..2b0f9041d5115 100644 --- a/src/librustc_mir/interpret/step.rs +++ b/src/librustc_mir/interpret/step.rs @@ -180,7 +180,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { layout.align, None, )?; - self.tcx.interpret_interner.borrow_mut().cache(cid, ptr.into()); + self.tcx.interpret_interner.borrow_mut().cache(cid, ptr.alloc_id); let internally_mutable = !layout.ty.is_freeze(self.tcx, self.param_env, span); let mutability = if mutability == Mutability::Mutable || internally_mutable { Mutability::Mutable @@ -265,7 +265,7 @@ impl<'a, 'b, 'tcx, M: Machine<'tcx>> Visitor<'tcx> for ConstantExtractor<'a, 'b, layout.align, None, )?; - this.ecx.tcx.interpret_interner.borrow_mut().cache(cid, ptr.into()); + this.ecx.tcx.interpret_interner.borrow_mut().cache(cid, ptr.alloc_id); trace!("pushing stack frame for {:?}", index); this.ecx.push_stack_frame( this.instance, diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 4556a8ecc4bb9..e9e7e688f1f07 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -79,4 +79,5 @@ pub fn provide(providers: &mut Providers) { providers.const_eval = interpret::const_eval_provider; } +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_mir, DIAGNOSTICS } diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 1f463cea7643b..9e547285b16ba 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -292,13 +292,13 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { ty::TyChar => output.push_str("char"), ty::TyStr => output.push_str("str"), ty::TyNever => output.push_str("!"), - ty::TyInt(ast::IntTy::Is) => output.push_str("isize"), + ty::TyInt(ast::IntTy::Isize) => output.push_str("isize"), ty::TyInt(ast::IntTy::I8) => output.push_str("i8"), ty::TyInt(ast::IntTy::I16) => output.push_str("i16"), ty::TyInt(ast::IntTy::I32) => output.push_str("i32"), ty::TyInt(ast::IntTy::I64) => output.push_str("i64"), ty::TyInt(ast::IntTy::I128) => output.push_str("i128"), - ty::TyUint(ast::UintTy::Us) => output.push_str("usize"), + ty::TyUint(ast::UintTy::Usize) => output.push_str("usize"), ty::TyUint(ast::UintTy::U8) => output.push_str("u8"), ty::TyUint(ast::UintTy::U16) => output.push_str("u16"), ty::TyUint(ast::UintTy::U32) => output.push_str("u32"), diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 9a150abea6691..754c3bbd07406 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -45,6 +45,7 @@ mod mir_stats; pub mod no_asm; pub mod static_recursion; +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_passes, DIAGNOSTICS } pub fn provide(providers: &mut Providers) { diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index c0f830f1fbe2e..38df5986ce2a9 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -82,4 +82,5 @@ pub mod registry; pub mod load; pub mod build; +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_plugin, DIAGNOSTICS } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index bb0a4be49c2a8..d1dc54e7c3a8e 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1725,4 +1725,5 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Rc::new(visitor.access_levels) } +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_privacy, DIAGNOSTICS } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index b49d9d2c7cf11..9f00bf97deba1 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1204,14 +1204,14 @@ impl PrimitiveTypeTable { table.intern("char", TyChar); table.intern("f32", TyFloat(FloatTy::F32)); table.intern("f64", TyFloat(FloatTy::F64)); - table.intern("isize", TyInt(IntTy::Is)); + table.intern("isize", TyInt(IntTy::Isize)); table.intern("i8", TyInt(IntTy::I8)); table.intern("i16", TyInt(IntTy::I16)); table.intern("i32", TyInt(IntTy::I32)); table.intern("i64", TyInt(IntTy::I64)); table.intern("i128", TyInt(IntTy::I128)); table.intern("str", TyStr); - table.intern("usize", TyUint(UintTy::Us)); + table.intern("usize", TyUint(UintTy::Usize)); table.intern("u8", TyUint(UintTy::U8)); table.intern("u16", TyUint(UintTy::U16)); table.intern("u32", TyUint(UintTy::U32)); @@ -4089,4 +4089,5 @@ pub enum MakeGlobMap { No, } +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_resolve, DIAGNOSTICS } diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs index 298716840926a..60b24a578c6b0 100644 --- a/src/librustc_trans/back/lto.rs +++ b/src/librustc_trans/back/lto.rs @@ -607,7 +607,7 @@ impl ThinModule { // into that context. One day, however, we may do this for upstream // crates but for locally translated modules we may be able to reuse // that LLVM Context and Module. - let llcx = llvm::LLVMContextCreate(); + let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names); let llmod = llvm::LLVMRustParseBitcodeForThinLTO( llcx, self.data().as_ptr(), diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index d8e95cd2cf2e0..4d1bcd9bf467d 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -323,6 +323,7 @@ pub struct CodegenContext { pub thinlto: bool, pub no_landing_pads: bool, pub save_temps: bool, + pub fewer_names: bool, pub exported_symbols: Arc, pub opts: Arc, pub crate_types: Vec, @@ -1407,6 +1408,7 @@ fn start_executing_work(tcx: TyCtxt, unsafe { llvm::LLVMRustThinLTOAvailable() }, no_landing_pads: sess.no_landing_pads(), + fewer_names: sess.fewer_names(), save_temps: sess.opts.cg.save_temps, opts: Arc::new(sess.opts.clone()), time_passes: sess.time_passes(), diff --git a/src/librustc_trans/builder.rs b/src/librustc_trans/builder.rs index 5b697d6b99c95..4a0b1381a4008 100644 --- a/src/librustc_trans/builder.rs +++ b/src/librustc_trans/builder.rs @@ -1012,12 +1012,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } pub fn landing_pad(&self, ty: Type, pers_fn: ValueRef, - num_clauses: usize, - llfn: ValueRef) -> ValueRef { + num_clauses: usize) -> ValueRef { self.count_insn("landingpad"); unsafe { - llvm::LLVMRustBuildLandingPad(self.llbuilder, ty.to_ref(), pers_fn, - num_clauses as c_uint, noname(), llfn) + llvm::LLVMBuildLandingPad(self.llbuilder, ty.to_ref(), pers_fn, + num_clauses as c_uint, noname()) } } diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index d5e71062f74d7..248b37c43b42e 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -197,7 +197,7 @@ pub fn is_pie_binary(sess: &Session) -> bool { } pub unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextRef, ModuleRef) { - let llcx = llvm::LLVMContextCreate(); + let llcx = llvm::LLVMRustContextCreate(sess.fewer_names()); let mod_name = CString::new(mod_name).unwrap(); let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx); diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index 3cd60e7f1bc7f..23f7d47e722a7 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -925,7 +925,7 @@ fn trans_gnu_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, // rust_try ignores the selector. let lpad_ty = Type::struct_(ccx, &[Type::i8p(ccx), Type::i32(ccx)], false); - let vals = catch.landing_pad(lpad_ty, bcx.ccx.eh_personality(), 1, catch.llfn()); + let vals = catch.landing_pad(lpad_ty, bcx.ccx.eh_personality(), 1); catch.add_clause(vals, C_null(Type::i8p(ccx))); let ptr = catch.extract_value(vals, 0); let ptr_align = bcx.tcx().data_layout.pointer_align; @@ -1246,7 +1246,7 @@ fn generic_simd_intrinsic<'a, 'tcx>( fn int_type_width_signed(ty: Ty, ccx: &CrateContext) -> Option<(u64, bool)> { match ty.sty { ty::TyInt(t) => Some((match t { - ast::IntTy::Is => { + ast::IntTy::Isize => { match &ccx.tcx().sess.target.target.target_pointer_width[..] { "16" => 16, "32" => 32, @@ -1261,7 +1261,7 @@ fn int_type_width_signed(ty: Ty, ccx: &CrateContext) -> Option<(u64, bool)> { ast::IntTy::I128 => 128, }, true)), ty::TyUint(t) => Some((match t { - ast::UintTy::Us => { + ast::UintTy::Usize => { match &ccx.tcx().sess.target.target.target_pointer_width[..] { "16" => 16, "32" => 32, diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index c4849c621e8d5..039dd94465d5b 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -328,4 +328,5 @@ pub struct CrateInfo { used_crates_dynamic: Vec<(CrateNum, LibSource)>, } +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_trans, DIAGNOSTICS } diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 422b8210b3544..8c9fb03954583 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -753,7 +753,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { let llpersonality = self.ccx.eh_personality(); let llretty = self.landing_pad_type(); - let lp = bcx.landing_pad(llretty, llpersonality, 1, self.llfn); + let lp = bcx.landing_pad(llretty, llpersonality, 1); bcx.set_cleanup(lp); let slot = self.get_personality_slot(&bcx); diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index 65f1129890d04..56309f20dc12e 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -720,13 +720,13 @@ fn get_overflow_intrinsic(oop: OverflowOp, bcx: &Builder, ty: Ty) -> ValueRef { let tcx = bcx.tcx(); let new_sty = match ty.sty { - TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] { + TyInt(Isize) => match &tcx.sess.target.target.target_pointer_width[..] { "16" => TyInt(I16), "32" => TyInt(I32), "64" => TyInt(I64), _ => panic!("unsupported target word size") }, - TyUint(Us) => match &tcx.sess.target.target.target_pointer_width[..] { + TyUint(Usize) => match &tcx.sess.target.target.target_pointer_width[..] { "16" => TyUint(U16), "32" => TyUint(U32), "64" => TyUint(U64), diff --git a/src/librustc_trans/type_.rs b/src/librustc_trans/type_.rs index b9daaf5a44808..6cbe175d4d8d5 100644 --- a/src/librustc_trans/type_.rs +++ b/src/librustc_trans/type_.rs @@ -147,7 +147,7 @@ impl Type { pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type { match t { - ast::IntTy::Is => ccx.isize_ty(), + ast::IntTy::Isize => ccx.isize_ty(), ast::IntTy::I8 => Type::i8(ccx), ast::IntTy::I16 => Type::i16(ccx), ast::IntTy::I32 => Type::i32(ccx), @@ -158,7 +158,7 @@ impl Type { pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type { match t { - ast::UintTy::Us => ccx.isize_ty(), + ast::UintTy::Usize => ccx.isize_ty(), ast::UintTy::U8 => Type::i8(ccx), ast::UintTy::U16 => Type::i16(ccx), ast::UintTy::U32 => Type::i32(ccx), diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 7c199587c9898..201997a74b73f 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -233,7 +233,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { CastError::NeedViaPtr => { let mut err = make_invalid_casting_error(fcx.tcx.sess, self.span, self.expr_ty, self.cast_ty, fcx); - if self.cast_ty.is_uint() { + if self.cast_ty.is_integral() { err.help(&format!("cast through {} first", match e { CastError::NeedViaPtr => "a raw pointer", diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 53bb0e577a4b6..6f83ecab01a1c 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -494,7 +494,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { let lang_def_id = lang_items.i128_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyInt(ast::IntTy::Is) => { + ty::TyInt(ast::IntTy::Isize) => { let lang_def_id = lang_items.isize_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } @@ -518,7 +518,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { let lang_def_id = lang_items.u128_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } - ty::TyUint(ast::UintTy::Us) => { + ty::TyUint(ast::UintTy::Usize) => { let lang_def_id = lang_items.usize_impl(); self.assemble_inherent_impl_for_primitive(lang_def_id); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 7a49c3549abdf..6d68824980b6a 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2219,7 +2219,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // First, try built-in indexing. match (adjusted_ty.builtin_index(), &index_ty.sty) { - (Some(ty), &ty::TyUint(ast::UintTy::Us)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => { + (Some(ty), &ty::TyUint(ast::UintTy::Usize)) | + (Some(ty), &ty::TyInfer(ty::IntVar(_))) => { debug!("try_index_step: success, using built-in indexing"); let adjustments = autoderef.adjust_steps(lvalue_pref); self.apply_adjustments(base_expr, adjustments); diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index 569b6a2febb45..4256a1fe12b60 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -200,7 +200,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "i128", item.span); } - ty::TyInt(ast::IntTy::Is) => { + ty::TyInt(ast::IntTy::Isize) => { self.check_primitive_impl(def_id, lang_items.isize_impl(), "isize", @@ -242,7 +242,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { "u128", item.span); } - ty::TyUint(ast::UintTy::Us) => { + ty::TyUint(ast::UintTy::Usize) => { self.check_primitive_impl(def_id, lang_items.usize_impl(), "usize", diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 0b2f59abf4f78..1dc98bc7a0072 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -380,4 +380,5 @@ pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait: (principal, projections) } +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { librustc_typeck, DIAGNOSTICS } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 10cb2e5f3fdaf..265114ae826f4 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2011,7 +2011,7 @@ impl PrimitiveType { impl From for PrimitiveType { fn from(int_ty: ast::IntTy) -> PrimitiveType { match int_ty { - ast::IntTy::Is => PrimitiveType::Isize, + ast::IntTy::Isize => PrimitiveType::Isize, ast::IntTy::I8 => PrimitiveType::I8, ast::IntTy::I16 => PrimitiveType::I16, ast::IntTy::I32 => PrimitiveType::I32, @@ -2024,7 +2024,7 @@ impl From for PrimitiveType { impl From for PrimitiveType { fn from(uint_ty: ast::UintTy) -> PrimitiveType { match uint_ty { - ast::UintTy::Us => PrimitiveType::Usize, + ast::UintTy::Usize => PrimitiveType::Usize, ast::UintTy::U8 => PrimitiveType::U8, ast::UintTy::U16 => PrimitiveType::U16, ast::UintTy::U32 => PrimitiveType::U32, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index afbaf037c7def..a389b26a5879b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -4136,7 +4136,11 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option match *clean_type { clean::ResolvedPath { ref path, .. } => { let segments = &path.segments; - Some(segments[segments.len() - 1].name.clone()) + let path_segment = segments.into_iter().last().unwrap_or_else(|| panic!( + "get_index_type_name(clean_type: {:?}, accept_generic: {:?}) had length zero path", + clean_type, accept_generic + )); + Some(path_segment.name.clone()) } clean::Generic(ref s) if accept_generic => Some(s.clone()), clean::Primitive(ref p) => Some(format!("{:?}", p)), diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index c128a812b93b0..b4dbd76d0b4d0 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1132,6 +1132,10 @@ e.preventDefault(); } else if (e.which === 16) { // shift // Does nothing, it's just to avoid losing "focus" on the highlighted element. + } else if (e.which === 27) { // escape + removeClass(actives[currentTab][0], 'highlighted'); + document.getElementsByClassName('search-input')[0].value = ''; + defocusSearchBar(); } else if (actives[currentTab].length > 0) { removeClass(actives[currentTab][0], 'highlighted'); } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 7f0e5a8d2aa22..e9427fb40a016 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -527,6 +527,16 @@ impl HashSet /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for /// the value type. /// + /// # Examples + /// + /// ``` + /// use std::collections::HashSet; + /// + /// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect(); + /// assert_eq!(set.get(&2), Some(&2)); + /// assert_eq!(set.get(&4), None); + /// ``` + /// /// [`Eq`]: ../../std/cmp/trait.Eq.html /// [`Hash`]: ../../std/hash/trait.Hash.html #[stable(feature = "set_recovery", since = "1.9.0")] @@ -631,6 +641,19 @@ impl HashSet /// Adds a value to the set, replacing the existing value, if any, that is equal to the given /// one. Returns the replaced value. + /// + /// # Examples + /// + /// ``` + /// use std::collections::HashSet; + /// + /// let mut set = HashSet::new(); + /// set.insert(Vec::::new()); + /// + /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 0); + /// set.replace(Vec::with_capacity(10)); + /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 10); + /// ``` #[stable(feature = "set_recovery", since = "1.9.0")] pub fn replace(&mut self, value: T) -> Option { Recover::replace(&mut self.map, value) @@ -671,6 +694,16 @@ impl HashSet /// [`Hash`] and [`Eq`] on the borrowed form *must* match those for /// the value type. /// + /// # Examples + /// + /// ``` + /// use std::collections::HashSet; + /// + /// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect(); + /// assert_eq!(set.take(&2), Some(2)); + /// assert_eq!(set.take(&2), None); + /// ``` + /// /// [`Eq`]: ../../std/cmp/trait.Eq.html /// [`Hash`]: ../../std/hash/trait.Hash.html #[stable(feature = "set_recovery", since = "1.9.0")] diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 457c6e1409d3c..ed34c1204b3a1 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -571,8 +571,11 @@ pub fn temp_dir() -> PathBuf { /// Returns the full filesystem path of the current running executable. /// -/// The path returned is not necessarily a "real path" of the executable as -/// there may be intermediate symlinks. +/// # Platform-specific behavior +/// +/// If the executable was invoked through a symbolic link, some platforms will +/// return the path of the symbolic link and other platforms will return the +/// path of the symbolic link’s target. /// /// # Errors /// @@ -599,14 +602,14 @@ pub fn temp_dir() -> PathBuf { /// Ok("/home/alex/foo") /// ``` /// -/// And you make a symbolic link of the program: +/// And you make a hard link of the program: /// /// ```bash /// $ ln foo bar /// ``` /// -/// When you run it, you won't get the original executable, you'll get the -/// symlink: +/// When you run it, you won’t get the path of the original executable, you’ll +/// get the path of the hard link: /// /// ```bash /// $ ./bar @@ -614,9 +617,9 @@ pub fn temp_dir() -> PathBuf { /// ``` /// /// This sort of behavior has been known to [lead to privilege escalation] when -/// used incorrectly, for example. +/// used incorrectly. /// -/// [lead to privilege escalation]: http://securityvulns.com/Wdocument183.html +/// [lead to privilege escalation]: https://securityvulns.com/Wdocument183.html /// /// # Examples /// @@ -625,7 +628,7 @@ pub fn temp_dir() -> PathBuf { /// /// match env::current_exe() { /// Ok(exe_path) => println!("Path of this executable is: {}", -/// exe_path.display()), +/// exe_path.display()), /// Err(e) => println!("failed to get current exe path: {}", e), /// }; /// ``` diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index e9b707c57ebbf..ad9cf1eed7013 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -601,7 +601,7 @@ pub trait Read { read_to_end(self, buf) } - /// Read all bytes until EOF in this source, placing them into `buf`. + /// Read all bytes until EOF in this source, appending them to `buf`. /// /// If successful, this function returns the number of bytes which were read /// and appended to `buf`. diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs index 921fbec3da303..af414d25b5f94 100644 --- a/src/libstd/rt.rs +++ b/src/libstd/rt.rs @@ -28,7 +28,7 @@ pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count}; // To reduce the generated code of the new `lang_start`, this function is doing // the real work. -#[cfg(not(any(test, stage0)))] +#[cfg(not(test))] fn lang_start_internal(main: &(Fn() -> i32 + Sync + ::panic::RefUnwindSafe), argc: isize, argv: *const *const u8) -> isize { use panic; @@ -66,55 +66,10 @@ fn lang_start_internal(main: &(Fn() -> i32 + Sync + ::panic::RefUnwindSafe), } } -#[cfg(not(any(test, stage0)))] +#[cfg(not(test))] #[lang = "start"] fn lang_start (main: fn() -> T, argc: isize, argv: *const *const u8) -> isize { lang_start_internal(&move || main().report(), argc, argv) } - -#[cfg(all(not(test), stage0))] -#[lang = "start"] -fn lang_start(main: fn(), argc: isize, argv: *const *const u8) -> isize { - use panic; - use sys; - use sys_common; - use sys_common::thread_info; - use thread::Thread; - #[cfg(not(feature = "backtrace"))] - use mem; - - sys::init(); - - let failed = unsafe { - let main_guard = sys::thread::guard::init(); - sys::stack_overflow::init(); - - // Next, set up the current Thread with the guard information we just - // created. Note that this isn't necessary in general for new threads, - // but we just do this to name the main thread and to give it correct - // info about the stack bounds. - let thread = Thread::new(Some("main".to_owned())); - thread_info::set(main_guard, thread); - - // Store our args if necessary in a squirreled away location - sys::args::init(argc, argv); - - // Let's run some code! - #[cfg(feature = "backtrace")] - let res = panic::catch_unwind(|| { - ::sys_common::backtrace::__rust_begin_short_backtrace(main) - }); - #[cfg(not(feature = "backtrace"))] - let res = panic::catch_unwind(mem::transmute::<_, fn()>(main)); - sys_common::cleanup(); - res.is_err() - }; - - if failed { - 101 - } else { - 0 - } -} diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index 72169773df596..e1c7ffc19e51e 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs @@ -69,7 +69,7 @@ impl DoubleEndedIterator for Args { target_os = "fuchsia"))] mod imp { use os::unix::prelude::*; - use mem; + use ptr; use ffi::{CStr, OsString}; use marker::PhantomData; use libc; @@ -77,49 +77,42 @@ mod imp { use sys_common::mutex::Mutex; - static mut GLOBAL_ARGS_PTR: usize = 0; + static mut ARGC: isize = 0; + static mut ARGV: *const *const u8 = ptr::null(); static LOCK: Mutex = Mutex::new(); pub unsafe fn init(argc: isize, argv: *const *const u8) { - let args = (0..argc).map(|i| { - CStr::from_ptr(*argv.offset(i) as *const libc::c_char).to_bytes().to_vec() - }).collect(); - LOCK.lock(); - let ptr = get_global_ptr(); - assert!((*ptr).is_none()); - (*ptr) = Some(box args); + ARGC = argc; + ARGV = argv; LOCK.unlock(); } pub unsafe fn cleanup() { LOCK.lock(); - *get_global_ptr() = None; + ARGC = 0; + ARGV = ptr::null(); LOCK.unlock(); } pub fn args() -> Args { - let bytes = clone().unwrap_or(Vec::new()); - let v: Vec = bytes.into_iter().map(|v| { - OsStringExt::from_vec(v) - }).collect(); - Args { iter: v.into_iter(), _dont_send_or_sync_me: PhantomData } + Args { + iter: clone().into_iter(), + _dont_send_or_sync_me: PhantomData + } } - fn clone() -> Option>> { + fn clone() -> Vec { unsafe { LOCK.lock(); - let ptr = get_global_ptr(); - let ret = (*ptr).as_ref().map(|s| (**s).clone()); + let ret = (0..ARGC).map(|i| { + let cstr = CStr::from_ptr(*ARGV.offset(i) as *const libc::c_char); + OsStringExt::from_vec(cstr.to_bytes().to_vec()) + }).collect(); LOCK.unlock(); return ret } } - - fn get_global_ptr() -> *mut Option>>> { - unsafe { mem::transmute(&GLOBAL_ARGS_PTR) } - } - } #[cfg(any(target_os = "macos", diff --git a/src/libstd/termination.rs b/src/libstd/termination.rs index 61137ba492299..93a913bb540b7 100644 --- a/src/libstd/termination.rs +++ b/src/libstd/termination.rs @@ -29,7 +29,7 @@ mod exit { /// /// The default implementations are returning `libc::EXIT_SUCCESS` to indicate /// a successful execution. In case of a failure, `libc::EXIT_FAILURE` is returned. -#[cfg_attr(not(any(stage0, test)), lang = "termination")] +#[cfg_attr(not(test), lang = "termination")] #[unstable(feature = "termination_trait", issue = "43301")] #[rustc_on_unimplemented = "`main` can only return types that implement {Termination}, not `{Self}`"] diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 15682b2d459fa..e08a2cbfd0846 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1324,7 +1324,7 @@ pub enum ImplItemKind { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy, PartialOrd, Ord)] pub enum IntTy { - Is, + Isize, I8, I16, I32, @@ -1347,7 +1347,7 @@ impl fmt::Display for IntTy { impl IntTy { pub fn ty_to_string(&self) -> &'static str { match *self { - IntTy::Is => "isize", + IntTy::Isize => "isize", IntTy::I8 => "i8", IntTy::I16 => "i16", IntTy::I32 => "i32", @@ -1365,7 +1365,7 @@ impl IntTy { pub fn bit_width(&self) -> Option { Some(match *self { - IntTy::Is => return None, + IntTy::Isize => return None, IntTy::I8 => 8, IntTy::I16 => 16, IntTy::I32 => 32, @@ -1378,7 +1378,7 @@ impl IntTy { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy, PartialOrd, Ord)] pub enum UintTy { - Us, + Usize, U8, U16, U32, @@ -1389,7 +1389,7 @@ pub enum UintTy { impl UintTy { pub fn ty_to_string(&self) -> &'static str { match *self { - UintTy::Us => "usize", + UintTy::Usize => "usize", UintTy::U8 => "u8", UintTy::U16 => "u16", UintTy::U32 => "u32", @@ -1404,7 +1404,7 @@ impl UintTy { pub fn bit_width(&self) -> Option { Some(match *self { - UintTy::Us => return None, + UintTy::Usize => return None, UintTy::U8 => 8, UintTy::U16 => 16, UintTy::U32 => 32, diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index cc72ff7d15d2b..0b868b514fe96 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -1071,8 +1071,8 @@ fn int_type_of_word(s: &str) -> Option { "u64" => Some(UnsignedInt(ast::UintTy::U64)), "i128" => Some(SignedInt(ast::IntTy::I128)), "u128" => Some(UnsignedInt(ast::UintTy::U128)), - "isize" => Some(SignedInt(ast::IntTy::Is)), - "usize" => Some(UnsignedInt(ast::UintTy::Us)), + "isize" => Some(SignedInt(ast::IntTy::Isize)), + "usize" => Some(UnsignedInt(ast::UintTy::Usize)), _ => None } } diff --git a/src/libsyntax/diagnostics/metadata.rs b/src/libsyntax/diagnostics/metadata.rs index 5f06475919fec..dc01a79190b3a 100644 --- a/src/libsyntax/diagnostics/metadata.rs +++ b/src/libsyntax/diagnostics/metadata.rs @@ -14,9 +14,10 @@ //! currently always a crate name. use std::collections::BTreeMap; -use std::path::PathBuf; +use std::env; use std::fs::{remove_file, create_dir_all, File}; use std::io::Write; +use std::path::PathBuf; use std::error::Error; use rustc_serialize::json::as_json; @@ -24,9 +25,6 @@ use syntax_pos::{Span, FileName}; use ext::base::ExtCtxt; use diagnostics::plugin::{ErrorMap, ErrorInfo}; -// Default metadata directory to use for extended error JSON. -const ERROR_METADATA_PREFIX: &'static str = "tmp/extended-errors"; - /// JSON encodable/decodable version of `ErrorInfo`. #[derive(PartialEq, RustcDecodable, RustcEncodable)] pub struct ErrorMetadata { @@ -59,7 +57,10 @@ impl ErrorLocation { /// /// See `output_metadata`. pub fn get_metadata_dir(prefix: &str) -> PathBuf { - PathBuf::from(ERROR_METADATA_PREFIX).join(prefix) + env::var_os("RUSTC_ERROR_METADATA_DST") + .map(PathBuf::from) + .expect("env var `RUSTC_ERROR_METADATA_DST` isn't set") + .join(prefix) } /// Map `name` to a path in the given directory: /.json diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 34e5610901ed8..be0bfd6677bd8 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -694,17 +694,17 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn expr_usize(&self, span: Span, i: usize) -> P { self.expr_lit(span, ast::LitKind::Int(i as u128, - ast::LitIntType::Unsigned(ast::UintTy::Us))) + ast::LitIntType::Unsigned(ast::UintTy::Usize))) } fn expr_isize(&self, sp: Span, i: isize) -> P { if i < 0 { let i = (-i) as u128; - let lit_ty = ast::LitIntType::Signed(ast::IntTy::Is); + let lit_ty = ast::LitIntType::Signed(ast::IntTy::Isize); let lit = self.expr_lit(sp, ast::LitKind::Int(i, lit_ty)); self.expr_unary(sp, ast::UnOp::Neg, lit) } else { self.expr_lit(sp, ast::LitKind::Int(i as u128, - ast::LitIntType::Signed(ast::IntTy::Is))) + ast::LitIntType::Signed(ast::IntTy::Isize))) } } fn expr_u32(&self, sp: Span, u: u32) -> P { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 59996d1e4a7b1..7fcd88c94ca6f 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -326,13 +326,13 @@ pub mod rt { ); } - impl_to_tokens_int! { signed, isize, ast::IntTy::Is } + impl_to_tokens_int! { signed, isize, ast::IntTy::Isize } impl_to_tokens_int! { signed, i8, ast::IntTy::I8 } impl_to_tokens_int! { signed, i16, ast::IntTy::I16 } impl_to_tokens_int! { signed, i32, ast::IntTy::I32 } impl_to_tokens_int! { signed, i64, ast::IntTy::I64 } - impl_to_tokens_int! { unsigned, usize, ast::UintTy::Us } + impl_to_tokens_int! { unsigned, usize, ast::UintTy::Usize } impl_to_tokens_int! { unsigned, u8, ast::UintTy::U8 } impl_to_tokens_int! { unsigned, u16, ast::UintTy::U16 } impl_to_tokens_int! { unsigned, u32, ast::UintTy::U32 } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 0b51f2e981456..d7f7ff554db4b 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -151,4 +151,5 @@ pub mod ext { #[cfg(test)] mod test_snippet; +#[cfg(not(stage0))] // remove after the next snapshot __build_diagnostic_array! { libsyntax, DIAGNOSTICS } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index a38ceba2f45a9..a9b1e4aaa6006 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -603,13 +603,13 @@ pub fn integer_lit(s: &str, suffix: Option, diag: Option<(Span, &Handler err!(diag, |span, diag| diag.span_bug(span, "found empty literal suffix in Some")); } ty = match &*suf.as_str() { - "isize" => ast::LitIntType::Signed(ast::IntTy::Is), + "isize" => ast::LitIntType::Signed(ast::IntTy::Isize), "i8" => ast::LitIntType::Signed(ast::IntTy::I8), "i16" => ast::LitIntType::Signed(ast::IntTy::I16), "i32" => ast::LitIntType::Signed(ast::IntTy::I32), "i64" => ast::LitIntType::Signed(ast::IntTy::I64), "i128" => ast::LitIntType::Signed(ast::IntTy::I128), - "usize" => ast::LitIntType::Unsigned(ast::UintTy::Us), + "usize" => ast::LitIntType::Unsigned(ast::UintTy::Usize), "u8" => ast::LitIntType::Unsigned(ast::UintTy::U8), "u16" => ast::LitIntType::Unsigned(ast::UintTy::U16), "u32" => ast::LitIntType::Unsigned(ast::UintTy::U32), diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 29f5196c9bd6f..48872cb1313d7 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -833,14 +833,14 @@ fn find_repr_type_name(diagnostic: &Handler, type_attrs: &[ast::Attribute]) -> & attr::ReprPacked | attr::ReprSimd | attr::ReprAlign(_) => continue, attr::ReprExtern => "i32", - attr::ReprInt(attr::SignedInt(ast::IntTy::Is)) => "isize", + attr::ReprInt(attr::SignedInt(ast::IntTy::Isize)) => "isize", attr::ReprInt(attr::SignedInt(ast::IntTy::I8)) => "i8", attr::ReprInt(attr::SignedInt(ast::IntTy::I16)) => "i16", attr::ReprInt(attr::SignedInt(ast::IntTy::I32)) => "i32", attr::ReprInt(attr::SignedInt(ast::IntTy::I64)) => "i64", attr::ReprInt(attr::SignedInt(ast::IntTy::I128)) => "i128", - attr::ReprInt(attr::UnsignedInt(ast::UintTy::Us)) => "usize", + attr::ReprInt(attr::UnsignedInt(ast::UintTy::Usize)) => "usize", attr::ReprInt(attr::UnsignedInt(ast::UintTy::U8)) => "u8", attr::ReprInt(attr::UnsignedInt(ast::UintTy::U16)) => "u16", attr::ReprInt(attr::UnsignedInt(ast::UintTy::U32)) => "u32", diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 6f51ea67cb1d1..0fac7f7bf28b1 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -76,11 +76,17 @@ extern "C" char *LLVMRustGetLastError(void) { return Ret; } -void LLVMRustSetLastError(const char *Err) { +extern "C" void LLVMRustSetLastError(const char *Err) { free((void *)LastError); LastError = strdup(Err); } +extern "C" LLVMContextRef LLVMRustContextCreate(bool shouldDiscardNames) { + auto ctx = new LLVMContext(); + ctx->setDiscardValueNames(shouldDiscardNames); + return wrap(ctx); +} + extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M, const char *Triple) { unwrap(M)->setTargetTriple(Triple::normalize(Triple)); @@ -1144,13 +1150,6 @@ extern "C" void LLVMRustWriteSMDiagnosticToString(LLVMSMDiagnosticRef D, unwrap(D)->print("", OS); } -extern "C" LLVMValueRef -LLVMRustBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, - LLVMValueRef PersFn, unsigned NumClauses, - const char *Name, LLVMValueRef F) { - return LLVMBuildLandingPad(B, Ty, PersFn, NumClauses, Name); -} - extern "C" LLVMValueRef LLVMRustBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, unsigned ArgCount, @@ -1355,10 +1354,6 @@ extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *hig return true; } -extern "C" LLVMContextRef LLVMRustGetValueContext(LLVMValueRef V) { - return wrap(&unwrap(V)->getContext()); -} - enum class LLVMRustVisibility { Default = 0, Hidden = 1, @@ -1439,11 +1434,6 @@ LLVMRustModuleBufferLen(const LLVMRustModuleBuffer *Buffer) { extern "C" uint64_t LLVMRustModuleCost(LLVMModuleRef M) { - Module &Mod = *unwrap(M); - uint64_t cost = 0; - for (auto &F : Mod.functions()) { - (void)F; - cost += 1; - } - return cost; + auto f = unwrap(M)->functions(); + return std::distance(std::begin(f), std::end(f)); } diff --git a/src/rustllvm/rustllvm.h b/src/rustllvm/rustllvm.h index 8c2f855c226ba..714173f86020d 100644 --- a/src/rustllvm/rustllvm.h +++ b/src/rustllvm/rustllvm.h @@ -71,7 +71,7 @@ #include "llvm/IR/IRPrintingPasses.h" #include "llvm/Linker/Linker.h" -void LLVMRustSetLastError(const char *); +extern "C" void LLVMRustSetLastError(const char *); enum class LLVMRustResult { Success, Failure }; diff --git a/src/stage0.txt b/src/stage0.txt index eb0bedf64b23c..38a8ef2acd261 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2017-11-21 +date: 2018-01-02 rustc: beta cargo: beta diff --git a/src/test/debuginfo/basic-types-globals-metadata.rs b/src/test/debuginfo/basic-types-globals-metadata.rs index fe687dabe9acb..b699eface3ff7 100644 --- a/src/test/debuginfo/basic-types-globals-metadata.rs +++ b/src/test/debuginfo/basic-types-globals-metadata.rs @@ -9,6 +9,7 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // gdb-command:run diff --git a/src/test/debuginfo/basic-types-globals.rs b/src/test/debuginfo/basic-types-globals.rs index 20bc403fbbcdc..51c36f8f1c15d 100644 --- a/src/test/debuginfo/basic-types-globals.rs +++ b/src/test/debuginfo/basic-types-globals.rs @@ -15,6 +15,7 @@ // its numerical value. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // gdb-command:run diff --git a/src/test/debuginfo/basic-types-metadata.rs b/src/test/debuginfo/basic-types-metadata.rs index 8aec1a059bdc6..3dbfdea3c22cf 100644 --- a/src/test/debuginfo/basic-types-metadata.rs +++ b/src/test/debuginfo/basic-types-metadata.rs @@ -9,6 +9,7 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // gdb-command:run diff --git a/src/test/debuginfo/basic-types-mut-globals.rs b/src/test/debuginfo/basic-types-mut-globals.rs index 62325aa53ab9f..2d4b4d61aa862 100644 --- a/src/test/debuginfo/basic-types-mut-globals.rs +++ b/src/test/debuginfo/basic-types-mut-globals.rs @@ -15,6 +15,7 @@ // its numerical value. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g diff --git a/src/test/debuginfo/by-value-non-immediate-argument.rs b/src/test/debuginfo/by-value-non-immediate-argument.rs index 0fe08c3a22731..9007b44296bcc 100644 --- a/src/test/debuginfo/by-value-non-immediate-argument.rs +++ b/src/test/debuginfo/by-value-non-immediate-argument.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-tidy-linelength +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 // compile-flags:-g diff --git a/src/test/debuginfo/c-style-enum.rs b/src/test/debuginfo/c-style-enum.rs index 900b0829530f3..1f1f42e2dec2e 100644 --- a/src/test/debuginfo/c-style-enum.rs +++ b/src/test/debuginfo/c-style-enum.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-aarch64 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 // compile-flags:-g diff --git a/src/test/debuginfo/drop-locations.rs b/src/test/debuginfo/drop-locations.rs index b4f6b33be26a1..76c2826ee8c61 100644 --- a/src/test/debuginfo/drop-locations.rs +++ b/src/test/debuginfo/drop-locations.rs @@ -10,6 +10,7 @@ // ignore-windows // ignore-android +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 #![allow(unused)] diff --git a/src/test/debuginfo/function-arg-initialization.rs b/src/test/debuginfo/function-arg-initialization.rs index 21fdc4e5e88a6..90088a0297aa8 100644 --- a/src/test/debuginfo/function-arg-initialization.rs +++ b/src/test/debuginfo/function-arg-initialization.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-tidy-linelength - +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 // This test case checks if function arguments already have the correct value diff --git a/src/test/debuginfo/function-prologue-stepping-regular.rs b/src/test/debuginfo/function-prologue-stepping-regular.rs index 529a8cd635a92..d50d105e009ff 100644 --- a/src/test/debuginfo/function-prologue-stepping-regular.rs +++ b/src/test/debuginfo/function-prologue-stepping-regular.rs @@ -13,6 +13,7 @@ // min-lldb-version: 310 // ignore-gdb +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g // lldb-command:breakpoint set --name immediate_args diff --git a/src/test/debuginfo/lexical-scopes-in-block-expression.rs b/src/test/debuginfo/lexical-scopes-in-block-expression.rs index 8e8a194e37841..e76f9da1c2505 100644 --- a/src/test/debuginfo/lexical-scopes-in-block-expression.rs +++ b/src/test/debuginfo/lexical-scopes-in-block-expression.rs @@ -9,6 +9,7 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g diff --git a/src/test/debuginfo/limited-debuginfo.rs b/src/test/debuginfo/limited-debuginfo.rs index e8c3597b8c8dd..d840f38b2aad2 100644 --- a/src/test/debuginfo/limited-debuginfo.rs +++ b/src/test/debuginfo/limited-debuginfo.rs @@ -10,6 +10,7 @@ // ignore-lldb +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-C debuginfo=1 diff --git a/src/test/debuginfo/macro-stepping.rs b/src/test/debuginfo/macro-stepping.rs index ca2c1e0c8f029..204dd8c1e739b 100644 --- a/src/test/debuginfo/macro-stepping.rs +++ b/src/test/debuginfo/macro-stepping.rs @@ -12,6 +12,7 @@ // ignore-android // ignore-aarch64 // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // aux-build:macro-stepping.rs diff --git a/src/test/debuginfo/method-on-enum.rs b/src/test/debuginfo/method-on-enum.rs index 7dbc0d3c5130d..ddfff0f7d76e1 100644 --- a/src/test/debuginfo/method-on-enum.rs +++ b/src/test/debuginfo/method-on-enum.rs @@ -10,6 +10,7 @@ // ignore-tidy-linelength // min-lldb-version: 310 +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g diff --git a/src/test/debuginfo/option-like-enum.rs b/src/test/debuginfo/option-like-enum.rs index 39e6a4e4facf9..618587e421970 100644 --- a/src/test/debuginfo/option-like-enum.rs +++ b/src/test/debuginfo/option-like-enum.rs @@ -9,6 +9,8 @@ // except according to those terms. // ignore-tidy-linelength +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 + // min-lldb-version: 310 // compile-flags:-g diff --git a/src/test/debuginfo/pretty-std.rs b/src/test/debuginfo/pretty-std.rs index 2a28c895b797e..7bc566480e763 100644 --- a/src/test/debuginfo/pretty-std.rs +++ b/src/test/debuginfo/pretty-std.rs @@ -10,6 +10,7 @@ // ignore-windows failing on win32 bot // ignore-freebsd: gdb package too new +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // ignore-android: FIXME(#10381) // compile-flags:-g // min-gdb-version 7.7 diff --git a/src/test/debuginfo/shadowed-variable.rs b/src/test/debuginfo/shadowed-variable.rs index bf47ebe5aa7d1..6e4d94d26cdeb 100644 --- a/src/test/debuginfo/shadowed-variable.rs +++ b/src/test/debuginfo/shadowed-variable.rs @@ -9,7 +9,6 @@ // except according to those terms. // min-lldb-version: 310 - // compile-flags:-g // === GDB TESTS =================================================================================== @@ -35,15 +34,15 @@ // gdb-command:continue // gdb-command:print x -// gdb-check:$5 = 10.5 +// gdb-check:$7 = 10.5 // gdb-command:print y -// gdb-check:$6 = 20 +// gdb-check:$8 = 20 // gdb-command:continue // gdb-command:print x -// gdb-check:$5 = 11.5 +// gdb-check:$9 = 11.5 // gdb-command:print y -// gdb-check:$6 = 20 +// gdb-check:$10 = 20 // gdb-command:continue // === LLDB TESTS ================================================================================== @@ -69,15 +68,15 @@ // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = 10.5 +// lldb-check:[...]$6 = 10.5 // lldb-command:print y -// lldb-check:[...]$5 = 20 +// lldb-check:[...]$7 = 20 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = 11.5 +// lldb-check:[...]$8 = 11.5 // lldb-command:print y -// lldb-check:[...]$5 = 20 +// lldb-check:[...]$9 = 20 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff --git a/src/test/debuginfo/should-fail.rs b/src/test/debuginfo/should-fail.rs new file mode 100644 index 0000000000000..1f8acb5310122 --- /dev/null +++ b/src/test/debuginfo/should-fail.rs @@ -0,0 +1,38 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// min-lldb-version: 310 + +// == Test [gdb|lldb]-[command|check] are parsed correctly === +// should-fail +// compile-flags:-g + +// === GDB TESTS =================================================================================== + +// gdb-command: run + +// gdb-command: print x +// gdb-check:$1 = 5 + +// === LLDB TESTS ================================================================================== + +// lldb-command:run + +// lldb-command:print x +// lldb-check:[...]$0 = 5 + +fn main() { + let x = 1; + + zzz(); // #break +} + +fn zzz() {()} + diff --git a/src/test/debuginfo/simple-struct.rs b/src/test/debuginfo/simple-struct.rs index ae05bafe5adaa..8fdf204d30ab5 100644 --- a/src/test/debuginfo/simple-struct.rs +++ b/src/test/debuginfo/simple-struct.rs @@ -9,6 +9,7 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g diff --git a/src/test/debuginfo/simple-tuple.rs b/src/test/debuginfo/simple-tuple.rs index b3c2704115095..8f69672c88844 100644 --- a/src/test/debuginfo/simple-tuple.rs +++ b/src/test/debuginfo/simple-tuple.rs @@ -9,6 +9,7 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g diff --git a/src/test/debuginfo/struct-in-enum.rs b/src/test/debuginfo/struct-in-enum.rs index bd044188dbcbc..14aaf67d5ae1b 100644 --- a/src/test/debuginfo/struct-in-enum.rs +++ b/src/test/debuginfo/struct-in-enum.rs @@ -11,6 +11,7 @@ // ignore-tidy-linelength // min-lldb-version: 310 // ignore-gdb-version: 7.11.90 - 7.12.9 +// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index 57d40cccf2d80..c89c0e4e7584d 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -10,6 +10,7 @@ // ignore-tidy-linelength // ignore-lldb +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // ignore-android: FIXME(#24958) // ignore-arm: FIXME(#24958) // ignore-aarch64: FIXME(#24958) diff --git a/src/test/debuginfo/union-smoke.rs b/src/test/debuginfo/union-smoke.rs index 433196b526c5c..622c7cf0d3334 100644 --- a/src/test/debuginfo/union-smoke.rs +++ b/src/test/debuginfo/union-smoke.rs @@ -9,6 +9,8 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 + // ignore-gdb-version: 7.11.90 - 7.12.9 // compile-flags:-g diff --git a/src/test/debuginfo/vec-slices.rs b/src/test/debuginfo/vec-slices.rs index d321df8431b88..888d9b28506b3 100644 --- a/src/test/debuginfo/vec-slices.rs +++ b/src/test/debuginfo/vec-slices.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-windows +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 // compile-flags:-g diff --git a/src/test/debuginfo/vec.rs b/src/test/debuginfo/vec.rs index fbb33b94d9577..dba947530fea8 100644 --- a/src/test/debuginfo/vec.rs +++ b/src/test/debuginfo/vec.rs @@ -9,6 +9,7 @@ // except according to those terms. // min-lldb-version: 310 +// ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // compile-flags:-g diff --git a/src/test/rustdoc/issue-46976.rs b/src/test/rustdoc/issue-46976.rs new file mode 100644 index 0000000000000..0df80fe3bd77a --- /dev/null +++ b/src/test/rustdoc/issue-46976.rs @@ -0,0 +1,12 @@ +// Copyright 2017 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(universal_impl_trait)] +pub fn ice(f: impl Fn()) {} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs new file mode 100644 index 0000000000000..3eb96c2ab9622 --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs @@ -0,0 +1,51 @@ +// Copyright 2018 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. + +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree, TokenNode, Span}; + +fn lit_span(tt: TokenTree) -> (Span, String) { + use TokenNode::*; + match tt.kind { + Literal(..) | Group(..) => (tt.span, tt.to_string().trim().into()), + _ => panic!("expected a literal in token tree, got: {:?}", tt) + } +} + +#[proc_macro] +pub fn parent_source_spans(input: TokenStream) -> TokenStream { + let mut tokens = input.into_iter(); + let (sp1, str1) = lit_span(tokens.next().expect("first string")); + let _ = tokens.next(); + let (sp2, str2) = lit_span(tokens.next().expect("second string")); + + sp1.error(format!("first final: {}", str1)).emit(); + sp2.error(format!("second final: {}", str2)).emit(); + + if let (Some(p1), Some(p2)) = (sp1.parent(), sp2.parent()) { + p1.error(format!("first parent: {}", str1)).emit(); + p2.error(format!("second parent: {}", str2)).emit(); + + if let (Some(gp1), Some(gp2)) = (p1.parent(), p2.parent()) { + gp1.error(format!("first grandparent: {}", str1)).emit(); + gp2.error(format!("second grandparent: {}", str2)).emit(); + } + } + + sp1.source().error(format!("first source: {}", str1)).emit(); + sp2.source().error(format!("second source: {}", str2)).emit(); + + "ok".parse().unwrap() +} diff --git a/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs b/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs new file mode 100644 index 0000000000000..4c71afbac4df1 --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs @@ -0,0 +1,61 @@ +// Copyright 2018 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. + +// aux-build:parent-source-spans.rs +// ignore-stage1 + +#![feature(proc_macro, decl_macro)] + +extern crate parent_source_spans; + +use parent_source_spans::parent_source_spans; + +macro one($a:expr, $b:expr) { + two!($a, $b); + //~^ ERROR first parent: "hello" + //~| ERROR second parent: "world" +} + +macro two($a:expr, $b:expr) { + three!($a, $b); + //~^ ERROR first final: "hello" + //~| ERROR second final: "world" + //~| ERROR first final: "yay" + //~| ERROR second final: "rust" +} + +// forwarding tokens directly doesn't create a new source chain +macro three($($tokens:tt)*) { + four!($($tokens)*); +} + +macro four($($tokens:tt)*) { + parent_source_spans!($($tokens)*); +} + +fn main() { + one!("hello", "world"); + //~^ ERROR first grandparent: "hello" + //~| ERROR second grandparent: "world" + //~| ERROR first source: "hello" + //~| ERROR second source: "world" + + two!("yay", "rust"); + //~^ ERROR first parent: "yay" + //~| ERROR second parent: "rust" + //~| ERROR first source: "yay" + //~| ERROR second source: "rust" + + three!("hip", "hop"); + //~^ ERROR first final: "hip" + //~| ERROR second final: "hop" + //~| ERROR first source: "hip" + //~| ERROR second source: "hop" +} diff --git a/src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr b/src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr new file mode 100644 index 0000000000000..7194b05b18e6c --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr @@ -0,0 +1,128 @@ +error: first final: "hello" + --> $DIR/parent-source-spans.rs:27:12 + | +27 | three!($a, $b); + | ^^ +... +44 | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: second final: "world" + --> $DIR/parent-source-spans.rs:27:16 + | +27 | three!($a, $b); + | ^^ +... +44 | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: first parent: "hello" + --> $DIR/parent-source-spans.rs:21:5 + | +21 | two!($a, $b); + | ^^^^^^^^^^^^^ +... +44 | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: second parent: "world" + --> $DIR/parent-source-spans.rs:21:5 + | +21 | two!($a, $b); + | ^^^^^^^^^^^^^ +... +44 | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: first grandparent: "hello" + --> $DIR/parent-source-spans.rs:44:5 + | +44 | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: second grandparent: "world" + --> $DIR/parent-source-spans.rs:44:5 + | +44 | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: first source: "hello" + --> $DIR/parent-source-spans.rs:44:5 + | +44 | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: second source: "world" + --> $DIR/parent-source-spans.rs:44:5 + | +44 | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: first final: "yay" + --> $DIR/parent-source-spans.rs:27:12 + | +27 | three!($a, $b); + | ^^ +... +50 | two!("yay", "rust"); + | -------------------- in this macro invocation + +error: second final: "rust" + --> $DIR/parent-source-spans.rs:27:16 + | +27 | three!($a, $b); + | ^^ +... +50 | two!("yay", "rust"); + | -------------------- in this macro invocation + +error: first parent: "yay" + --> $DIR/parent-source-spans.rs:50:5 + | +50 | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: second parent: "rust" + --> $DIR/parent-source-spans.rs:50:5 + | +50 | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: first source: "yay" + --> $DIR/parent-source-spans.rs:50:5 + | +50 | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: second source: "rust" + --> $DIR/parent-source-spans.rs:50:5 + | +50 | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: first final: "hip" + --> $DIR/parent-source-spans.rs:56:12 + | +56 | three!("hip", "hop"); + | ^^^^^ + +error: second final: "hop" + --> $DIR/parent-source-spans.rs:56:19 + | +56 | three!("hip", "hop"); + | ^^^^^ + +error: first source: "hip" + --> $DIR/parent-source-spans.rs:56:12 + | +56 | three!("hip", "hop"); + | ^^^^^ + +error: second source: "hop" + --> $DIR/parent-source-spans.rs:56:19 + | +56 | three!("hip", "hop"); + | ^^^^^ + +error: aborting due to 18 previous errors + diff --git a/src/test/ui/fat-ptr-cast.stderr b/src/test/ui/fat-ptr-cast.stderr index 35a97749e0024..b3c2b23cd3272 100644 --- a/src/test/ui/fat-ptr-cast.stderr +++ b/src/test/ui/fat-ptr-cast.stderr @@ -11,18 +11,24 @@ error[E0606]: casting `&[i32]` as `isize` is invalid | 21 | a as isize; //~ ERROR casting | ^^^^^^^^^^ + | + = help: cast through a raw pointer first error[E0606]: casting `&[i32]` as `i16` is invalid --> $DIR/fat-ptr-cast.rs:22:5 | 22 | a as i16; //~ ERROR casting `&[i32]` as `i16` is invalid | ^^^^^^^^ + | + = help: cast through a raw pointer first error[E0606]: casting `&[i32]` as `u32` is invalid --> $DIR/fat-ptr-cast.rs:23:5 | 23 | a as u32; //~ ERROR casting `&[i32]` as `u32` is invalid | ^^^^^^^^ + | + = help: cast through a raw pointer first error[E0605]: non-primitive cast: `std::boxed::Box<[i32]>` as `usize` --> $DIR/fat-ptr-cast.rs:24:5 diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 1b87576ba0b0d..dbeee39e606c6 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -901,6 +901,13 @@ impl<'test> TestCx<'test> { for line in reader.lines() { match line { Ok(line) => { + let line = + if line.starts_with("//") { + line[2..].trim_left() + } else { + line.as_str() + }; + if line.contains("#break") { breakpoint_lines.push(counter); }