From fa75111043975e0da885a72b72b6697dda38642d Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Tue, 28 Aug 2018 20:43:10 +0200 Subject: [PATCH 01/17] Also link Clippy repo in the CONTRIBUTING.md file --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea9f2c194300..21b14d011f91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -405,7 +405,8 @@ before the PR is merged. [breaking-tools-built-with-the-compiler]: #breaking-tools-built-with-the-compiler Rust's build system builds a number of tools that make use of the -internals of the compiler. This includes clippy, +internals of the compiler. This includes +[Clippy](https://github.com/rust-lang-nursery/rust-clippy), [RLS](https://github.com/rust-lang-nursery/rls) and [rustfmt](https://github.com/rust-lang-nursery/rustfmt). If these tools break because of your changes, you may run into a sort of "chicken and egg" From 0902fc88db6d51f3f22735d26a2b2e8caedd25bc Mon Sep 17 00:00:00 2001 From: Philip Daniels Date: Tue, 28 Aug 2018 22:05:00 +0100 Subject: [PATCH 02/17] Add rust-gdbgui script. This script invokes the gdbgui graphical GDB front-end with the Rust pretty printers loaded. The script does not install gdbgui, that must be done manually. --- src/etc/rust-gdbgui | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 src/etc/rust-gdbgui diff --git a/src/etc/rust-gdbgui b/src/etc/rust-gdbgui new file mode 100755 index 000000000000..6786fe015bca --- /dev/null +++ b/src/etc/rust-gdbgui @@ -0,0 +1,65 @@ +#!/bin/sh +# Copyright 2014 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# Exit if anything fails +set -e + +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then + echo " +rust-gdbgui +=========== +gdbgui - https://gdbgui.com - is a graphical front-end to GDB +that runs in a browser. This script invokes gdbgui with the Rust +pretty printers loaded. + +Simple usage : rust-gdbgui target\debug\myprog +With arguments: rust-gdbgui 'target\debug\myprog arg1 arg2...' + (note the quotes) + + +Hints +===== +gdbgui won't be able to find the rust 'main' method automatically, so +in its options make sure to disable the 'Add breakpoint to main after +loading executable' setting to avoid a 'File not found: main' warning +on startup. + +Instead, type 'main' into the file browser and you should get +auto-completion on the filename. Just pick 'main.rs', add a breakpoint +by clicking in the line number gutter, and type 'r' or hit the Restart +icon to start your program running. +" + exit 0 +fi + +# Find out where the pretty printer Python module is +RUSTC_SYSROOT=`rustc --print=sysroot` +GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc" + +# Set the environment variable `RUST_GDB` to overwrite the call to a +# different/specific command (defaults to `gdb`). +RUST_GDB="${RUST_GDB:-gdb}" + +# Set the environment variable `RUST_GDBGUI` to overwrite the call to a +# different/specific command (defaults to `gdbgui`). +RUST_GDBGUI="${RUST_GDBGUI:-gdbgui}" + +# These arguments get passed through to GDB and make it load the +# Rust pretty printers. +GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" -iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\"" + +# Finally we execute gdbgui. +PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \ + exec ${RUST_GDBGUI} \ + --gdb ${RUST_GDB} \ + --gdb-args "${GDB_ARGS}" \ + "${@}" + From 50057ee3a364d51f5dee611ebd1fd3a05ac77ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 29 Aug 2018 12:18:05 +0200 Subject: [PATCH 03/17] bench: libcore: fix build failure of any.rs benchmark (use "dyn Any") --- src/libcore/benches/any.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/benches/any.rs b/src/libcore/benches/any.rs index 67e02cf9509b..f4f01eb1cf5d 100644 --- a/src/libcore/benches/any.rs +++ b/src/libcore/benches/any.rs @@ -15,7 +15,7 @@ use test::{Bencher, black_box}; fn bench_downcast_ref(b: &mut Bencher) { b.iter(|| { let mut x = 0; - let mut y = &mut x as &mut Any; + let mut y = &mut x as &mut dyn Any; black_box(&mut y); black_box(y.downcast_ref::() == Some(&0)); }); From 5399616f1d98b4bcc1da87af15f75c95e3c2288b Mon Sep 17 00:00:00 2001 From: Otto Rask Date: Wed, 29 Aug 2018 13:20:56 +0300 Subject: [PATCH 04/17] Make Arc cloning mechanics clearer in module docs Add some more wording to module documentation regarding how `Arc::clone()` works, as some users have assumed cloning Arc's to work via dereferencing to inner value as follows: use std::sync::Arc; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(1 == myarcref); Instead of the actual mechanic of referencing the existing Arc value: use std::sync::Arg; let myarc = Arc::new(1); let myarcref = myarc.clone(); assert!(myarcref == &myarc); // not sure if assert could assert this in the real world --- src/liballoc/sync.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2cd7898f4c78..176743fdd1d3 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -49,9 +49,9 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// /// The type `Arc` provides shared ownership of a value of type `T`, /// allocated in the heap. Invoking [`clone`][clone] on `Arc` produces -/// a new pointer to the same value in the heap. When the last `Arc` -/// pointer to a given value is destroyed, the pointed-to value is -/// also destroyed. +/// a new pointer to the same `Arc` reference value in the heap. When the last +/// `Arc` pointer to a given value is destroyed, the pointed-to value is also +/// destroyed. /// /// Shared references in Rust disallow mutation by default, and `Arc` is no /// exception: you cannot generally obtain a mutable reference to something @@ -107,7 +107,8 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// // The two syntaxes below are equivalent. /// let a = foo.clone(); /// let b = Arc::clone(&foo); -/// // a and b both point to the same memory location as foo. +/// // a and b both point to the same memory location where foo resides +/// // (not where the value wrapped by foo resides). /// ``` /// /// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly From 3b98571b325c3fc8c42aa2209333bfec9d838718 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 29 Aug 2018 23:01:57 +0200 Subject: [PATCH 05/17] Prevent duplicated impl on foreign types --- src/librustdoc/html/render.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 8fb3b570f8a4..741efd8becd4 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2943,12 +2943,16 @@ fn item_trait( ")?; + let mut foreign_cache = FxHashSet(); for implementor in foreign { - let assoc_link = AssocItemLink::GotoSource( - implementor.impl_item.def_id, &implementor.inner_impl().provided_trait_methods - ); - render_impl(w, cx, &implementor, assoc_link, - RenderMode::Normal, implementor.impl_item.stable_since(), false)?; + if foreign_cache.insert(implementor.inner_impl().to_string()) { + let assoc_link = AssocItemLink::GotoSource( + implementor.impl_item.def_id, + &implementor.inner_impl().provided_trait_methods + ); + render_impl(w, cx, &implementor, assoc_link, + RenderMode::Normal, implementor.impl_item.stable_since(), false)?; + } } } From 60202199936365e7b2adc70189fbaa664ce729a6 Mon Sep 17 00:00:00 2001 From: Otto Rask Date: Thu, 30 Aug 2018 12:20:41 +0300 Subject: [PATCH 06/17] Rephrase Arc documentation changes regarding clones Make it clearer that `Arc::clone()` in fact creates a whole new Arc with the internal pointer pointing to the same location as the source Arc. --- src/liballoc/sync.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 176743fdd1d3..72a4740b1566 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -49,8 +49,9 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// /// The type `Arc` provides shared ownership of a value of type `T`, /// allocated in the heap. Invoking [`clone`][clone] on `Arc` produces -/// a new pointer to the same `Arc` reference value in the heap. When the last -/// `Arc` pointer to a given value is destroyed, the pointed-to value is also +/// a new `Arc` instance, which points to the same value on the heap as the +/// source `Arc`, while increasing a reference count. When the last `Arc` +/// pointer to a given value is destroyed, the pointed-to value is also /// destroyed. /// /// Shared references in Rust disallow mutation by default, and `Arc` is no @@ -107,8 +108,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// // The two syntaxes below are equivalent. /// let a = foo.clone(); /// let b = Arc::clone(&foo); -/// // a and b both point to the same memory location where foo resides -/// // (not where the value wrapped by foo resides). +/// // a and b both point to the same memory location as foo /// ``` /// /// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly From 251f26298a5484b1cf6cd505c555d71d34a75010 Mon Sep 17 00:00:00 2001 From: Basile Desloges Date: Wed, 29 Aug 2018 17:45:55 +0200 Subject: [PATCH 07/17] Add regression test for issue #52060 --- src/test/ui/issues/issue-52060.rs | 8 ++++++++ src/test/ui/issues/issue-52060.stderr | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/issues/issue-52060.rs create mode 100644 src/test/ui/issues/issue-52060.stderr diff --git a/src/test/ui/issues/issue-52060.rs b/src/test/ui/issues/issue-52060.rs new file mode 100644 index 000000000000..54eff228934e --- /dev/null +++ b/src/test/ui/issues/issue-52060.rs @@ -0,0 +1,8 @@ +// Regression test for https://github.com/rust-lang/rust/issues/52060 +// The compiler shouldn't ICE in this case +static A: &'static [u32] = &[1]; +static B: [u32; 1] = [0; A.len()]; +//~^ ERROR [E0013] +//~| ERROR `core::slice::::len` is not yet stable as a const fn + +fn main() {} diff --git a/src/test/ui/issues/issue-52060.stderr b/src/test/ui/issues/issue-52060.stderr new file mode 100644 index 000000000000..988bfd480e6a --- /dev/null +++ b/src/test/ui/issues/issue-52060.stderr @@ -0,0 +1,17 @@ +error[E0013]: constants cannot refer to statics, use a constant instead + --> $DIR/issue-52060.rs:4:26 + | +LL | static B: [u32; 1] = [0; A.len()]; + | ^ + +error: `core::slice::::len` is not yet stable as a const fn + --> $DIR/issue-52060.rs:4:26 + | +LL | static B: [u32; 1] = [0; A.len()]; + | ^^^^^^^ + | + = help: in Nightly builds, add `#![feature(const_slice_len)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0013`. From 47aa4758664ee7b054261f09de3375cfb3cc926d Mon Sep 17 00:00:00 2001 From: Philip Daniels Date: Thu, 30 Aug 2018 20:23:41 +0100 Subject: [PATCH 08/17] Fix direction of slashes in the help text example. --- src/etc/rust-gdbgui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/etc/rust-gdbgui b/src/etc/rust-gdbgui index 6786fe015bca..7e179ba927df 100755 --- a/src/etc/rust-gdbgui +++ b/src/etc/rust-gdbgui @@ -20,8 +20,8 @@ gdbgui - https://gdbgui.com - is a graphical front-end to GDB that runs in a browser. This script invokes gdbgui with the Rust pretty printers loaded. -Simple usage : rust-gdbgui target\debug\myprog -With arguments: rust-gdbgui 'target\debug\myprog arg1 arg2...' +Simple usage : rust-gdbgui target/debug/myprog +With arguments: rust-gdbgui 'target/debug/myprog arg1 arg2...' (note the quotes) @@ -32,7 +32,7 @@ in its options make sure to disable the 'Add breakpoint to main after loading executable' setting to avoid a 'File not found: main' warning on startup. -Instead, type 'main' into the file browser and you should get +Instead, type 'main' into gdbgui's file browser and you should get auto-completion on the filename. Just pick 'main.rs', add a breakpoint by clicking in the line number gutter, and type 'r' or hit the Restart icon to start your program running. From bf7e324e4e610b1f12971e601073ccfd6f197fff Mon Sep 17 00:00:00 2001 From: Otto Rask Date: Fri, 31 Aug 2018 11:21:01 +0300 Subject: [PATCH 09/17] Add clearer wording to Arc clone example code --- src/liballoc/sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 72a4740b1566..db7a4044b267 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -108,7 +108,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// // The two syntaxes below are equivalent. /// let a = foo.clone(); /// let b = Arc::clone(&foo); -/// // a and b both point to the same memory location as foo +/// // a, b, and foo are all Arcs that point to the same memory location /// ``` /// /// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly From 66d7216469faa5f22d0fe1deb9573e84d22142c5 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Fri, 31 Aug 2018 18:30:38 +0800 Subject: [PATCH 10/17] trip const_to_alloc query --- src/librustc/dep_graph/dep_node.rs | 3 +-- src/librustc/ty/query/config.rs | 6 ------ src/librustc/ty/query/mod.rs | 13 +------------ src/librustc/ty/query/plumbing.rs | 1 - src/librustc_mir/lib.rs | 1 - 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 90081d5b85ef..dfe0a395ca14 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -75,7 +75,7 @@ use traits::query::{ CanonicalPredicateGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal, }; use ty::{TyCtxt, FnSig, Instance, InstanceDef, - ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty, self}; + ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty}; use ty::subst::Substs; // erase!() just makes tokens go away. It's used to specify which macro argument @@ -632,7 +632,6 @@ define_dep_nodes!( <'tcx> // queries). Making them anonymous avoids hashing the result, which // may save a bit of time. [anon] EraseRegionsTy { ty: Ty<'tcx> }, - [anon] ConstToAllocation { val: &'tcx ty::Const<'tcx> }, [input] Freevars(DefId), [input] MaybeUnusedTraitImport(DefId), diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index b5093d0a1fc9..d32580181f8d 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -198,12 +198,6 @@ impl<'tcx> QueryDescription<'tcx> for queries::super_predicates_of<'tcx> { } } -impl<'tcx> QueryDescription<'tcx> for queries::const_to_allocation<'tcx> { - fn describe(_tcx: TyCtxt, val: &'tcx ty::Const<'tcx>) -> String { - format!("converting constant `{:?}` to an allocation", val) - } -} - impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> { fn describe(_tcx: TyCtxt, ty: Ty<'tcx>) -> String { format!("erasing regions from `{:?}`", ty) diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 6f61583e49b8..88f599971c7d 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -30,7 +30,7 @@ use middle::exported_symbols::{SymbolExportLevel, ExportedSymbol}; use mir::interpret::ConstEvalResult; use mir::mono::{CodegenUnit, Stats}; use mir; -use mir::interpret::{GlobalId, Allocation}; +use mir::interpret::GlobalId; use session::{CompileResult, CrateDisambiguator}; use session::config::OutputFilenames; use traits::{self, Vtable}; @@ -286,11 +286,6 @@ define_queries! { <'tcx> /// other items (such as enum variant explicit discriminants). [] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) -> ConstEvalResult<'tcx>, - - /// Converts a constant value to a constant allocation - [] fn const_to_allocation: const_to_allocation( - &'tcx ty::Const<'tcx> - ) -> &'tcx Allocation, }, TypeChecking { @@ -706,12 +701,6 @@ fn erase_regions_ty<'tcx>(ty: Ty<'tcx>) -> DepConstructor<'tcx> { DepConstructor::EraseRegionsTy { ty } } -fn const_to_allocation<'tcx>( - val: &'tcx ty::Const<'tcx>, -) -> DepConstructor<'tcx> { - DepConstructor::ConstToAllocation { val } -} - fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> { DepConstructor::TypeParamPredicates { item_id, diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 0edb1aa79e74..215fba54499b 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -1062,7 +1062,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::FulfillObligation | DepKind::VtableMethods | DepKind::EraseRegionsTy | - DepKind::ConstToAllocation | DepKind::NormalizeProjectionTy | DepKind::NormalizeTyAfterErasingRegions | DepKind::ImpliedOutlivesBounds | diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index f91ff3642cd1..d5148b09c4ff 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -93,7 +93,6 @@ pub fn provide(providers: &mut Providers) { shim::provide(providers); transform::provide(providers); providers.const_eval = interpret::const_eval_provider; - providers.const_to_allocation = interpret::const_to_allocation_provider; providers.check_match = hair::pattern::check_match; } From 72ba683457f3bb2b62754dec78ddd0c633982c65 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Fri, 31 Aug 2018 18:31:15 +0800 Subject: [PATCH 11/17] extract allocation info from byref --- src/librustc_mir/interpret/memory.rs | 11 +++++++---- src/librustc_typeck/check/mod.rs | 8 ++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 91fc6453446a..79e635a03b2e 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -22,7 +22,7 @@ use std::ptr; use rustc::ty::{self, Instance, query::TyCtxtAt}; use rustc::ty::layout::{self, Align, TargetDataLayout, Size, HasDataLayout}; -use rustc::mir::interpret::{Pointer, AllocId, Allocation, ScalarMaybeUndef, GlobalId, +use rustc::mir::interpret::{Pointer, AllocId, Allocation, ConstValue, ScalarMaybeUndef, GlobalId, EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic, truncate}; pub use rustc::mir::interpret::{write_target_uint, read_target_uint}; @@ -340,9 +340,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { // no need to report anything, the const_eval call takes care of that for statics assert!(tcx.is_static(def_id).is_some()); EvalErrorKind::ReferencedConstant(err).into() - }).map(|val| { - // FIXME We got our static (will be a ByRef), now we make a *copy*?!? - tcx.const_to_allocation(val) + }).map(|const_val| { + if let ConstValue::ByRef(_, allocation, _) = const_val.val { + allocation + } else { + panic!("Trying to get allocation info from non-byref const value") + } }) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index bbb45c04e4e9..2129cdf6f466 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -94,7 +94,7 @@ use rustc::infer::{self, InferCtxt, InferOk, RegionVariableOrigin}; use rustc::infer::anon_types::AnonTypeDecl; use rustc::infer::type_variable::{TypeVariableOrigin}; use rustc::middle::region; -use rustc::mir::interpret::{GlobalId}; +use rustc::mir::interpret::{ConstValue, GlobalId}; use rustc::ty::subst::{CanonicalSubsts, UnpackedKind, Subst, Substs}; use rustc::traits::{self, ObligationCause, ObligationCauseCode, TraitEngine}; use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind, Visibility, ToPredicate, RegionKind}; @@ -1375,7 +1375,11 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) { }; let param_env = ty::ParamEnv::reveal_all(); if let Ok(static_) = tcx.const_eval(param_env.and(cid)) { - let alloc = tcx.const_to_allocation(static_); + let alloc = if let ConstValue::ByRef(_, allocation, _) = static_.val { + allocation + } else { + panic!("Trying to get allocation info from non-byref const value") + }; if alloc.relocations.len() != 0 { let msg = "statics with a custom `#[link_section]` must be a \ simple list of bytes on the wasm target with no \ From c56adf64136aba153cac4600986787e8646c0811 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 23 Aug 2018 02:19:38 +0300 Subject: [PATCH 12/17] cleanup: Add main functions to some UI tests --- src/test/ui/enum/enum-discrim-autosizing.rs | 1 + src/test/ui/enum/enum-discrim-autosizing.stderr | 9 ++------- src/test/ui/gated-bad-feature.rs | 2 ++ src/test/ui/gated-bad-feature.stderr | 8 ++------ src/test/ui/hygiene/generate-mod.rs | 2 ++ src/test/ui/hygiene/generate-mod.stderr | 9 ++------- src/test/ui/hygiene/no_implicit_prelude.rs | 2 ++ src/test/ui/hygiene/no_implicit_prelude.stderr | 8 ++------ src/test/ui/imports/import-glob-circular.rs | 2 ++ src/test/ui/imports/import-glob-circular.stderr | 9 ++------- src/test/ui/imports/import-loop-2.rs | 2 ++ src/test/ui/imports/import-loop-2.stderr | 14 ++------------ src/test/ui/invalid_crate_type_syntax.rs | 2 ++ src/test/ui/invalid_crate_type_syntax.stderr | 7 +------ src/test/ui/issues/issue-38715.rs | 2 ++ src/test/ui/issues/issue-38715.stderr | 7 +------ src/test/ui/issues/issue-42755.rs | 2 ++ src/test/ui/issues/issue-42755.stderr | 7 +------ src/test/ui/issues/issue-43784-associated-type.rs | 2 ++ .../ui/issues/issue-43784-associated-type.stderr | 9 ++------- src/test/ui/issues/issue-43784-supertrait.rs | 2 ++ src/test/ui/issues/issue-43784-supertrait.stderr | 9 ++------- src/test/ui/macros/macro-use-bad-args-1.rs | 2 ++ src/test/ui/macros/macro-use-bad-args-1.stderr | 9 ++------- src/test/ui/macros/macro-use-bad-args-2.rs | 2 ++ src/test/ui/macros/macro-use-bad-args-2.stderr | 9 ++------- src/test/ui/nested-ty-params.rs | 2 ++ src/test/ui/nested-ty-params.stderr | 9 ++------- src/test/ui/repr/repr-transparent-other-items.rs | 2 ++ .../ui/repr/repr-transparent-other-items.stderr | 8 ++------ src/test/ui/repr/repr-transparent-other-reprs.rs | 2 ++ .../ui/repr/repr-transparent-other-reprs.stderr | 9 ++------- src/test/ui/repr/repr-transparent.rs | 2 ++ src/test/ui/repr/repr-transparent.stderr | 10 +++------- src/test/ui/resolve/resolve-unknown-trait.rs | 2 ++ src/test/ui/resolve/resolve-unknown-trait.stderr | 9 ++------- src/test/ui/resolve_self_super_hint.rs | 2 ++ src/test/ui/resolve_self_super_hint.stderr | 9 ++------- .../ui/specialization/defaultimpl/validation.rs | 2 ++ .../specialization/defaultimpl/validation.stderr | 9 ++------- src/test/ui/tuple/tuple-struct-fields/test.rs | 2 ++ src/test/ui/tuple/tuple-struct-fields/test.stderr | 9 ++------- src/test/ui/unresolved/unresolved-import.rs | 2 ++ src/test/ui/unresolved/unresolved-import.stderr | 9 ++------- src/test/ui/user-defined-macro-rules.rs | 2 ++ src/test/ui/user-defined-macro-rules.stderr | 7 +------ src/test/ui/wasm-custom-section-relocations.rs | 2 ++ src/test/ui/wasm-custom-section-relocations.stderr | 7 +------ 48 files changed, 91 insertions(+), 165 deletions(-) diff --git a/src/test/ui/enum/enum-discrim-autosizing.rs b/src/test/ui/enum/enum-discrim-autosizing.rs index 3a243330ad9b..dab22de1b6e5 100644 --- a/src/test/ui/enum/enum-discrim-autosizing.rs +++ b/src/test/ui/enum/enum-discrim-autosizing.rs @@ -18,3 +18,4 @@ enum Eu64 { Bu64 = 0x8000_0000_0000_0000 //~ERROR already exists } +fn main() {} diff --git a/src/test/ui/enum/enum-discrim-autosizing.stderr b/src/test/ui/enum/enum-discrim-autosizing.stderr index 3b4ac436898e..e4419d628512 100644 --- a/src/test/ui/enum/enum-discrim-autosizing.stderr +++ b/src/test/ui/enum/enum-discrim-autosizing.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `enum_discrim_autosizing` - | - = note: consider adding a `main` function to `$DIR/enum-discrim-autosizing.rs` - error[E0081]: discriminant value `0` already exists --> $DIR/enum-discrim-autosizing.rs:18:12 | @@ -10,7 +6,6 @@ LL | Au64 = 0, LL | Bu64 = 0x8000_0000_0000_0000 //~ERROR already exists | ^^^^^^^^^^^^^^^^^^^^^ enum already has `0` -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0081, E0601. -For more information about an error, try `rustc --explain E0081`. +For more information about this error, try `rustc --explain E0081`. diff --git a/src/test/ui/gated-bad-feature.rs b/src/test/ui/gated-bad-feature.rs index 5baafd415315..0d74f9011c3e 100644 --- a/src/test/ui/gated-bad-feature.rs +++ b/src/test/ui/gated-bad-feature.rs @@ -20,3 +20,5 @@ #![feature = "foo"] //~ ERROR: malformed feature #![feature(test_removed_feature)] //~ ERROR: feature has been removed + +fn main() {} diff --git a/src/test/ui/gated-bad-feature.stderr b/src/test/ui/gated-bad-feature.stderr index 2bed241d68ca..68be49a7277d 100644 --- a/src/test/ui/gated-bad-feature.stderr +++ b/src/test/ui/gated-bad-feature.stderr @@ -28,11 +28,7 @@ error[E0557]: feature has been removed LL | #![feature(test_removed_feature)] //~ ERROR: feature has been removed | ^^^^^^^^^^^^^^^^^^^^ -error[E0601]: `main` function not found in crate `gated_bad_feature` - | - = note: consider adding a `main` function to `$DIR/gated-bad-feature.rs` +error: aborting due to 5 previous errors -error: aborting due to 6 previous errors - -Some errors occurred: E0555, E0556, E0557, E0601. +Some errors occurred: E0555, E0556, E0557. For more information about an error, try `rustc --explain E0555`. diff --git a/src/test/ui/hygiene/generate-mod.rs b/src/test/ui/hygiene/generate-mod.rs index 2b2108558a0f..efb3696cf851 100644 --- a/src/test/ui/hygiene/generate-mod.rs +++ b/src/test/ui/hygiene/generate-mod.rs @@ -55,3 +55,5 @@ fn check_legacy() { struct FromOutside; genmod_legacy!(); } + +fn main() {} diff --git a/src/test/ui/hygiene/generate-mod.stderr b/src/test/ui/hygiene/generate-mod.stderr index 0c5905c5acb4..f86444bae77e 100644 --- a/src/test/ui/hygiene/generate-mod.stderr +++ b/src/test/ui/hygiene/generate-mod.stderr @@ -46,11 +46,6 @@ LL | type Inner = Outer; //~ ERROR cannot find type `Outer` in this scop LL | genmod_legacy!(); | ----------------- in this macro invocation -error[E0601]: `main` function not found in crate `generate_mod` - | - = note: consider adding a `main` function to `$DIR/generate-mod.rs` +error: aborting due to 6 previous errors -error: aborting due to 7 previous errors - -Some errors occurred: E0412, E0601. -For more information about an error, try `rustc --explain E0412`. +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/hygiene/no_implicit_prelude.rs b/src/test/ui/hygiene/no_implicit_prelude.rs index c90c7b3093c9..bf07bc05491c 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.rs +++ b/src/test/ui/hygiene/no_implicit_prelude.rs @@ -23,3 +23,5 @@ mod bar { } fn f() { ::foo::m!(); } } + +fn main() {} diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index b3d82e9094ba..463fdbf00ce5 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -7,10 +7,6 @@ LL | fn f() { ::bar::m!(); } LL | Vec::new(); //~ ERROR failed to resolve | ^^^ Use of undeclared type or module `Vec` -error[E0601]: `main` function not found in crate `no_implicit_prelude` - | - = note: consider adding a `main` function to `$DIR/no_implicit_prelude.rs` - error[E0599]: no method named `clone` found for type `()` in the current scope --> $DIR/no_implicit_prelude.rs:22:12 | @@ -24,7 +20,7 @@ LL | ().clone() //~ ERROR no method named `clone` found = note: the following trait is implemented but not in scope, perhaps add a `use` for it: `use std::clone::Clone;` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors occurred: E0433, E0599, E0601. +Some errors occurred: E0433, E0599. For more information about an error, try `rustc --explain E0433`. diff --git a/src/test/ui/imports/import-glob-circular.rs b/src/test/ui/imports/import-glob-circular.rs index d9cc17791ed5..b2e92fe0e1bf 100644 --- a/src/test/ui/imports/import-glob-circular.rs +++ b/src/test/ui/imports/import-glob-circular.rs @@ -25,3 +25,5 @@ mod test { fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope } + +fn main() {} diff --git a/src/test/ui/imports/import-glob-circular.stderr b/src/test/ui/imports/import-glob-circular.stderr index 078a6a3937a4..fdff04cc2414 100644 --- a/src/test/ui/imports/import-glob-circular.stderr +++ b/src/test/ui/imports/import-glob-circular.stderr @@ -4,11 +4,6 @@ error[E0425]: cannot find function `f1066` in this scope LL | fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope | ^^^^^ not found in this scope -error[E0601]: `main` function not found in crate `import_glob_circular` - | - = note: consider adding a `main` function to `$DIR/import-glob-circular.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors occurred: E0425, E0601. -For more information about an error, try `rustc --explain E0425`. +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/imports/import-loop-2.rs b/src/test/ui/imports/import-loop-2.rs index b7bbe11a4dc9..0bc968872db5 100644 --- a/src/test/ui/imports/import-loop-2.rs +++ b/src/test/ui/imports/import-loop-2.rs @@ -19,3 +19,5 @@ mod b { fn main() { let y = x; } } + +fn main() {} diff --git a/src/test/ui/imports/import-loop-2.stderr b/src/test/ui/imports/import-loop-2.stderr index 717f74643ebb..09c2e7918f37 100644 --- a/src/test/ui/imports/import-loop-2.stderr +++ b/src/test/ui/imports/import-loop-2.stderr @@ -4,16 +4,6 @@ error[E0432]: unresolved import `a::x` LL | pub use a::x; | ^^^^ no `x` in `a` -error[E0601]: `main` function not found in crate `import_loop_2` - | - = note: the main function must be defined at the crate level but you have one or more functions named 'main' that are not defined at the crate level. Either move the definition or attach the `#[main]` attribute to override this behavior. -note: here is a function named 'main' - --> $DIR/import-loop-2.rs:20:5 - | -LL | fn main() { let y = x; } - | ^^^^^^^^^^^^^^^^^^^^^^^^ +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors occurred: E0432, E0601. -For more information about an error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/invalid_crate_type_syntax.rs b/src/test/ui/invalid_crate_type_syntax.rs index 6d42515704ea..904a9acf9e53 100644 --- a/src/test/ui/invalid_crate_type_syntax.rs +++ b/src/test/ui/invalid_crate_type_syntax.rs @@ -12,3 +12,5 @@ #![crate_type(lib)] //~ ERROR `crate_type` requires a value fn my_lib_fn() {} + +fn main() {} diff --git a/src/test/ui/invalid_crate_type_syntax.stderr b/src/test/ui/invalid_crate_type_syntax.stderr index b609695b86ee..6f02f96faca9 100644 --- a/src/test/ui/invalid_crate_type_syntax.stderr +++ b/src/test/ui/invalid_crate_type_syntax.stderr @@ -6,10 +6,5 @@ LL | #![crate_type(lib)] //~ ERROR `crate_type` requires a value | = note: for example: `#![crate_type="lib"]` -error[E0601]: `main` function not found in crate `invalid_crate_type_syntax` - | - = note: consider adding a `main` function to `$DIR/invalid_crate_type_syntax.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/issues/issue-38715.rs b/src/test/ui/issues/issue-38715.rs index 552653c21bad..5c745d1fab3b 100644 --- a/src/test/ui/issues/issue-38715.rs +++ b/src/test/ui/issues/issue-38715.rs @@ -14,3 +14,5 @@ macro_rules! foo { ($i:ident) => {} } #[macro_export] macro_rules! foo { () => {} } //~ ERROR a macro named `foo` has already been exported //~| WARN this was previously accepted + +fn main() {} diff --git a/src/test/ui/issues/issue-38715.stderr b/src/test/ui/issues/issue-38715.stderr index a0dbcbd18c67..67b27cc83cc8 100644 --- a/src/test/ui/issues/issue-38715.stderr +++ b/src/test/ui/issues/issue-38715.stderr @@ -13,10 +13,5 @@ note: previous macro export is now shadowed LL | macro_rules! foo { ($i:ident) => {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0601]: `main` function not found in crate `issue_38715` - | - = note: consider adding a `main` function to `$DIR/issue-38715.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/issues/issue-42755.rs b/src/test/ui/issues/issue-42755.rs index dd53a1c71a5b..46c8cb740ded 100644 --- a/src/test/ui/issues/issue-42755.rs +++ b/src/test/ui/issues/issue-42755.rs @@ -15,3 +15,5 @@ macro_rules! foo { } foo!(a); + +fn main() {} diff --git a/src/test/ui/issues/issue-42755.stderr b/src/test/ui/issues/issue-42755.stderr index 914390619961..fa736edc47f5 100644 --- a/src/test/ui/issues/issue-42755.stderr +++ b/src/test/ui/issues/issue-42755.stderr @@ -4,10 +4,5 @@ error: repetition matches empty token tree LL | ($($p:vis)*) => {} //~ ERROR repetition matches empty token tree | ^^^^^^^^ -error[E0601]: `main` function not found in crate `issue_42755` - | - = note: consider adding a `main` function to `$DIR/issue-42755.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/issues/issue-43784-associated-type.rs b/src/test/ui/issues/issue-43784-associated-type.rs index 94b5c0034a76..1ff1238ec54b 100644 --- a/src/test/ui/issues/issue-43784-associated-type.rs +++ b/src/test/ui/issues/issue-43784-associated-type.rs @@ -23,3 +23,5 @@ impl Partial for T::Assoc where impl Complete for T { //~ ERROR the trait bound `T: std::marker::Copy` is not satisfied type Assoc = T; } + +fn main() {} diff --git a/src/test/ui/issues/issue-43784-associated-type.stderr b/src/test/ui/issues/issue-43784-associated-type.stderr index 798d8c660166..18e97e24b733 100644 --- a/src/test/ui/issues/issue-43784-associated-type.stderr +++ b/src/test/ui/issues/issue-43784-associated-type.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `issue_43784_associated_type` - | - = note: consider adding a `main` function to `$DIR/issue-43784-associated-type.rs` - error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/issue-43784-associated-type.rs:23:9 | @@ -10,7 +6,6 @@ LL | impl Complete for T { //~ ERROR the trait bound `T: std::marker::Copy` i | = help: consider adding a `where T: std::marker::Copy` bound -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0277, E0601. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-43784-supertrait.rs b/src/test/ui/issues/issue-43784-supertrait.rs index e70df113da33..30132c3be88a 100644 --- a/src/test/ui/issues/issue-43784-supertrait.rs +++ b/src/test/ui/issues/issue-43784-supertrait.rs @@ -16,3 +16,5 @@ pub trait Complete: Partial { impl Partial for T where T: Complete {} impl Complete for T {} //~ ERROR the trait bound `T: std::marker::Copy` is not satisfied + +fn main() {} diff --git a/src/test/ui/issues/issue-43784-supertrait.stderr b/src/test/ui/issues/issue-43784-supertrait.stderr index 8646b315abda..422075f62aa0 100644 --- a/src/test/ui/issues/issue-43784-supertrait.stderr +++ b/src/test/ui/issues/issue-43784-supertrait.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `issue_43784_supertrait` - | - = note: consider adding a `main` function to `$DIR/issue-43784-supertrait.rs` - error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/issue-43784-supertrait.rs:18:9 | @@ -10,7 +6,6 @@ LL | impl Complete for T {} //~ ERROR the trait bound `T: std::marker::Copy` | = help: consider adding a `where T: std::marker::Copy` bound -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0277, E0601. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/macros/macro-use-bad-args-1.rs b/src/test/ui/macros/macro-use-bad-args-1.rs index a07cc8344117..fefc6ff6ca61 100644 --- a/src/test/ui/macros/macro-use-bad-args-1.rs +++ b/src/test/ui/macros/macro-use-bad-args-1.rs @@ -13,3 +13,5 @@ #[allow(unused_extern_crates)] #[macro_use(foo(bar))] //~ ERROR bad macro import extern crate std; + +fn main() {} diff --git a/src/test/ui/macros/macro-use-bad-args-1.stderr b/src/test/ui/macros/macro-use-bad-args-1.stderr index 19a8c7c0382d..308fb6c76e1b 100644 --- a/src/test/ui/macros/macro-use-bad-args-1.stderr +++ b/src/test/ui/macros/macro-use-bad-args-1.stderr @@ -4,11 +4,6 @@ error[E0466]: bad macro import LL | #[macro_use(foo(bar))] //~ ERROR bad macro import | ^^^^^^^^ -error[E0601]: `main` function not found in crate `macro_use_bad_args_1` - | - = note: consider adding a `main` function to `$DIR/macro-use-bad-args-1.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors occurred: E0466, E0601. -For more information about an error, try `rustc --explain E0466`. +For more information about this error, try `rustc --explain E0466`. diff --git a/src/test/ui/macros/macro-use-bad-args-2.rs b/src/test/ui/macros/macro-use-bad-args-2.rs index 89004f168977..81352cf2e427 100644 --- a/src/test/ui/macros/macro-use-bad-args-2.rs +++ b/src/test/ui/macros/macro-use-bad-args-2.rs @@ -13,3 +13,5 @@ #[allow(unused_extern_crates)] #[macro_use(foo="bar")] //~ ERROR bad macro import extern crate std; + +fn main() {} diff --git a/src/test/ui/macros/macro-use-bad-args-2.stderr b/src/test/ui/macros/macro-use-bad-args-2.stderr index 0ac18201d791..62e3c22fab3e 100644 --- a/src/test/ui/macros/macro-use-bad-args-2.stderr +++ b/src/test/ui/macros/macro-use-bad-args-2.stderr @@ -4,11 +4,6 @@ error[E0466]: bad macro import LL | #[macro_use(foo="bar")] //~ ERROR bad macro import | ^^^^^^^^^ -error[E0601]: `main` function not found in crate `macro_use_bad_args_2` - | - = note: consider adding a `main` function to `$DIR/macro-use-bad-args-2.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors occurred: E0466, E0601. -For more information about an error, try `rustc --explain E0466`. +For more information about this error, try `rustc --explain E0466`. diff --git a/src/test/ui/nested-ty-params.rs b/src/test/ui/nested-ty-params.rs index aac37289bb74..2378cccf56f7 100644 --- a/src/test/ui/nested-ty-params.rs +++ b/src/test/ui/nested-ty-params.rs @@ -14,3 +14,5 @@ fn hd(v: Vec ) -> U { return hd1(v); } + +fn main() {} diff --git a/src/test/ui/nested-ty-params.stderr b/src/test/ui/nested-ty-params.stderr index 93b934f610f8..58b6cd18989f 100644 --- a/src/test/ui/nested-ty-params.stderr +++ b/src/test/ui/nested-ty-params.stderr @@ -18,11 +18,6 @@ LL | fn hd1(w: [U]) -> U { return w[0]; } | | | help: try using a local type parameter instead: `hd1` -error[E0601]: `main` function not found in crate `nested_ty_params` - | - = note: consider adding a `main` function to `$DIR/nested-ty-params.rs` +error: aborting due to 2 previous errors -error: aborting due to 3 previous errors - -Some errors occurred: E0401, E0601. -For more information about an error, try `rustc --explain E0401`. +For more information about this error, try `rustc --explain E0401`. diff --git a/src/test/ui/repr/repr-transparent-other-items.rs b/src/test/ui/repr/repr-transparent-other-items.rs index 685d62dc3a9c..be6f3cf9eb20 100644 --- a/src/test/ui/repr/repr-transparent-other-items.rs +++ b/src/test/ui/repr/repr-transparent-other-items.rs @@ -36,3 +36,5 @@ fn cant_repr_this() {} #[repr(transparent)] //~ ERROR should be applied to struct static CANT_REPR_THIS: u32 = 0; + +fn main() {} diff --git a/src/test/ui/repr/repr-transparent-other-items.stderr b/src/test/ui/repr/repr-transparent-other-items.stderr index e5889cf53e58..5a1978991480 100644 --- a/src/test/ui/repr/repr-transparent-other-items.stderr +++ b/src/test/ui/repr/repr-transparent-other-items.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `repr_transparent_other_items` - | - = note: consider adding a `main` function to `$DIR/repr-transparent-other-items.rs` - error[E0517]: attribute should be applied to struct --> $DIR/repr-transparent-other-items.rs:13:8 | @@ -67,7 +63,7 @@ LL | #[repr(transparent)] //~ ERROR unsupported representation for zero-variant LL | enum Void {} //~| ERROR should be applied to struct | ------------ zero-variant enum -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors -Some errors occurred: E0084, E0517, E0601. +Some errors occurred: E0084, E0517. For more information about an error, try `rustc --explain E0084`. diff --git a/src/test/ui/repr/repr-transparent-other-reprs.rs b/src/test/ui/repr/repr-transparent-other-reprs.rs index fa5f1a2f7fb8..aed8a69f66ef 100644 --- a/src/test/ui/repr/repr-transparent-other-reprs.rs +++ b/src/test/ui/repr/repr-transparent-other-reprs.rs @@ -26,3 +26,5 @@ struct TransparentPlusAlign(u8); #[repr(transparent)] //~ ERROR cannot have other repr #[repr(C)] struct SeparateAttributes(*mut u8); + +fn main() {} diff --git a/src/test/ui/repr/repr-transparent-other-reprs.stderr b/src/test/ui/repr/repr-transparent-other-reprs.stderr index 40f41c474dbd..c8f5dea3c124 100644 --- a/src/test/ui/repr/repr-transparent-other-reprs.stderr +++ b/src/test/ui/repr/repr-transparent-other-reprs.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `repr_transparent_other_reprs` - | - = note: consider adding a `main` function to `$DIR/repr-transparent-other-reprs.rs` - error[E0692]: transparent struct cannot have other repr hints --> $DIR/repr-transparent-other-reprs.rs:15:8 | @@ -28,7 +24,6 @@ LL | #[repr(transparent)] //~ ERROR cannot have other repr LL | #[repr(C)] | ^ -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors occurred: E0601, E0692. -For more information about an error, try `rustc --explain E0601`. +For more information about this error, try `rustc --explain E0692`. diff --git a/src/test/ui/repr/repr-transparent.rs b/src/test/ui/repr/repr-transparent.rs index 230573247316..f5b99af156ee 100644 --- a/src/test/ui/repr/repr-transparent.rs +++ b/src/test/ui/repr/repr-transparent.rs @@ -48,3 +48,5 @@ struct ZstAlign32(PhantomData); #[repr(transparent)] struct GenericAlign(ZstAlign32, u32); //~ ERROR alignment larger than 1 + +fn main() {} diff --git a/src/test/ui/repr/repr-transparent.stderr b/src/test/ui/repr/repr-transparent.stderr index 0f620880fa9d..f7bfdbdc625b 100644 --- a/src/test/ui/repr/repr-transparent.stderr +++ b/src/test/ui/repr/repr-transparent.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `repr_transparent` - | - = note: consider adding a `main` function to `$DIR/repr-transparent.rs` - error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 0 --> $DIR/repr-transparent.rs:21:1 | @@ -70,7 +66,7 @@ error[E0691]: zero-sized field in transparent struct has alignment larger than 1 LL | struct GenericAlign(ZstAlign32, u32); //~ ERROR alignment larger than 1 | ^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors -Some errors occurred: E0601, E0690, E0691. -For more information about an error, try `rustc --explain E0601`. +Some errors occurred: E0690, E0691. +For more information about an error, try `rustc --explain E0690`. diff --git a/src/test/ui/resolve/resolve-unknown-trait.rs b/src/test/ui/resolve/resolve-unknown-trait.rs index 9432e727fa5b..05bf4b928b72 100644 --- a/src/test/ui/resolve/resolve-unknown-trait.rs +++ b/src/test/ui/resolve/resolve-unknown-trait.rs @@ -17,3 +17,5 @@ impl SomeNonExistentTrait for isize {} fn f() {} //~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope + +fn main() {} diff --git a/src/test/ui/resolve/resolve-unknown-trait.stderr b/src/test/ui/resolve/resolve-unknown-trait.stderr index 8a2d791654d2..74b190f86845 100644 --- a/src/test/ui/resolve/resolve-unknown-trait.stderr +++ b/src/test/ui/resolve/resolve-unknown-trait.stderr @@ -16,11 +16,6 @@ error[E0405]: cannot find trait `SomeNonExistentTrait` in this scope LL | fn f() {} | ^^^^^^^^^^^^^^^^^^^^ not found in this scope -error[E0601]: `main` function not found in crate `resolve_unknown_trait` - | - = note: consider adding a `main` function to `$DIR/resolve-unknown-trait.rs` +error: aborting due to 3 previous errors -error: aborting due to 4 previous errors - -Some errors occurred: E0405, E0601. -For more information about an error, try `rustc --explain E0405`. +For more information about this error, try `rustc --explain E0405`. diff --git a/src/test/ui/resolve_self_super_hint.rs b/src/test/ui/resolve_self_super_hint.rs index a89fd802baf0..c5dd367c0ab8 100644 --- a/src/test/ui/resolve_self_super_hint.rs +++ b/src/test/ui/resolve_self_super_hint.rs @@ -32,3 +32,5 @@ mod a { } } } + +fn main() {} diff --git a/src/test/ui/resolve_self_super_hint.stderr b/src/test/ui/resolve_self_super_hint.stderr index 8538da06baf6..40b2a4bf9684 100644 --- a/src/test/ui/resolve_self_super_hint.stderr +++ b/src/test/ui/resolve_self_super_hint.stderr @@ -22,11 +22,6 @@ error[E0432]: unresolved import `alloc` LL | use alloc::HashMap; | ^^^^^ Did you mean `a::alloc`? -error[E0601]: `main` function not found in crate `resolve_self_super_hint` - | - = note: consider adding a `main` function to `$DIR/resolve_self_super_hint.rs` +error: aborting due to 4 previous errors -error: aborting due to 5 previous errors - -Some errors occurred: E0432, E0601. -For more information about an error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/specialization/defaultimpl/validation.rs b/src/test/ui/specialization/defaultimpl/validation.rs index 26b8b737f340..068eb7a44855 100644 --- a/src/test/ui/specialization/defaultimpl/validation.rs +++ b/src/test/ui/specialization/defaultimpl/validation.rs @@ -21,3 +21,5 @@ default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default trait Tr {} default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits + +fn main() {} diff --git a/src/test/ui/specialization/defaultimpl/validation.stderr b/src/test/ui/specialization/defaultimpl/validation.stderr index 54b92da7b219..c25c428eb4e9 100644 --- a/src/test/ui/specialization/defaultimpl/validation.stderr +++ b/src/test/ui/specialization/defaultimpl/validation.stderr @@ -6,10 +6,6 @@ LL | default impl S {} //~ ERROR inherent impls cannot be default | = note: only trait implementations may be annotated with default -error[E0601]: `main` function not found in crate `validation` - | - = note: consider adding a `main` function to `$DIR/validation.rs` - error: impls of auto traits cannot be default --> $DIR/validation.rs:19:1 | @@ -28,7 +24,6 @@ error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and LL | default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors occurred: E0192, E0601. -For more information about an error, try `rustc --explain E0192`. +For more information about this error, try `rustc --explain E0192`. diff --git a/src/test/ui/tuple/tuple-struct-fields/test.rs b/src/test/ui/tuple/tuple-struct-fields/test.rs index 22d54a383407..c8b77bfabdb9 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test.rs +++ b/src/test/ui/tuple/tuple-struct-fields/test.rs @@ -15,3 +15,5 @@ mod foo { //~^ ERROR expected one of `)` or `,`, found `(` //~| ERROR cannot find type `foo` in this scope } + +fn main() {} diff --git a/src/test/ui/tuple/tuple-struct-fields/test.stderr b/src/test/ui/tuple/tuple-struct-fields/test.stderr index 59228ea8c14d..f83e9dd5458f 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test.stderr @@ -10,11 +10,6 @@ error[E0412]: cannot find type `foo` in this scope LL | struct S2(pub((foo)) ()); | ^^^ not found in this scope -error[E0601]: `main` function not found in crate `test` - | - = note: consider adding a `main` function to `$DIR/test.rs` +error: aborting due to 2 previous errors -error: aborting due to 3 previous errors - -Some errors occurred: E0412, E0601. -For more information about an error, try `rustc --explain E0412`. +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/unresolved/unresolved-import.rs b/src/test/ui/unresolved/unresolved-import.rs index a3eeb6de96bd..efa749464769 100644 --- a/src/test/ui/unresolved/unresolved-import.rs +++ b/src/test/ui/unresolved/unresolved-import.rs @@ -55,3 +55,5 @@ mod items { fn item() {} } + +fn main() {} diff --git a/src/test/ui/unresolved/unresolved-import.stderr b/src/test/ui/unresolved/unresolved-import.stderr index 1e663cde48a6..9bcebb0011a7 100644 --- a/src/test/ui/unresolved/unresolved-import.stderr +++ b/src/test/ui/unresolved/unresolved-import.stderr @@ -34,11 +34,6 @@ error[E0432]: unresolved import `Enum` LL | use Enum::*; //~ ERROR unresolved import `Enum` [E0432] | ^^^^ Did you mean `self::Enum`? -error[E0601]: `main` function not found in crate `unresolved_import` - | - = note: consider adding a `main` function to `$DIR/unresolved-import.rs` +error: aborting due to 6 previous errors -error: aborting due to 7 previous errors - -Some errors occurred: E0432, E0601. -For more information about an error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/user-defined-macro-rules.rs b/src/test/ui/user-defined-macro-rules.rs index 02e1a585fa89..fe76d58f1ef7 100644 --- a/src/test/ui/user-defined-macro-rules.rs +++ b/src/test/ui/user-defined-macro-rules.rs @@ -11,3 +11,5 @@ #![allow(unused_macros)] macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules` + +fn main() {} diff --git a/src/test/ui/user-defined-macro-rules.stderr b/src/test/ui/user-defined-macro-rules.stderr index 3359aa4bcd72..1f8b18166c9c 100644 --- a/src/test/ui/user-defined-macro-rules.stderr +++ b/src/test/ui/user-defined-macro-rules.stderr @@ -4,10 +4,5 @@ error: user-defined macros may not be named `macro_rules` LL | macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0601]: `main` function not found in crate `user_defined_macro_rules` - | - = note: consider adding a `main` function to `$DIR/user-defined-macro-rules.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/wasm-custom-section-relocations.rs b/src/test/ui/wasm-custom-section-relocations.rs index 5631a70192af..9f431e780613 100644 --- a/src/test/ui/wasm-custom-section-relocations.rs +++ b/src/test/ui/wasm-custom-section-relocations.rs @@ -21,3 +21,5 @@ pub static C: usize = 3; #[link_section = "test"] pub static D: &usize = &C; //~ ERROR: no extra levels of indirection + +fn main() {} diff --git a/src/test/ui/wasm-custom-section-relocations.stderr b/src/test/ui/wasm-custom-section-relocations.stderr index 9b96b99e02ae..cea6e5c41923 100644 --- a/src/test/ui/wasm-custom-section-relocations.stderr +++ b/src/test/ui/wasm-custom-section-relocations.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `wasm_custom_section_relocations` - | - = note: consider adding a `main` function to `$DIR/wasm-custom-section-relocations.rs` - error: statics with a custom `#[link_section]` must be a simple list of bytes on the wasm target with no extra levels of indirection such as references --> $DIR/wasm-custom-section-relocations.rs:14:1 | @@ -14,6 +10,5 @@ error: statics with a custom `#[link_section]` must be a simple list of bytes on LL | pub static D: &usize = &C; //~ ERROR: no extra levels of indirection | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0601`. From 1a3bb2795b3c06e56d0c172b59178c72a171f1fc Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Sat, 4 Aug 2018 18:12:38 -0500 Subject: [PATCH 13/17] feature(doc_cfg): set cfg(rustdoc) when rustdoc is running --- src/librustdoc/lib.rs | 6 ++++-- src/libsyntax/feature_gate.rs | 1 + src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.rs | 14 ++++++++++++++ .../ui/feature-gate-doc_cfg-cfg-rustdoc.stderr | 11 +++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.rs create mode 100644 src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.stderr diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 279151eb26de..feae724b55d0 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -466,7 +466,8 @@ fn main_args(args: &[String]) -> isize { let output = matches.opt_str("o").map(|s| PathBuf::from(&s)); let css_file_extension = matches.opt_str("e").map(|s| PathBuf::from(&s)); - let cfgs = matches.opt_strs("cfg"); + let mut cfgs = matches.opt_strs("cfg"); + cfgs.push("rustdoc".to_string()); if let Some(ref p) = css_file_extension { if !p.is_file() { @@ -643,7 +644,8 @@ where R: 'static + Send, for s in &matches.opt_strs("L") { paths.add_path(s, ErrorOutputType::default()); } - let cfgs = matches.opt_strs("cfg"); + let mut cfgs = matches.opt_strs("cfg"); + cfgs.push("rustdoc".to_string()); let triple = matches.opt_str("target").map(|target| { if target.ends_with(".json") { TargetTriple::TargetPath(PathBuf::from(target)) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 6dd788bf6e2a..7f051ac3ebcc 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1148,6 +1148,7 @@ const GATED_CFGS: &[(&str, &str, fn(&Features) -> bool)] = &[ ("target_vendor", "cfg_target_vendor", cfg_fn!(cfg_target_vendor)), ("target_thread_local", "cfg_target_thread_local", cfg_fn!(cfg_target_thread_local)), ("target_has_atomic", "cfg_target_has_atomic", cfg_fn!(cfg_target_has_atomic)), + ("rustdoc", "doc_cfg", cfg_fn!(doc_cfg)), ]; #[derive(Debug)] diff --git a/src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.rs b/src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.rs new file mode 100644 index 000000000000..6207d99dc36a --- /dev/null +++ b/src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.rs @@ -0,0 +1,14 @@ +// 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. + +#[cfg(rustdoc)] //~ ERROR: `cfg(rustdoc)` is experimental and subject to change +pub struct SomeStruct; + +fn main() {} diff --git a/src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.stderr b/src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.stderr new file mode 100644 index 000000000000..be2c263af042 --- /dev/null +++ b/src/test/ui/feature-gate-doc_cfg-cfg-rustdoc.stderr @@ -0,0 +1,11 @@ +error[E0658]: `cfg(rustdoc)` is experimental and subject to change (see issue #43781) + --> $DIR/feature-gate-doc_cfg-cfg-rustdoc.rs:11:7 + | +LL | #[cfg(rustdoc)] //~ ERROR: `cfg(rustdoc)` is experimental and subject to change + | ^^^^^^^ + | + = help: add #![feature(doc_cfg)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. From d7e496f4424cc0fef686abdc738a8421825c9c50 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Sat, 4 Aug 2018 18:28:36 -0500 Subject: [PATCH 14/17] feature(doc_cfg): add docs for cfg(rustdoc) --- src/doc/rustdoc/src/unstable-features.md | 20 +++++++++---------- .../src/language-features/doc-cfg.md | 8 ++++++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index a91c2cd71cde..876a773b30ab 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -106,27 +106,25 @@ The `#[doc(cfg(...))]` attribute has another effect: When Rustdoc renders docume item, it will be accompanied by a banner explaining that the item is only available on certain platforms. -As mentioned earlier, getting the items to Rustdoc requires some extra preparation. The standard -library adds a `--cfg dox` flag to every Rustdoc command, but the same thing can be accomplished by -adding a feature to your Cargo.toml and adding `--feature dox` (or whatever you choose to name the -feature) to your `cargo doc` calls. +For Rustdoc to document an item, it needs to see it, regardless of what platform it's currently +running on. To aid this, Rustdoc sets the flag `#[cfg(rustdoc)]` when running on your crate. +Combining this with the target platform of a given item allows it to appear when building your crate +normally on that platform, as well as when building documentation anywhere. -Either way, once you create an environment for the documentation, you can start to augment your -`#[cfg]` attributes to allow both the target platform *and* the documentation configuration to leave -the item in. For example, `#[cfg(any(windows, feature = "dox"))]` will preserve the item either on -Windows or during the documentation process. Then, adding a new attribute `#[doc(cfg(windows))]` -will tell Rustdoc that the item is supposed to be used on Windows. For example: +For example, `#[cfg(any(windows, rustdoc))]` will preserve the item either on Windows or during the +documentation process. Then, adding a new attribute `#[doc(cfg(windows))]` will tell Rustdoc that +the item is supposed to be used on Windows. For example: ```rust #![feature(doc_cfg)] /// Token struct that can only be used on Windows. -#[cfg(any(windows, feature = "dox"))] +#[cfg(any(windows, rustdoc))] #[doc(cfg(windows))] pub struct WindowsToken; /// Token struct that can only be used on Unix. -#[cfg(any(unix, feature = "dox"))] +#[cfg(any(unix, rustdoc))] #[doc(cfg(unix))] pub struct UnixToken; ``` diff --git a/src/doc/unstable-book/src/language-features/doc-cfg.md b/src/doc/unstable-book/src/language-features/doc-cfg.md index ddc538e12144..96c66a1515ed 100644 --- a/src/doc/unstable-book/src/language-features/doc-cfg.md +++ b/src/doc/unstable-book/src/language-features/doc-cfg.md @@ -12,13 +12,17 @@ This attribute has two effects: 2. The item's doc-tests will only run on the specific platform. +In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a +special conditional compilation flag, `#[cfg(rustdoc)]`, set whenever building documentation on your +crate. + This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the standard library be documented. ```rust #![feature(doc_cfg)] -#[cfg(any(windows, feature = "documentation"))] +#[cfg(any(windows, rustdoc))] #[doc(cfg(windows))] /// The application's icon in the notification area (a.k.a. system tray). /// @@ -39,4 +43,4 @@ pub struct Icon { ``` [#43781]: https://github.com/rust-lang/rust/issues/43781 -[#43348]: https://github.com/rust-lang/rust/issues/43348 \ No newline at end of file +[#43348]: https://github.com/rust-lang/rust/issues/43348 From ad2169c095b190afd76a5e32865410502a8bcfdd Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Sat, 4 Aug 2018 18:29:47 -0500 Subject: [PATCH 15/17] use cfg(rustdoc) instead of cfg(dox) in std and friends --- src/bootstrap/bin/rustdoc.rs | 2 ++ src/libcore/macros.rs | 2 +- src/libstd/macros.rs | 2 +- src/libstd/os/mod.rs | 2 +- src/libstd/sys/mod.rs | 4 ++-- src/libstd/sys/unix/mod.rs | 30 +++++++++++++++--------------- src/libstd/sys/windows/c.rs | 2 +- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs index a54e58665cce..bb5a21e3e405 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/bin/rustdoc.rs @@ -37,6 +37,8 @@ fn main() { let mut dylib_path = bootstrap::util::dylib_path(); dylib_path.insert(0, PathBuf::from(libdir.clone())); + //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox` + //arguments here let mut cmd = Command::new(rustdoc); cmd.args(&args) .arg("--cfg") diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 5b3b2d163568..0032bedc7ed1 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -541,7 +541,7 @@ macro_rules! unimplemented { /// into libsyntax itself. /// /// For more information, see documentation for `std`'s macros. -#[cfg(dox)] +#[cfg(rustdoc)] mod builtin { /// Unconditionally causes compilation to fail with the given error message when encountered. diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 6945a41a5e73..b649ec2340e9 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -309,7 +309,7 @@ macro_rules! assert_approx_eq { /// These macros do not have any corresponding definition with a `macro_rules!` /// macro, but are documented here. Their implementations can be found hardcoded /// into libsyntax itself. -#[cfg(dox)] +#[cfg(rustdoc)] mod builtin { /// Unconditionally causes compilation to fail with the given error message when encountered. diff --git a/src/libstd/os/mod.rs b/src/libstd/os/mod.rs index c384ec9168ac..6bc186e79666 100644 --- a/src/libstd/os/mod.rs +++ b/src/libstd/os/mod.rs @@ -14,7 +14,7 @@ #![allow(missing_docs, bad_style, missing_debug_implementations)] cfg_if! { - if #[cfg(dox)] { + if #[cfg(rustdoc)] { // When documenting libstd we want to show unix/windows/linux modules as // these are the "main modules" that are used across platforms. This diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs index c44db3b10722..61e4ce66eec0 100644 --- a/src/libstd/sys/mod.rs +++ b/src/libstd/sys/mod.rs @@ -57,7 +57,7 @@ cfg_if! { // then later used in the `std::os` module when documenting, for example, // Windows when we're compiling for Linux. -#[cfg(dox)] +#[cfg(rustdoc)] cfg_if! { if #[cfg(any(unix, target_os = "redox"))] { // On unix we'll document what's already available @@ -77,7 +77,7 @@ cfg_if! { } } -#[cfg(dox)] +#[cfg(rustdoc)] cfg_if! { if #[cfg(windows)] { // On windows we'll just be documenting what's already available diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index c738003caf1d..a631ef5ec5cb 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -13,22 +13,22 @@ use io::{self, ErrorKind}; use libc; -#[cfg(any(dox, target_os = "linux"))] pub use os::linux as platform; +#[cfg(any(rustdoc, target_os = "linux"))] pub use os::linux as platform; -#[cfg(all(not(dox), target_os = "android"))] pub use os::android as platform; -#[cfg(all(not(dox), target_os = "bitrig"))] pub use os::bitrig as platform; -#[cfg(all(not(dox), target_os = "dragonfly"))] pub use os::dragonfly as platform; -#[cfg(all(not(dox), target_os = "freebsd"))] pub use os::freebsd as platform; -#[cfg(all(not(dox), target_os = "haiku"))] pub use os::haiku as platform; -#[cfg(all(not(dox), target_os = "ios"))] pub use os::ios as platform; -#[cfg(all(not(dox), target_os = "macos"))] pub use os::macos as platform; -#[cfg(all(not(dox), target_os = "netbsd"))] pub use os::netbsd as platform; -#[cfg(all(not(dox), target_os = "openbsd"))] pub use os::openbsd as platform; -#[cfg(all(not(dox), target_os = "solaris"))] pub use os::solaris as platform; -#[cfg(all(not(dox), target_os = "emscripten"))] pub use os::emscripten as platform; -#[cfg(all(not(dox), target_os = "fuchsia"))] pub use os::fuchsia as platform; -#[cfg(all(not(dox), target_os = "l4re"))] pub use os::linux as platform; -#[cfg(all(not(dox), target_os = "hermit"))] pub use os::hermit as platform; +#[cfg(all(not(rustdoc), target_os = "android"))] pub use os::android as platform; +#[cfg(all(not(rustdoc), target_os = "bitrig"))] pub use os::bitrig as platform; +#[cfg(all(not(rustdoc), target_os = "dragonfly"))] pub use os::dragonfly as platform; +#[cfg(all(not(rustdoc), target_os = "freebsd"))] pub use os::freebsd as platform; +#[cfg(all(not(rustdoc), target_os = "haiku"))] pub use os::haiku as platform; +#[cfg(all(not(rustdoc), target_os = "ios"))] pub use os::ios as platform; +#[cfg(all(not(rustdoc), target_os = "macos"))] pub use os::macos as platform; +#[cfg(all(not(rustdoc), target_os = "netbsd"))] pub use os::netbsd as platform; +#[cfg(all(not(rustdoc), target_os = "openbsd"))] pub use os::openbsd as platform; +#[cfg(all(not(rustdoc), target_os = "solaris"))] pub use os::solaris as platform; +#[cfg(all(not(rustdoc), target_os = "emscripten"))] pub use os::emscripten as platform; +#[cfg(all(not(rustdoc), target_os = "fuchsia"))] pub use os::fuchsia as platform; +#[cfg(all(not(rustdoc), target_os = "l4re"))] pub use os::linux as platform; +#[cfg(all(not(rustdoc), target_os = "hermit"))] pub use os::hermit as platform; pub use self::rand::hashmap_random_keys; pub use libc::strlen; diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index e514a56dcc43..10f48c3c308a 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -794,7 +794,7 @@ pub struct FLOATING_SAVE_AREA { // will not appear in the final documentation. This should be also defined for // other architectures supported by Windows such as ARM, and for historical // interest, maybe MIPS and PowerPC as well. -#[cfg(all(dox, not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"))))] +#[cfg(all(rustdoc, not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"))))] pub enum CONTEXT {} #[cfg(target_arch = "aarch64")] From a18a2900f3c4be97d661c2ab5ae5812106ed2833 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Sat, 1 Sep 2018 09:49:24 +0800 Subject: [PATCH 16/17] improve panic message --- src/librustc_mir/interpret/memory.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 79e635a03b2e..d2edfdec9065 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -344,7 +344,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { if let ConstValue::ByRef(_, allocation, _) = const_val.val { allocation } else { - panic!("Trying to get allocation info from non-byref const value") + panic!("Matching on non-ByRef static") } }) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 2129cdf6f466..b0e8f1c8ca3f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1378,7 +1378,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) { let alloc = if let ConstValue::ByRef(_, allocation, _) = static_.val { allocation } else { - panic!("Trying to get allocation info from non-byref const value") + panic!("Matching on non-ByRef static") }; if alloc.relocations.len() != 0 { let msg = "statics with a custom `#[link_section]` must be a \ From db7da0e476b943cf9248e2f49329a300ffbb132e Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Sat, 1 Sep 2018 18:13:28 +0800 Subject: [PATCH 17/17] bug! instead of panic! --- src/librustc_mir/interpret/memory.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index d2edfdec9065..59bebbb87a77 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -344,7 +344,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { if let ConstValue::ByRef(_, allocation, _) = const_val.val { allocation } else { - panic!("Matching on non-ByRef static") + bug!("Matching on non-ByRef static") } }) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b0e8f1c8ca3f..7a13d8bdd4ba 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1378,7 +1378,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) { let alloc = if let ConstValue::ByRef(_, allocation, _) = static_.val { allocation } else { - panic!("Matching on non-ByRef static") + bug!("Matching on non-ByRef static") }; if alloc.relocations.len() != 0 { let msg = "statics with a custom `#[link_section]` must be a \