diff --git a/configure b/configure index c42fc047667ab..0255b04caa316 100755 --- a/configure +++ b/configure @@ -499,13 +499,18 @@ case $CFG_CPUTYPE in CFG_CPUTYPE=aarch64 ;; - # At some point, when ppc64[le] support happens, this will need to do - # something clever. For now it's safe to assume that we're only ever - # interested in building 32 bit. - powerpc | ppc | ppc64) + powerpc | ppc) CFG_CPUTYPE=powerpc ;; + powerpc64 | ppc64) + CFG_CPUTYPE=powerpc64 + ;; + + powerpc64le | ppc64le) + CFG_CPUTYPE=powerpc64le + ;; + x86_64 | x86-64 | x64 | amd64) CFG_CPUTYPE=x86_64 ;; diff --git a/mk/cfg/powerpc64-unknown-linux-gnu.mk b/mk/cfg/powerpc64-unknown-linux-gnu.mk new file mode 100644 index 0000000000000..a9e8585ad6db5 --- /dev/null +++ b/mk/cfg/powerpc64-unknown-linux-gnu.mk @@ -0,0 +1,24 @@ +# powerpc64-unknown-linux-gnu configuration +CROSS_PREFIX_powerpc64-unknown-linux-gnu=powerpc64-linux-gnu- +CC_powerpc64-unknown-linux-gnu=$(CC) +CXX_powerpc64-unknown-linux-gnu=$(CXX) +CPP_powerpc64-unknown-linux-gnu=$(CPP) +AR_powerpc64-unknown-linux-gnu=$(AR) +CFG_LIB_NAME_powerpc64-unknown-linux-gnu=lib$(1).so +CFG_STATIC_LIB_NAME_powerpc64-unknown-linux-gnu=lib$(1).a +CFG_LIB_GLOB_powerpc64-unknown-linux-gnu=lib$(1)-*.so +CFG_LIB_DSYM_GLOB_powerpc64-unknown-linux-gnu=lib$(1)-*.dylib.dSYM +CFG_CFLAGS_powerpc64-unknown-linux-gnu := -m64 $(CFLAGS) +CFG_GCCISH_CFLAGS_powerpc64-unknown-linux-gnu := -Wall -Werror -g -fPIC -m64 $(CFLAGS) +CFG_GCCISH_CXXFLAGS_powerpc64-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) +CFG_GCCISH_LINK_FLAGS_powerpc64-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m64 +CFG_GCCISH_DEF_FLAG_powerpc64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= +CFG_LLC_FLAGS_powerpc64-unknown-linux-gnu := +CFG_INSTALL_NAME_powerpc64-unknown-linux-gnu = +CFG_EXE_SUFFIX_powerpc64-unknown-linux-gnu = +CFG_WINDOWSY_powerpc64-unknown-linux-gnu := +CFG_UNIXY_powerpc64-unknown-linux-gnu := 1 +CFG_LDPATH_powerpc64-unknown-linux-gnu := +CFG_RUN_powerpc64-unknown-linux-gnu=$(2) +CFG_RUN_TARG_powerpc64-unknown-linux-gnu=$(call CFG_RUN_powerpc64-unknown-linux-gnu,,$(2)) +CFG_GNU_TRIPLE_powerpc64-unknown-linux-gnu := powerpc64-unknown-linux-gnu diff --git a/mk/cfg/powerpc64le-unknown-linux-gnu.mk b/mk/cfg/powerpc64le-unknown-linux-gnu.mk new file mode 100644 index 0000000000000..a2049331ab2e9 --- /dev/null +++ b/mk/cfg/powerpc64le-unknown-linux-gnu.mk @@ -0,0 +1,24 @@ +# powerpc64le-unknown-linux-gnu configuration +CROSS_PREFIX_powerpc64le-unknown-linux-gnu=powerpc64le-linux-gnu- +CC_powerpc64le-unknown-linux-gnu=$(CC) +CXX_powerpc64le-unknown-linux-gnu=$(CXX) +CPP_powerpc64le-unknown-linux-gnu=$(CPP) +AR_powerpc64le-unknown-linux-gnu=$(AR) +CFG_LIB_NAME_powerpc64le-unknown-linux-gnu=lib$(1).so +CFG_STATIC_LIB_NAME_powerpc64le-unknown-linux-gnu=lib$(1).a +CFG_LIB_GLOB_powerpc64le-unknown-linux-gnu=lib$(1)-*.so +CFG_LIB_DSYM_GLOB_powerpc64le-unknown-linux-gnu=lib$(1)-*.dylib.dSYM +CFG_CFLAGS_powerpc64le-unknown-linux-gnu := -m64 $(CFLAGS) +CFG_GCCISH_CFLAGS_powerpc64le-unknown-linux-gnu := -Wall -Werror -g -fPIC -m64 $(CFLAGS) +CFG_GCCISH_CXXFLAGS_powerpc64le-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) +CFG_GCCISH_LINK_FLAGS_powerpc64le-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m64 +CFG_GCCISH_DEF_FLAG_powerpc64le-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= +CFG_LLC_FLAGS_powerpc64le-unknown-linux-gnu := +CFG_INSTALL_NAME_powerpc64le-unknown-linux-gnu = +CFG_EXE_SUFFIX_powerpc64le-unknown-linux-gnu = +CFG_WINDOWSY_powerpc64le-unknown-linux-gnu := +CFG_UNIXY_powerpc64le-unknown-linux-gnu := 1 +CFG_LDPATH_powerpc64le-unknown-linux-gnu := +CFG_RUN_powerpc64le-unknown-linux-gnu=$(2) +CFG_RUN_TARG_powerpc64le-unknown-linux-gnu=$(call CFG_RUN_powerpc64le-unknown-linux-gnu,,$(2)) +CFG_GNU_TRIPLE_powerpc64le-unknown-linux-gnu := powerpc64le-unknown-linux-gnu diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index fbafee102e4b2..103ca463f7a58 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -38,6 +38,8 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[ ("mips", "mips"), ("msp430", "msp430"), ("powerpc", "powerpc"), + ("powerpc64", "powerpc64"), + ("powerpc64le", "powerpc64le"), ("s390x", "systemz"), ("sparc", "sparc"), ("x86_64", "x86_64"), diff --git a/src/doc/book/crates-and-modules.md b/src/doc/book/crates-and-modules.md index 2b6297640d09f..849c5f1212a57 100644 --- a/src/doc/book/crates-and-modules.md +++ b/src/doc/book/crates-and-modules.md @@ -2,7 +2,7 @@ When a project starts getting large, it’s considered good software engineering practice to split it up into a bunch of smaller pieces, and then -fit them together. It’s also important to have a well-defined interface, so +fit them together. It is also important to have a well-defined interface, so that some of your functionality is private, and some is public. To facilitate these kinds of things, Rust has a module system. diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index f72737566a493..e9d271e753768 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -505,9 +505,11 @@ Cargo checks to see if any of your project’s files have been modified, and onl rebuilds your project if they’ve changed since the last time you built it. With simple projects, Cargo doesn't bring a whole lot over just using `rustc`, -but it will become useful in future. With complex projects composed of multiple -crates, it’s much easier to let Cargo coordinate the build. With Cargo, you can -run `cargo build`, and it should work the right way. +but it will become useful in future. This is especially true when you start +using crates; these are synonymous with a ‘library’ or ‘package’ in other +programming languages. For complex projects composed of multiple crates, it’s +much easier to let Cargo coordinate the build. Using Cargo, you can run `cargo +build`, and it should work the right way. ## Building for Release diff --git a/src/doc/reference.md b/src/doc/reference.md index 87104b4526f72..b786b59ec986d 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2044,7 +2044,7 @@ The following configurations must be defined by the implementation: production. For example, it controls the behavior of the standard library's `debug_assert!` macro. * `target_arch = "..."` - Target CPU architecture, such as `"x86"`, `"x86_64"` - `"mips"`, `"powerpc"`, `"arm"`, or `"aarch64"`. + `"mips"`, `"powerpc"`, `"powerpc64"`, `"powerpc64le"`, `"arm"`, or `"aarch64"`. * `target_endian = "..."` - Endianness of the target CPU, either `"little"` or `"big"`. * `target_env = ".."` - An option provided by the compiler by default diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index eaaa9391d3115..91d229b819df1 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -55,7 +55,9 @@ extern "C" { const MIN_ALIGN: usize = 8; #[cfg(all(any(target_arch = "x86", target_arch = "x86_64", - target_arch = "aarch64")))] + target_arch = "aarch64", + target_arch = "powerpc64", + target_arch = "powerpc64le")))] const MIN_ALIGN: usize = 16; // MALLOCX_ALIGN(a) macro diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index a4e98e413bbb5..ffb6999d6e3fe 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -29,7 +29,9 @@ extern crate libc; target_arch = "arm", target_arch = "mips", target_arch = "mipsel", - target_arch = "powerpc")))] + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "powerpc64le")))] const MIN_ALIGN: usize = 8; #[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64")))] diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 93a46090b90eb..3689312bed1d4 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -16,9 +16,6 @@ use lint::{LintPass, LateLintPass, LintArray}; -// name of the future-incompatible group -pub const FUTURE_INCOMPATIBLE: &'static str = "future_incompatible"; - declare_lint! { pub CONST_ERR, Warn, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index d7eacbfff90db..1abfa2bfc59d1 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -76,10 +76,22 @@ pub struct LintStore { /// is true if the lint group was added by a plugin. lint_groups: FnvHashMap<&'static str, (Vec, bool)>, + /// Extra info for future incompatibility lints, descibing the + /// issue or RFC that caused the incompatibility. + future_incompatible: FnvHashMap, + /// Maximum level a lint can be lint_cap: Option, } +/// Extra information for a future incompatibility lint. See the call +/// to `register_future_incompatible` in `librustc_lint/lib.rs` for +/// guidelines. +pub struct FutureIncompatibleInfo { + pub id: LintId, + pub reference: &'static str // e.g., a URL for an issue/PR/RFC or error code +} + /// The targed of the `by_name` map, which accounts for renaming/deprecation. enum TargetLint { /// A direct lint target @@ -124,6 +136,7 @@ impl LintStore { late_passes: Some(vec!()), by_name: FnvHashMap(), levels: FnvHashMap(), + future_incompatible: FnvHashMap(), lint_groups: FnvHashMap(), lint_cap: None, } @@ -183,6 +196,20 @@ impl LintStore { } } + pub fn register_future_incompatible(&mut self, + sess: Option<&Session>, + lints: Vec) { + let ids = lints.iter().map(|f| f.id).collect(); + self.register_group(sess, false, "future_incompatible", ids); + for info in lints { + self.future_incompatible.insert(info.id, info); + } + } + + pub fn future_incompatible(&self, id: LintId) -> Option<&FutureIncompatibleInfo> { + self.future_incompatible.get(&id) + } + pub fn register_group(&mut self, sess: Option<&Session>, from_plugin: bool, name: &'static str, to: Vec) { @@ -418,14 +445,18 @@ pub fn raw_struct_lint<'a>(sess: &'a Session, }; // Check for future incompatibility lints and issue a stronger warning. - let future_incompat_lints = &lints.lint_groups[builtin::FUTURE_INCOMPATIBLE]; - let this_id = LintId::of(lint); - if future_incompat_lints.0.iter().any(|&id| id == this_id) { - let msg = "this lint will become a HARD ERROR in a future release!"; + if let Some(future_incompatible) = lints.future_incompatible(LintId::of(lint)) { + let explanation = format!("this was previously accepted by the compiler \ + but is being phased out; \ + it will become a hard error in a future release!"); + let citation = format!("for more information, see {}", + future_incompatible.reference); if let Some(sp) = span { - err.span_note(sp, msg); + err.fileline_warn(sp, &explanation); + err.fileline_note(sp, &citation); } else { - err.note(msg); + err.warn(&explanation); + err.note(&citation); } } diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 9c689daab86a7..6061525ef398c 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -41,7 +41,7 @@ use rustc_front::hir; pub use lint::context::{LateContext, EarlyContext, LintContext, LintStore, raw_emit_lint, check_crate, check_ast_crate, gather_attrs, - raw_struct_lint, GatherNodeLevels}; + raw_struct_lint, GatherNodeLevels, FutureIncompatibleInfo}; /// Specification of a single lint. #[derive(Copy, Clone, Debug)] diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 666903b4eed42..51149101e0c2d 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -80,7 +80,7 @@ pub struct Target { /// Vendor name to use for conditional compilation. pub target_vendor: String, /// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm", - /// "aarch64", "mips", and "powerpc". "mips" includes "mipsel". + /// "aarch64", "mips", "powerpc", "powerpc64" and "powerpc64le". "mips" includes "mipsel". pub arch: String, /// Optional settings with defaults. pub options: TargetOptions, @@ -413,6 +413,8 @@ impl Target { mips_unknown_linux_gnu, mipsel_unknown_linux_gnu, powerpc_unknown_linux_gnu, + powerpc64_unknown_linux_gnu, + powerpc64le_unknown_linux_gnu, arm_unknown_linux_gnueabi, arm_unknown_linux_gnueabihf, aarch64_unknown_linux_gnu, diff --git a/src/librustc_back/target/powerpc64_unknown_linux_gnu.rs b/src/librustc_back/target/powerpc64_unknown_linux_gnu.rs new file mode 100644 index 0000000000000..83970e73b933c --- /dev/null +++ b/src/librustc_back/target/powerpc64_unknown_linux_gnu.rs @@ -0,0 +1,27 @@ +// Copyright 2012-2016 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. + +use target::Target; + +pub fn target() -> Target { + let mut base = super::linux_base::opts(); + base.pre_link_args.push("-m64".to_string()); + + Target { + llvm_target: "powerpc64-unknown-linux-gnu".to_string(), + target_endian: "big".to_string(), + target_pointer_width: "64".to_string(), + arch: "powerpc64".to_string(), + target_os: "linux".to_string(), + target_env: "gnu".to_string(), + target_vendor: "unknown".to_string(), + options: base, + } +} diff --git a/src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs b/src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs new file mode 100644 index 0000000000000..0f5252fdc23a5 --- /dev/null +++ b/src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs @@ -0,0 +1,27 @@ +// Copyright 2012-2016 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. + +use target::Target; + +pub fn target() -> Target { + let mut base = super::linux_base::opts(); + base.pre_link_args.push("-m64".to_string()); + + Target { + llvm_target: "powerpc64le-unknown-linux-gnu".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + arch: "powerpc64le".to_string(), + target_os: "linux".to_string(), + target_env: "gnu".to_string(), + target_vendor: "unknown".to_string(), + options: base, + } +} diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 825dee9f659f5..53acbe3af6743 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -54,6 +54,7 @@ pub use rustc::util as util; use session::Session; use lint::LintId; +use lint::FutureIncompatibleInfo; mod bad_style; mod builtin; @@ -144,9 +145,29 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { UNUSED_MUT, UNREACHABLE_CODE, UNUSED_MUST_USE, UNUSED_UNSAFE, PATH_STATEMENTS, UNUSED_ATTRIBUTES); - add_lint_group!(sess, FUTURE_INCOMPATIBLE, - PRIVATE_IN_PUBLIC, INVALID_TYPE_PARAM_DEFAULT, - MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT); + // Guidelines for creating a future incompatibility lint: + // + // - Create a lint defaulting to warn as normal, with ideally the same error + // message you would normally give + // - Add a suitable reference, typically an RFC or tracking issue. Go ahead + // and include the full URL. + // - Later, change lint to error + // - Eventually, remove lint + store.register_future_incompatible(sess, vec![ + FutureIncompatibleInfo { + id: LintId::of(PRIVATE_IN_PUBLIC), + reference: "the explanation for E0446 (`--explain E0446`)", + }, + FutureIncompatibleInfo { + id: LintId::of(INVALID_TYPE_PARAM_DEFAULT), + reference: "PR 30742 ", + }, + FutureIncompatibleInfo { + id: LintId::of(MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT), + reference: "RFC 218 ", + }, + ]); // We have one lint pass defined specially store.register_late_pass(sess, false, box lint::GatherNodeLevels); diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 955e68be0b006..d3da93a3e080d 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -329,9 +329,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> { // This code is here instead of in visit_item so that the // crate module gets processed as well. if self.prev_level.is_some() { - for export in self.export_map.get(&id).expect("module isn't found in export map") { - if let Some(node_id) = self.tcx.map.as_local_node_id(export.def_id) { - self.update(node_id, Some(AccessLevel::Exported)); + if let Some(exports) = self.export_map.get(&id) { + for export in exports { + if let Some(node_id) = self.tcx.map.as_local_node_id(export.def_id) { + self.update(node_id, Some(AccessLevel::Exported)); + } } } } @@ -1528,7 +1530,7 @@ impl<'a, 'tcx: 'a, 'v> Visitor<'v> for SearchInterfaceForPrivateItemsVisitor<'a, lint::builtin::PRIVATE_IN_PUBLIC, node_id, ty.span, - "private type in public interface (error E0446)".to_string() + format!("private type in public interface"), ); } } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 9857e83bd621a..8464d3ef29870 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -101,7 +101,6 @@ use resolve_imports::Shadowable; pub mod diagnostics; mod check_unused; -mod record_exports; mod build_reduced_graph; mod resolve_imports; @@ -4014,9 +4013,6 @@ pub fn create_resolver<'a, 'tcx>(session: &'a Session, resolve_imports::resolve_imports(&mut resolver); session.abort_if_errors(); - record_exports::record(&mut resolver); - session.abort_if_errors(); - resolver } diff --git a/src/librustc_resolve/record_exports.rs b/src/librustc_resolve/record_exports.rs deleted file mode 100644 index 13f4348f79522..0000000000000 --- a/src/librustc_resolve/record_exports.rs +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2012-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. - - -// Export recording -// -// This pass simply determines what all "export" keywords refer to and -// writes the results into the export map. -// -// FIXME #4953 This pass will be removed once exports change to per-item. -// Then this operation can simply be performed as part of item (or import) -// processing. - -use {Module, NameBinding, Resolver}; -use Namespace::{TypeNS, ValueNS}; - -use build_reduced_graph; -use module_to_string; - -use rustc::middle::def::Export; -use syntax::ast; - -use std::ops::{Deref, DerefMut}; - -struct ExportRecorder<'a, 'b: 'a, 'tcx: 'b> { - resolver: &'a mut Resolver<'b, 'tcx>, -} - -// Deref and DerefMut impls allow treating ExportRecorder as Resolver. -impl<'a, 'b, 'tcx:'b> Deref for ExportRecorder<'a, 'b, 'tcx> { - type Target = Resolver<'b, 'tcx>; - - fn deref<'c>(&'c self) -> &'c Resolver<'b, 'tcx> { - &*self.resolver - } -} - -impl<'a, 'b, 'tcx:'b> DerefMut for ExportRecorder<'a, 'b, 'tcx> { - fn deref_mut<'c>(&'c mut self) -> &'c mut Resolver<'b, 'tcx> { - &mut *self.resolver - } -} - -impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> { - fn record_exports_for_module_subtree(&mut self, module_: Module<'b>) { - // If this isn't a local krate, then bail out. We don't need to record - // exports for nonlocal crates. - - match module_.def_id() { - Some(def_id) if def_id.is_local() => { - // OK. Continue. - debug!("(recording exports for module subtree) recording exports for local \ - module `{}`", - module_to_string(module_)); - } - None => { - // Record exports for the root module. - debug!("(recording exports for module subtree) recording exports for root module \ - `{}`", - module_to_string(module_)); - } - Some(_) => { - // Bail out. - debug!("(recording exports for module subtree) not recording exports for `{}`", - module_to_string(module_)); - return; - } - } - - self.record_exports_for_module(module_); - build_reduced_graph::populate_module_if_necessary(self.resolver, &module_); - - for (_, child_name_bindings) in module_.children.borrow().iter() { - match child_name_bindings.type_ns.module() { - None => { - // Nothing to do. - } - Some(child_module) => { - self.record_exports_for_module_subtree(child_module); - } - } - } - - for (_, child_module) in module_.anonymous_children.borrow().iter() { - self.record_exports_for_module_subtree(child_module); - } - } - - fn record_exports_for_module(&mut self, module_: Module<'b>) { - let mut exports = Vec::new(); - - self.add_exports_for_module(&mut exports, module_); - match module_.def_id() { - Some(def_id) => { - let node_id = self.ast_map.as_local_node_id(def_id).unwrap(); - self.export_map.insert(node_id, exports); - debug!("(computing exports) writing exports for {} (some)", node_id); - } - None => {} - } - } - - fn add_export_of_namebinding(&mut self, - exports: &mut Vec, - name: ast::Name, - namebinding: &NameBinding) { - match namebinding.def() { - Some(d) => { - debug!("(computing exports) YES: export '{}' => {:?}", - name, - d.def_id()); - exports.push(Export { - name: name, - def_id: d.def_id(), - }); - } - d_opt => { - debug!("(computing exports) NO: {:?}", d_opt); - } - } - } - - fn add_exports_for_module(&mut self, exports: &mut Vec, module_: Module<'b>) { - for (name, import_resolution) in module_.import_resolutions.borrow().iter() { - let xs = [TypeNS, ValueNS]; - for &ns in &xs { - if !import_resolution[ns].is_public { - continue; - } - - match import_resolution[ns].target { - Some(ref target) => { - debug!("(computing exports) maybe export '{}'", name); - self.add_export_of_namebinding(exports, *name, &target.binding) - } - _ => (), - } - } - } - } -} - -pub fn record(resolver: &mut Resolver) { - let mut recorder = ExportRecorder { resolver: resolver }; - let root_module = recorder.graph_root; - recorder.record_exports_for_module_subtree(root_module); -} diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 53d1b888d8e87..abaf45cb1704d 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -688,6 +688,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { id: directive.id, is_public: directive.is_public }; + + self.add_export(module_, target, &import_resolution[namespace]); *used_public = name_binding.is_public(); } UnboundResult => { @@ -827,6 +829,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { dest_import_resolution[ns] = ImportResolution { id: id, is_public: is_public, target: Some(target.clone()) }; + self.add_export(module_, *name, &dest_import_resolution[ns]); } _ => {} } @@ -919,6 +922,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { id: id, is_public: is_public }; + self.add_export(module_, name, &dest_import_resolution[namespace]); } } else { // FIXME #30159: This is required for backwards compatability. @@ -935,6 +939,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { name); } + fn add_export(&mut self, module: Module<'b>, name: Name, resolution: &ImportResolution<'b>) { + if !resolution.is_public { return } + let node_id = match module.def_id() { + Some(def_id) => self.resolver.ast_map.as_local_node_id(def_id).unwrap(), + None => return, + }; + let export = match resolution.target.as_ref().unwrap().binding.def() { + Some(def) => Export { name: name, def_id: def.def_id() }, + None => return, + }; + self.resolver.export_map.entry(node_id).or_insert(Vec::new()).push(export); + } + /// Checks that imported names and items don't have the same name. fn check_for_conflicting_import(&mut self, import_resolution: &ImportResolutionPerNamespace, diff --git a/src/librustc_trans/trans/cabi.rs b/src/librustc_trans/trans/cabi.rs index 0ff5264c00f0f..4bfbb8b69f0ac 100644 --- a/src/librustc_trans/trans/cabi.rs +++ b/src/librustc_trans/trans/cabi.rs @@ -19,6 +19,7 @@ use trans::cabi_x86_win64; use trans::cabi_arm; use trans::cabi_aarch64; use trans::cabi_powerpc; +use trans::cabi_powerpc64; use trans::cabi_mips; use trans::type_::Type; @@ -127,6 +128,7 @@ pub fn compute_abi_info(ccx: &CrateContext, }, "mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def), "powerpc" => cabi_powerpc::compute_abi_info(ccx, atys, rty, ret_def), + "powerpc64" | "powerpc64le" => cabi_powerpc64::compute_abi_info(ccx, atys, rty, ret_def), a => ccx.sess().fatal(&format!("unrecognized arch \"{}\" in target specification", a) ), } diff --git a/src/librustc_trans/trans/cabi_powerpc64.rs b/src/librustc_trans/trans/cabi_powerpc64.rs new file mode 100644 index 0000000000000..cba73004279d6 --- /dev/null +++ b/src/librustc_trans/trans/cabi_powerpc64.rs @@ -0,0 +1,259 @@ +// Copyright 2014-2016 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. + +// FIXME: The PowerPC64 ABI needs to zero or sign extend function +// call parameters, but compute_abi_info() is passed LLVM types +// which have no sign information. +// +// Alignment of 128 bit types is not currently handled, this will +// need to be fixed when PowerPC vector support is added. + +use llvm::{Integer, Pointer, Float, Double, Struct, Array, Attribute}; +use trans::cabi::{FnType, ArgType}; +use trans::context::CrateContext; +use trans::type_::Type; + +use std::cmp; + +fn align_up_to(off: usize, a: usize) -> usize { + return (off + a - 1) / a * a; +} + +fn align(off: usize, ty: Type) -> usize { + let a = ty_align(ty); + return align_up_to(off, a); +} + +fn ty_align(ty: Type) -> usize { + match ty.kind() { + Integer => ((ty.int_width() as usize) + 7) / 8, + Pointer => 8, + Float => 4, + Double => 8, + Struct => { + if ty.is_packed() { + 1 + } else { + let str_tys = ty.field_types(); + str_tys.iter().fold(1, |a, t| cmp::max(a, ty_align(*t))) + } + } + Array => { + let elt = ty.element_type(); + ty_align(elt) + } + _ => panic!("ty_align: unhandled type") + } +} + +fn ty_size(ty: Type) -> usize { + match ty.kind() { + Integer => ((ty.int_width() as usize) + 7) / 8, + Pointer => 8, + Float => 4, + Double => 8, + Struct => { + if ty.is_packed() { + let str_tys = ty.field_types(); + str_tys.iter().fold(0, |s, t| s + ty_size(*t)) + } else { + let str_tys = ty.field_types(); + let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t)); + align(size, ty) + } + } + Array => { + let len = ty.array_length(); + let elt = ty.element_type(); + let eltsz = ty_size(elt); + len * eltsz + } + _ => panic!("ty_size: unhandled type") + } +} + +fn is_homogenous_aggregate_ty(ty: Type) -> Option<(Type, u64)> { + fn check_array(ty: Type) -> Option<(Type, u64)> { + let len = ty.array_length() as u64; + if len == 0 { + return None + } + let elt = ty.element_type(); + + // if our element is an HFA/HVA, so are we; multiply members by our len + is_homogenous_aggregate_ty(elt).map(|(base_ty, members)| (base_ty, len * members)) + } + + fn check_struct(ty: Type) -> Option<(Type, u64)> { + let str_tys = ty.field_types(); + if str_tys.len() == 0 { + return None + } + + let mut prev_base_ty = None; + let mut members = 0; + for opt_homog_agg in str_tys.iter().map(|t| is_homogenous_aggregate_ty(*t)) { + match (prev_base_ty, opt_homog_agg) { + // field isn't itself an HFA, so we aren't either + (_, None) => return None, + + // first field - store its type and number of members + (None, Some((field_ty, field_members))) => { + prev_base_ty = Some(field_ty); + members = field_members; + }, + + // 2nd or later field - give up if it's a different type; otherwise incr. members + (Some(prev_ty), Some((field_ty, field_members))) => { + if prev_ty != field_ty { + return None; + } + members += field_members; + } + } + } + + // Because of previous checks, we know prev_base_ty is Some(...) because + // 1. str_tys has at least one element; and + // 2. prev_base_ty was filled in (or we would've returned early) + let (base_ty, members) = (prev_base_ty.unwrap(), members); + + // Ensure there is no padding. + if ty_size(ty) == ty_size(base_ty) * (members as usize) { + Some((base_ty, members)) + } else { + None + } + } + + let homog_agg = match ty.kind() { + Float => Some((ty, 1)), + Double => Some((ty, 1)), + Array => check_array(ty), + Struct => check_struct(ty), + _ => None + }; + + // Ensure we have at most eight uniquely addressable members + homog_agg.and_then(|(base_ty, members)| { + if members > 0 && members <= 8 { + Some((base_ty, members)) + } else { + None + } + }) +} + +fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { + if is_reg_ty(ty) { + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; + return ArgType::direct(ty, None, None, attr); + } + + // The PowerPC64 big endian ABI doesn't return aggregates in registers + if ccx.sess().target.target.arch == "powerpc64" { + return ArgType::indirect(ty, Some(Attribute::StructRet)) + } + + if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) { + let llty = Type::array(&base_ty, members); + return ArgType::direct(ty, Some(llty), None, None); + } + let size = ty_size(ty); + if size <= 16 { + let llty = if size <= 1 { + Type::i8(ccx) + } else if size <= 2 { + Type::i16(ccx) + } else if size <= 4 { + Type::i32(ccx) + } else if size <= 8 { + Type::i64(ccx) + } else { + Type::array(&Type::i64(ccx), ((size + 7 ) / 8 ) as u64) + }; + return ArgType::direct(ty, Some(llty), None, None); + } + + ArgType::indirect(ty, Some(Attribute::StructRet)) +} + +fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType { + if is_reg_ty(ty) { + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; + return ArgType::direct(ty, None, None, attr); + } + if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) { + let llty = Type::array(&base_ty, members); + return ArgType::direct(ty, Some(llty), None, None); + } + + ArgType::direct( + ty, + Some(struct_ty(ccx, ty)), + None, + None + ) +} + +fn is_reg_ty(ty: Type) -> bool { + match ty.kind() { + Integer + | Pointer + | Float + | Double => true, + _ => false + } +} + +fn coerce_to_long(ccx: &CrateContext, size: usize) -> Vec { + let long_ty = Type::i64(ccx); + let mut args = Vec::new(); + + let mut n = size / 64; + while n > 0 { + args.push(long_ty); + n -= 1; + } + + let r = size % 64; + if r > 0 { + args.push(Type::ix(ccx, r as u64)); + } + + args +} + +fn struct_ty(ccx: &CrateContext, ty: Type) -> Type { + let size = ty_size(ty) * 8; + Type::struct_(ccx, &coerce_to_long(ccx, size), false) +} + +pub fn compute_abi_info(ccx: &CrateContext, + atys: &[Type], + rty: Type, + ret_def: bool) -> FnType { + let ret_ty = if ret_def { + classify_ret_ty(ccx, rty) + } else { + ArgType::direct(Type::void(ccx), None, None, None) + }; + + let mut arg_tys = Vec::new(); + for &aty in atys { + let ty = classify_arg_ty(ccx, aty); + arg_tys.push(ty); + }; + + return FnType { + arg_tys: arg_tys, + ret_ty: ret_ty, + }; +} diff --git a/src/librustc_trans/trans/mod.rs b/src/librustc_trans/trans/mod.rs index 1fbc0d5c01529..f474e288efe86 100644 --- a/src/librustc_trans/trans/mod.rs +++ b/src/librustc_trans/trans/mod.rs @@ -31,6 +31,7 @@ mod cabi_aarch64; mod cabi_arm; mod cabi_mips; mod cabi_powerpc; +mod cabi_powerpc64; mod cabi_x86; mod cabi_x86_64; mod cabi_x86_win64; diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 93ceaf8b11f12..dfa144699b217 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -595,14 +595,10 @@ fn bad_struct_kind_err(sess: &Session, pat: &hir::Pat, path: &hir::Path, lint: b let name = pprust::path_to_string(path); let msg = format!("`{}` does not name a tuple variant or a tuple struct", name); if lint { - let expanded_msg = - format!("{}; RFC 218 disallowed matching of unit variants or unit structs via {}(..)", - msg, - name); sess.add_lint(lint::builtin::MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT, pat.id, pat.span, - expanded_msg); + msg); } else { span_err!(sess, pat.span, E0164, "{}", msg); } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index fbbd2f02908f1..af2824d0930d2 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1917,8 +1917,8 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, lint::builtin::INVALID_TYPE_PARAM_DEFAULT, param.id, param.span, - format!("defaults for type parameters are only allowed \ - on `struct` or `enum` definitions (see issue #27336)")); + format!("defaults for type parameters are only allowed on type definitions, \ + like `struct` or `enum`")); } } diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 760733872ea19..6726f52224755 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -615,6 +615,8 @@ pub mod consts { /// - mips /// - mipsel /// - powerpc + /// - powerpc64 + /// - powerpc64le #[stable(feature = "env", since = "1.0.0")] pub const ARCH: &'static str = super::arch::ARCH; @@ -867,6 +869,16 @@ mod arch { pub const ARCH: &'static str = "powerpc"; } +#[cfg(target_arch = "powerpc64")] +mod arch { + pub const ARCH: &'static str = "powerpc64"; +} + +#[cfg(target_arch = "powerpc64le")] +mod arch { + pub const ARCH: &'static str = "powerpc64le"; +} + #[cfg(target_arch = "le32")] mod arch { pub const ARCH: &'static str = "le32"; diff --git a/src/libstd/os/linux/raw.rs b/src/libstd/os/linux/raw.rs index f44199f311bfa..953d0917141d1 100644 --- a/src/libstd/os/linux/raw.rs +++ b/src/libstd/os/linux/raw.rs @@ -205,7 +205,8 @@ mod arch { } } -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "powerpc64le"))] mod arch { use super::{dev_t, mode_t}; use os::raw::{c_long, c_int}; diff --git a/src/libstd/os/openbsd/raw.rs b/src/libstd/os/openbsd/raw.rs index 209546c4e4f56..b4d493953030e 100644 --- a/src/libstd/os/openbsd/raw.rs +++ b/src/libstd/os/openbsd/raw.rs @@ -16,7 +16,7 @@ use os::raw::c_long; use os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64; -#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u32; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = i32; #[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32; #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; diff --git a/src/libstd/os/raw.rs b/src/libstd/os/raw.rs index 3bc063f426920..62080fee48ec1 100644 --- a/src/libstd/os/raw.rs +++ b/src/libstd/os/raw.rs @@ -14,11 +14,17 @@ #[cfg(any(target_os = "android", all(target_os = "linux", any(target_arch = "aarch64", - target_arch = "arm"))))] + target_arch = "arm", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "powerpc64le"))))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8; #[cfg(not(any(target_os = "android", all(target_os = "linux", any(target_arch = "aarch64", - target_arch = "arm")))))] + target_arch = "arm", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "powerpc64le")))))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8; #[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8; #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8; diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 23a368a30a52b..619f100f1a137 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -30,14 +30,19 @@ mod imp { target_arch = "x86", target_arch = "arm", target_arch = "aarch64", - target_arch = "powerpc")))] + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "powerpc64le")))] fn getrandom(buf: &mut [u8]) -> libc::c_long { #[cfg(target_arch = "x86_64")] const NR_GETRANDOM: libc::c_long = 318; #[cfg(target_arch = "x86")] const NR_GETRANDOM: libc::c_long = 355; - #[cfg(any(target_arch = "arm", target_arch = "powerpc"))] + #[cfg(target_arch = "arm")] const NR_GETRANDOM: libc::c_long = 384; + #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64", + target_arch = "powerpc64le"))] + const NR_GETRANDOM: libc::c_long = 359; #[cfg(target_arch = "aarch64")] const NR_GETRANDOM: libc::c_long = 278; @@ -51,7 +56,9 @@ mod imp { target_arch = "x86", target_arch = "arm", target_arch = "aarch64", - target_arch = "powerpc"))))] + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "powerpc64le"))))] fn getrandom(_buf: &mut [u8]) -> libc::c_long { -1 } fn getrandom_fill_bytes(v: &mut [u8]) { @@ -88,7 +95,9 @@ mod imp { target_arch = "x86", target_arch = "arm", target_arch = "aarch64", - target_arch = "powerpc")))] + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "powerpc64le")))] fn is_getrandom_available() -> bool { use sync::atomic::{AtomicBool, Ordering}; use sync::Once; @@ -116,7 +125,9 @@ mod imp { target_arch = "x86", target_arch = "arm", target_arch = "aarch64", - target_arch = "powerpc"))))] + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "powerpc64le"))))] fn is_getrandom_available() -> bool { false } /// A random number generator that retrieves randomness straight from diff --git a/src/libstd/sys/common/libunwind.rs b/src/libstd/sys/common/libunwind.rs index feb05c7b56008..77d1eed96231d 100644 --- a/src/libstd/sys/common/libunwind.rs +++ b/src/libstd/sys/common/libunwind.rs @@ -83,7 +83,8 @@ pub const unwinder_private_data_size: usize = 2; #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] pub const unwinder_private_data_size: usize = 2; -#[cfg(target_arch = "powerpc")] +#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64", + target_arch = "powerpc64le"))] pub const unwinder_private_data_size: usize = 2; #[repr(C)] diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index e3ce8e0de4b12..f885733c2d18f 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -23,6 +23,7 @@ pub use self::duration::Duration; mod duration; /// A measurement of a monotonically increasing clock. +/// Opaque and useful only with `Duration`. /// /// Instants are always guaranteed to be greater than any previously measured /// instant when created, and are often useful for tasks such as measuring @@ -42,8 +43,8 @@ mod duration; #[unstable(feature = "time2", reason = "recently added", issue = "29866")] pub struct Instant(time::Instant); -/// A measurement of the system clock appropriate for timestamps such as those -/// on files on the filesystem. +/// A measurement of the system clock, useful for talking to +/// external entities like the file system or other processes. /// /// Distinct from the `Instant` type, this time measurement **is not /// monotonic**. This means that you can save a file to the file system, then diff --git a/src/libsyntax/errors/mod.rs b/src/libsyntax/errors/mod.rs index f269dee31d9ea..6983c74696ac8 100644 --- a/src/libsyntax/errors/mod.rs +++ b/src/libsyntax/errors/mod.rs @@ -161,6 +161,17 @@ impl<'a> DiagnosticBuilder<'a> { self.sub(Level::Note, msg, Some(sp), None); self } + pub fn warn(&mut self, msg: &str) -> &mut DiagnosticBuilder<'a> { + self.sub(Level::Warning, msg, None, None); + self + } + pub fn span_warn(&mut self, + sp: Span, + msg: &str) + -> &mut DiagnosticBuilder<'a> { + self.sub(Level::Warning, msg, Some(sp), None); + self + } pub fn help(&mut self , msg: &str) -> &mut DiagnosticBuilder<'a> { self.sub(Level::Help, msg, None, None); self @@ -190,6 +201,13 @@ impl<'a> DiagnosticBuilder<'a> { self.sub(Level::Note, msg, Some(sp), Some(EndSpan(sp))); self } + pub fn fileline_warn(&mut self , + sp: Span, + msg: &str) + -> &mut DiagnosticBuilder<'a> { + self.sub(Level::Warning, msg, Some(sp), Some(FileLine(sp))); + self + } pub fn fileline_note(&mut self , sp: Span, msg: &str) diff --git a/src/snapshots.txt b/src/snapshots.txt index 2fa540012816e..f64c9d36025a3 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -2,6 +2,7 @@ S 2015-12-18 3391630 bitrig-x86_64 6476e1562df02389b55553b4c88b1f4fd121cd40 freebsd-i386 7e624c50494402e1feb14c743d659fbd71b448f5 freebsd-x86_64 91724d4e655807a2a2e940ac50992ebeaac16ea9 + dragonfly-x86_64 e74d79488e88ac2de3bd03afd5959d2ae6e2b628 linux-i386 a09c4a4036151d0cb28e265101669731600e01f2 linux-x86_64 97e2a5eb8904962df8596e95d6e5d9b574d73bf4 macos-i386 ca52d2d3ba6497ed007705ee3401cf7efc136ca1 diff --git a/src/test/auxiliary/extern_calling_convention.rs b/src/test/auxiliary/extern_calling_convention.rs index 22cbc415eb4ce..55a4226c6632d 100644 --- a/src/test/auxiliary/extern_calling_convention.rs +++ b/src/test/auxiliary/extern_calling_convention.rs @@ -24,7 +24,7 @@ pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) { } #[inline(never)] -#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64"))] +#[cfg(not(target_arch = "x86_64"))] pub extern fn foo(a: isize, b: isize, c: isize, d: isize) { assert_eq!(a, 1); assert_eq!(b, 2); diff --git a/src/test/compile-fail/empty-struct-unit-pat.rs b/src/test/compile-fail/empty-struct-unit-pat.rs index 7e13f539bb043..cffd9fd9b4938 100644 --- a/src/test/compile-fail/empty-struct-unit-pat.rs +++ b/src/test/compile-fail/empty-struct-unit-pat.rs @@ -32,6 +32,7 @@ fn main() { //~ ERROR: compilation successful // } match e1 { Empty1(..) => () //~ WARN `Empty1` does not name a tuple variant or a tuple struct + //~^ WARN hard error } // Rejected by parser as yet // match e2 { @@ -39,5 +40,6 @@ fn main() { //~ ERROR: compilation successful // } match e2 { E::Empty2(..) => () //~ WARN `E::Empty2` does not name a tuple variant or a tuple struct + //~^ WARN hard error } } diff --git a/src/test/compile-fail/private-in-public-warn.rs b/src/test/compile-fail/private-in-public-warn.rs index 2d1de3ca2823e..9aab06ce14ee1 100644 --- a/src/test/compile-fail/private-in-public-warn.rs +++ b/src/test/compile-fail/private-in-public-warn.rs @@ -26,23 +26,34 @@ mod types { } pub type Alias = Priv; //~ WARN private type in public interface + //~^ WARNING hard error pub enum E { V1(Priv), //~ WARN private type in public interface + //~^ WARNING hard error V2 { field: Priv }, //~ WARN private type in public interface + //~^ WARNING hard error } pub trait Tr { const C: Priv = Priv; //~ WARN private type in public interface + //~^ WARNING hard error type Alias = Priv; //~ WARN private type in public interface + //~^ WARNING hard error fn f1(arg: Priv) {} //~ WARN private type in public interface + //~^ WARNING hard error fn f2() -> Priv { panic!() } //~ WARN private type in public interface + //~^ WARNING hard error } extern { pub static ES: Priv; //~ WARN private type in public interface + //~^ WARNING hard error pub fn ef1(arg: Priv); //~ WARN private type in public interface + //~^ WARNING hard error pub fn ef2() -> Priv; //~ WARN private type in public interface + //~^ WARNING hard error } impl PubTr for Pub { type Alias = Priv; //~ WARN private type in public interface + //~^ WARNING hard error } } @@ -53,14 +64,21 @@ mod traits { pub type Alias = T; //~ WARN private trait in public interface //~^ WARN trait bounds are not (yet) enforced in type definitions + //~| WARNING hard error pub trait Tr1: PrivTr {} //~ WARN private trait in public interface + //~^ WARNING hard error pub trait Tr2 {} //~ WARN private trait in public interface + //~^ WARNING hard error pub trait Tr3 { type Alias: PrivTr; //~ WARN private trait in public interface + //~^ WARNING hard error fn f(arg: T) {} //~ WARN private trait in public interface + //~^ WARNING hard error } impl Pub {} //~ WARN private trait in public interface + //~^ WARNING hard error impl PubTr for Pub {} //~ WARN private trait in public interface + //~^ WARNING hard error } mod traits_where { @@ -69,12 +87,17 @@ mod traits_where { pub trait PubTr {} pub type Alias where T: PrivTr = T; //~ WARN private trait in public interface + //~^ WARNING hard error pub trait Tr2 where T: PrivTr {} //~ WARN private trait in public interface + //~^ WARNING hard error pub trait Tr3 { fn f(arg: T) where T: PrivTr {} //~ WARN private trait in public interface + //~^ WARNING hard error } impl Pub where T: PrivTr {} //~ WARN private trait in public interface + //~^ WARNING hard error impl PubTr for Pub where T: PrivTr {} //~ WARN private trait in public interface + //~^ WARNING hard error } mod generics { @@ -84,9 +107,13 @@ mod generics { pub trait PubTr {} pub trait Tr1: PrivTr {} //~ WARN private trait in public interface + //~^ WARNING hard error pub trait Tr2: PubTr {} //~ WARN private type in public interface + //~^ WARNING hard error pub trait Tr3: PubTr<[Priv; 1]> {} //~ WARN private type in public interface + //~^ WARNING hard error pub trait Tr4: PubTr> {} //~ WARN private type in public interface + //~^ WARNING hard error } mod impls { @@ -113,6 +140,7 @@ mod impls { } impl PubTr for Pub { type Alias = Priv; //~ WARN private type in public interface + //~^ WARNING hard error } } @@ -179,9 +207,11 @@ mod aliases_pub { pub trait Tr1: PrivUseAliasTr {} // OK // This should be OK, if type aliases are substituted pub trait Tr2: PrivUseAliasTr {} //~ WARN private type in public interface + //~^ WARNING hard error impl PrivAlias { pub fn f(arg: Priv) {} //~ WARN private type in public interface + //~^ WARNING hard error } // This doesn't even parse // impl ::AssocAlias { @@ -189,12 +219,15 @@ mod aliases_pub { // } impl PrivUseAliasTr for PrivUseAlias { type Check = Priv; //~ WARN private type in public interface + //~^ WARNING hard error } impl PrivUseAliasTr for PrivAlias { type Check = Priv; //~ WARN private type in public interface + //~^ WARNING hard error } impl PrivUseAliasTr for ::AssocAlias { type Check = Priv; //~ WARN private type in public interface + //~^ WARNING hard error } } @@ -217,8 +250,11 @@ mod aliases_priv { impl PrivTr for Priv {} pub trait Tr1: PrivUseAliasTr {} //~ WARN private trait in public interface + //~^ WARNING hard error pub trait Tr2: PrivUseAliasTr {} //~ WARN private trait in public interface //~^ WARN private type in public interface + //~| WARNING hard error + //~| WARNING hard error impl PrivUseAlias { pub fn f(arg: Priv) {} // OK diff --git a/src/test/compile-fail/private-variant-reexport.rs b/src/test/compile-fail/private-variant-reexport.rs index 39698fa593a28..06f08dc13c6b4 100644 --- a/src/test/compile-fail/private-variant-reexport.rs +++ b/src/test/compile-fail/private-variant-reexport.rs @@ -13,18 +13,22 @@ mod m1 { pub use ::E::V; //~ WARN variant `V` is private, and cannot be reexported + //~^ WARNING hard error } mod m2 { pub use ::E::{V}; //~ WARN variant `V` is private, and cannot be reexported + //~^ WARNING hard error } mod m3 { pub use ::E::V::{self}; //~ WARN variant `V` is private, and cannot be reexported + //~^ WARNING hard error } mod m4 { pub use ::E::*; //~ WARN variant `V` is private, and cannot be reexported + //~^ WARNING hard error } enum E { V } diff --git a/src/test/compile-fail/type-parameter-invalid-lint.rs b/src/test/compile-fail/type-parameter-invalid-lint.rs index a3ecbfa84f0a8..9291329fac37f 100644 --- a/src/test/compile-fail/type-parameter-invalid-lint.rs +++ b/src/test/compile-fail/type-parameter-invalid-lint.rs @@ -13,5 +13,5 @@ fn avg(_: T) {} //~^ ERROR defaults for type parameters are only allowed -//~| NOTE HARD ERROR +//~| WARNING hard error fn main() {} diff --git a/src/test/run-pass/bitwise.rs b/src/test/run-pass/bitwise.rs index ac24ed8d91604..bb4b9cfecf7b6 100644 --- a/src/test/run-pass/bitwise.rs +++ b/src/test/run-pass/bitwise.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[cfg(any(target_arch = "x86", target_arch = "arm"))] +#[cfg(any(target_pointer_width = "32"))] fn target() { assert_eq!(-1000isize as usize >> 3_usize, 536870787_usize); } -#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] +#[cfg(any(target_pointer_width = "64"))] fn target() { assert_eq!(-1000isize as usize >> 3_usize, 2305843009213693827_usize); } diff --git a/src/test/run-pass/conditional-compile-arch.rs b/src/test/run-pass/conditional-compile-arch.rs index e51270fdc8d21..4e4c98e50bca1 100644 --- a/src/test/run-pass/conditional-compile-arch.rs +++ b/src/test/run-pass/conditional-compile-arch.rs @@ -21,3 +21,9 @@ pub fn main() { } #[cfg(target_arch = "aarch64")] pub fn main() { } + +#[cfg(target_arch = "powerpc64")] +pub fn main() { } + +#[cfg(target_arch = "powerpc64le")] +pub fn main() { } diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index ef69946d7aa2a..a4720d48213ce 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -35,7 +35,7 @@ mod m { } #[main] - #[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))] + #[cfg(not(target_arch = "x86"))] pub fn main() { unsafe { assert_eq!(::rusti::pref_align_of::(), 8); diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs index 93d9300edf634..5587f68bd1854 100644 --- a/src/test/run-pass/issue-2895.rs +++ b/src/test/run-pass/issue-2895.rs @@ -23,13 +23,13 @@ impl Drop for Kitty { fn drop(&mut self) {} } -#[cfg(any(target_arch = "x86_64", target_arch="aarch64"))] +#[cfg(target_pointer_width = "64")] pub fn main() { assert_eq!(mem::size_of::(), 8 as usize); assert_eq!(mem::size_of::(), 16 as usize); } -#[cfg(any(target_arch = "x86", target_arch = "arm"))] +#[cfg(target_pointer_width = "32")] pub fn main() { assert_eq!(mem::size_of::(), 4 as usize); assert_eq!(mem::size_of::(), 8 as usize); diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index e5d76c3e67abd..4a115c737da3a 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -35,14 +35,6 @@ struct Outer { t: Inner } - -#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64"))] -mod m { - pub fn align() -> usize { 4 } - pub fn size() -> usize { 8 } -} - -#[cfg(target_arch = "x86_64")] mod m { pub fn align() -> usize { 4 } pub fn size() -> usize { 8 } diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index fc032aa3ff0cd..25cd77845ea03 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -49,7 +49,7 @@ mod m { pub fn size() -> usize { 12 } } - #[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))] + #[cfg(not(target_arch = "x86"))] pub mod m { pub fn align() -> usize { 8 } pub fn size() -> usize { 16 } diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index 109287a83b16a..6f23263790cb7 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -43,7 +43,7 @@ fn test1() { } } -#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] +#[cfg(target_pointer_width = "64")] fn test2() { unsafe { let f = Floats { a: 1.234567890e-15_f64, @@ -59,7 +59,7 @@ fn test2() { } } -#[cfg(any(target_arch = "x86", target_arch = "arm"))] +#[cfg(target_pointer_width = "32")] fn test2() { }