# rustc to execute.
#lld = false
+# Whether to deny warnings in crates
+#deny-warnings = true
+
# =============================================================================
# Options for specific targets
#
cmd.arg("--color=always");
}
+ if env::var_os("RUSTC_DENY_WARNINGS").is_some() {
+ cmd.arg("-Dwarnings");
+ }
+
if verbose > 1 {
eprintln!("rustc command: {:?}", cmd);
eprintln!("sysroot: {:?}", sysroot);
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));
+ // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
+ if self.config.deny_warnings && !(mode == Mode::Libstd && stage == 0) {
+ cargo.env("RUSTC_DENY_WARNINGS", "1");
+ }
+
// Throughout the build Cargo can execute a number of build scripts
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
// obtained previously to those build scripts.
cargo.arg("--message-format").arg("json")
.stdout(Stdio::piped());
- if stderr_isatty() && build.ci_env == CiEnv::None {
+ if stderr_isatty() && build.ci_env == CiEnv::None &&
+ // if the terminal is reported as dumb, then we don't want to enable color for rustc
+ env::var_os("TERM").map(|t| t != *"dumb").unwrap_or(true) {
// since we pass message-format=json to cargo, we need to tell the rustc
// wrapper to give us colored output if necessary. This is because we
// only want Cargo's JSON output, not rustcs.
pub incremental: bool,
pub dry_run: bool,
+ pub deny_warnings: bool,
+
// llvm codegen options
pub llvm_enabled: bool,
pub llvm_assertions: bool,
codegen_backends_dir: Option<String>,
wasm_syscall: Option<bool>,
lld: Option<bool>,
+ deny_warnings: Option<bool>,
}
/// TOML representation of how each build target is configured.
config.test_miri = false;
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
config.rust_codegen_backends_dir = "codegen-backends".to_owned();
+ config.deny_warnings = true;
// set by bootstrap.py
config.src = env::var_os("SRC").map(PathBuf::from).expect("'SRC' to be set");
config.incremental = flags.incremental;
config.dry_run = flags.dry_run;
config.keep_stage = flags.keep_stage;
+ if let Some(value) = flags.warnings {
+ config.deny_warnings = value;
+ }
if config.dry_run {
let dir = config.out.join("tmp-dry-run");
config.rustc_default_linker = rust.default_linker.clone();
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
+ set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
if let Some(ref backends) = rust.codegen_backends {
config.rust_codegen_backends = backends.iter()
pub exclude: Vec<PathBuf>,
pub rustc_error_format: Option<String>,
pub dry_run: bool,
+
+ // true => deny
+ pub warnings: Option<bool>,
}
pub enum Subcommand {
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
opts.optflag("h", "help", "print this help message");
+ opts.optopt("", "warnings", "if value is deny, will deny warnings, otherwise use default",
+ "VALUE");
opts.optopt("", "error-format", "rustc error format", "FORMAT");
// fn usage()
incremental: matches.opt_present("incremental"),
exclude: split(matches.opt_strs("exclude"))
.into_iter().map(|p| p.into()).collect::<Vec<_>>(),
+ warnings: matches.opt_str("warnings").map(|v| v == "deny"),
}
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
use std::fs::File;
use std::path::{Path, PathBuf};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
-
#![feature(rand)]
#![feature(repr_simd)]
#![feature(slice_sort_by_cached_key)]
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
#![no_std]
#![needs_allocator]
-#![deny(warnings)]
#![deny(missing_debug_implementations)]
#![cfg_attr(test, allow(deprecated))] // rand
let sz_usize = mem::size_of::<(K, usize)>();
let len = self.len();
+ if len < 2 { return }
if sz_u8 < sz_u16 && len <= ( u8::MAX as usize) { return sort_by_key!( u8, self, f) }
if sz_u16 < sz_u32 && len <= (u16::MAX as usize) { return sort_by_key!(u16, self, f) }
if sz_u32 < sz_usize && len <= (u32::MAX as usize) { return sort_by_key!(u32, self, f) }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
-
#![feature(allocator_api)]
#![feature(alloc_system)]
#![feature(attr_literals)]
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "27783")]
-#![deny(warnings)]
#![feature(alloc_system)]
#![feature(libc)]
#![feature(linkage)]
#![no_std]
#![allow(unused_attributes)]
-#![deny(warnings)]
#![unstable(feature = "alloc_system",
reason = "this library is unlikely to be stabilized in its current \
form or name",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
test(no_crate_inject, attr(deny(warnings))))]
-#![deny(warnings)]
#![feature(alloc)]
#![feature(core_intrinsics)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
-
#![feature(flt2dec)]
#![feature(test)]
#![no_core]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
-#![deny(warnings)]
#![feature(allow_internal_unstable)]
#![feature(asm)]
/// # Examples
///
/// ```rust
- /// #![feature(option_filter)]
- ///
/// fn is_even(n: &i32) -> bool {
/// n % 2 == 0
/// }
/// assert_eq!(Some(4).filter(is_even), Some(4));
/// ```
#[inline]
- #[unstable(feature = "option_filter", issue = "45860")]
+ #[stable(feature = "option_filter", since = "1.27.0")]
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
if let Some(x) = self {
if predicate(&x) {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
-
#![feature(ascii_ctype)]
#![feature(box_syntax)]
#![feature(core_float)]
html_root_url = "https://doc.rust-lang.org/nightly/",
html_playground_url = "https://play.rust-lang.org/",
test(attr(deny(warnings))))]
-#![deny(warnings)]
pub use self::Piece::*;
pub use self::Position::*;
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
test(attr(allow(unused_variables), deny(warnings))))]
-#![deny(warnings)]
#![feature(str_escape)]
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
-#![deny(warnings)]
#![panic_runtime]
#![allow(unused_features)]
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
-#![deny(warnings)]
#![feature(alloc)]
#![feature(core_intrinsics)]
//! See [the book](../book/first-edition/procedural-macros.html) for more.
#![stable(feature = "proc_macro_lib", since = "1.15.0")]
-#![deny(warnings)]
#![deny(missing_docs)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
-
#![feature(test)]
extern crate test;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use syntax::ast;
+use syntax::symbol::InternedString;
use syntax_pos::Span;
use ty::{self, Ty};
MiscVariable(Span),
NormalizeProjectionType(Span),
TypeInference(Span),
- TypeParameterDefinition(Span, ast::Name),
+ TypeParameterDefinition(Span, InternedString),
/// one of the upvars or closure kind parameters in a `ClosureSubsts`
/// (before it has been determined)
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
+#![feature(slice_sort_by_cached_key)]
#![feature(specialization)]
#![feature(unboxed_closures)]
#![feature(trace_macros)]
.collect::<Vec<_>>();
let mut ordering = tcx.postorder_cnums(LOCAL_CRATE);
Lrc::make_mut(&mut ordering).reverse();
- libs.sort_by_key(|&(a, _)| {
+ libs.sort_by_cached_key(|&(a, _)| {
ordering.iter().position(|x| *x == a)
});
libs
}
for param in generics.types.iter() {
- let name = param.name.as_str().to_string();
+ let name = param.name.to_string();
let ty = trait_ref.substs.type_for_def(param);
let ty_str = ty.to_string();
flags.push((name.clone(),
let trait_str = tcx.item_path_str(trait_ref.def_id);
let generics = tcx.generics_of(trait_ref.def_id);
let generic_map = generics.types.iter().map(|param| {
- (param.name.as_str().to_string(),
+ (param.name.to_string(),
trait_ref.substs.type_for_def(param).to_string())
}).collect::<FxHashMap<String, String>>();
use std::sync::mpsc;
use std::sync::Arc;
use syntax::abi;
-use syntax::ast::{self, Name, NodeId};
+use syntax::ast::{self, NodeId};
use syntax::attr;
use syntax::codemap::MultiSpan;
use syntax::feature_gate;
-use syntax::symbol::{Symbol, keywords};
+use syntax::symbol::{Symbol, keywords, InternedString};
use syntax_pos::Span;
use hir;
pub fn mk_param(self,
index: u32,
- name: Name) -> Ty<'tcx> {
+ name: InternedString) -> Ty<'tcx> {
self.mk_ty(TyParam(ParamTy { idx: index, name: name }))
}
pub fn mk_self_type(self) -> Ty<'tcx> {
- self.mk_param(0, keywords::SelfType.name())
+ self.mk_param(0, keywords::SelfType.name().as_str())
}
pub fn mk_param_from_def(self, def: &ty::TypeParameterDef) -> Ty<'tcx> {
// Find one non-ZST variant.
'variants: for (v, fields) in variants.iter().enumerate() {
+ if fields.iter().any(|f| f.abi == Abi::Uninhabited) {
+ continue 'variants;
+ }
for f in fields {
- if f.abi == Abi::Uninhabited {
- continue 'variants;
- }
if !f.is_zst() {
if dataful_variant.is_none() {
dataful_variant = Some(v);
map: LockGuard<'_, QueryMap<$tcx, Self>>,
dep_node: DepNode)
-> Result<($V, DepNodeIndex), CycleError<$tcx>> {
- debug_assert!(!tcx.dep_graph.dep_node_exists(&dep_node));
+ // If the following assertion triggers, it can have two reasons:
+ // 1. Something is wrong with DepNode creation, either here or
+ // in DepGraph::try_mark_green()
+ // 2. Two distinct query keys get mapped to the same DepNode
+ // (see for example #48923)
+ assert!(!tcx.dep_graph.dep_node_exists(&dep_node),
+ "Forcing query with already existing DepNode.\n\
+ - query-key: {:?}\n\
+ - dep-node: {:?}",
+ key, dep_node);
profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin);
let res = Self::start_job(tcx,
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub struct TypeParameterDef {
- pub name: Name,
+ pub name: InternedString,
pub def_id: DefId,
pub index: u32,
pub has_default: bool,
use std::cmp::Ordering;
use syntax::abi;
use syntax::ast::{self, Name};
-use syntax::symbol::keywords;
+use syntax::symbol::{keywords, InternedString};
use serialize;
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub struct ParamTy {
pub idx: u32,
- pub name: Name,
+ pub name: InternedString,
}
impl<'a, 'gcx, 'tcx> ParamTy {
- pub fn new(index: u32, name: Name) -> ParamTy {
+ pub fn new(index: u32, name: InternedString) -> ParamTy {
ParamTy { idx: index, name: name }
}
pub fn for_self() -> ParamTy {
- ParamTy::new(0, keywords::SelfType.name())
+ ParamTy::new(0, keywords::SelfType.name().as_str())
}
pub fn for_def(def: &ty::TypeParameterDef) -> ParamTy {
}
pub fn is_self(&self) -> bool {
- if self.name == keywords::SelfType.name() {
+ if self.name == keywords::SelfType.name().as_str() {
assert_eq!(self.idx, 0);
true
} else {
}
TyParam(p) => {
self.hash(p.idx);
- self.hash(p.name.as_str());
+ self.hash(p.name);
}
TyProjection(ref data) => {
self.def_id(data.item_def_id);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
-
#![feature(rustc_private)]
extern crate rustc;
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![forbid(unsafe_code)]
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(box_syntax)]
#![feature(const_fn)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![allow(non_camel_case_types)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
extern crate rustc_apfloat;
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(collections_range)]
#![feature(nonzero)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(box_syntax)]
#![cfg_attr(unix, feature(libc))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
+#![feature(slice_sort_by_cached_key)]
#![feature(set_stdio)]
#![feature(rustc_stack_internals)]
use serialize::json::ToJson;
use std::any::Any;
-use std::cmp::Ordering::Equal;
use std::cmp::max;
use std::default::Default;
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
fn sort_lints(sess: &Session, lints: Vec<(&'static Lint, bool)>) -> Vec<&'static Lint> {
let mut lints: Vec<_> = lints.into_iter().map(|(x, _)| x).collect();
- lints.sort_by(|x: &&Lint, y: &&Lint| {
- match x.default_level(sess).cmp(&y.default_level(sess)) {
- // The sort doesn't case-fold but it's doubtful we care.
- Equal => x.name.cmp(y.name),
- r => r,
- }
- });
+ // The sort doesn't case-fold but it's doubtful we care.
+ lints.sort_by_cached_key(|x: &&Lint| (x.default_level(sess), x.name));
lints
}
pub fn t_param(&self, index: u32) -> Ty<'tcx> {
let name = format!("T{}", index);
- self.infcx.tcx.mk_param(index, Symbol::intern(&name))
+ self.infcx.tcx.mk_param(index, Symbol::intern(&name).as_str())
}
pub fn re_early_bound(&self, index: u32, name: &'static str) -> ty::Region<'tcx> {
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(custom_attribute)]
#![allow(unused_attributes)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(fs_read_write)]
#![feature(specialization)]
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
hir::ItemStatic(..) => {
+ if attr::find_by_name(&it.attrs, "no_mangle").is_some() {
+ return;
+ }
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span);
}
hir::ItemConst(..) => {
}
if let PatKind::Binding(_, _, name, None) = fieldpat.node.pat.node {
if name.node == fieldpat.node.name {
+ if let Some(_) = fieldpat.span.ctxt().outer().expn_info() {
+ // Don't lint if this is a macro expansion: macro authors
+ // shouldn't have to worry about this kind of style issue
+ // (Issue #49588)
+ return;
+ }
let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
fieldpat.span,
&format!("the `{}:` in this pattern is redundant",
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![cfg_attr(test, feature(test))]
#![feature(box_patterns)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(box_syntax)]
#![feature(concat_idents)]
let mut all_impls: Vec<_> = visitor.impls.into_iter().collect();
// Bring everything into deterministic order for hashing
- all_impls.sort_unstable_by_key(|&(trait_def_id, _)| {
+ all_impls.sort_by_cached_key(|&(trait_def_id, _)| {
tcx.def_path_hash(trait_def_id)
});
.into_iter()
.map(|(trait_def_id, mut impls)| {
// Bring everything into deterministic order for hashing
- impls.sort_unstable_by_key(|&def_index| {
+ impls.sort_by_cached_key(|&def_index| {
tcx.hir.definitions().def_path_hash(def_index)
});
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(box_patterns)]
#![feature(fs_read_write)]
#![feature(macro_lifetime_matcher)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
+#![feature(slice_sort_by_cached_key)]
#![feature(specialization)]
#![feature(rustc_private)]
use dataflow::move_paths::{IllegalMoveOriginKind, MoveError};
use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MovePathIndex};
use util::borrowck_errors::{BorrowckErrors, Origin};
+use util::collect_writes::FindAssignments;
use std::iter;
}
}
+ fn specialized_description(&self, place:&Place<'tcx>) -> Option<String>{
+ if let Some(_name) = self.describe_place(place) {
+ Some(format!("data in a `&` reference"))
+ } else {
+ None
+ }
+ }
+
+ fn get_default_err_msg(&self, place:&Place<'tcx>) -> String{
+ match self.describe_place(place) {
+ Some(name) => format!("immutable item `{}`", name),
+ None => "immutable item".to_owned(),
+ }
+ }
+
+ fn get_secondary_err_msg(&self, place:&Place<'tcx>) -> String{
+ match self.specialized_description(place) {
+ Some(_) => format!("data in a `&` reference"),
+ None => self.get_default_err_msg(place)
+ }
+ }
+
+ fn get_primary_err_msg(&self, place:&Place<'tcx>) -> String{
+ if let Some(name) = self.describe_place(place) {
+ format!("`{}` is a `&` reference, so the data it refers to cannot be written", name)
+ } else {
+ format!("cannot assign through `&`-reference")
+ }
+ }
+
/// Check the permissions for the given place and read or write kind
///
/// Returns true if an error is reported, false otherwise.
self.is_mutable(place, is_local_mutation_allowed)
{
error_reported = true;
-
- let item_msg = match self.describe_place(place) {
- Some(name) => format!("immutable item `{}`", name),
- None => "immutable item".to_owned(),
- };
-
+ let item_msg = self.get_default_err_msg(place);
let mut err = self.tcx
.cannot_borrow_path_as_mutable(span, &item_msg, Origin::Mir);
err.span_label(span, "cannot borrow as mutable");
if place != place_err {
if let Some(name) = self.describe_place(place_err) {
- err.note(&format!("Value not mutable causing this error: `{}`", name));
+ err.note(&format!("the value which is causing this path not to be mutable \
+ is...: `{}`", name));
}
}
err.emit();
},
Reservation(WriteKind::Mutate) | Write(WriteKind::Mutate) => {
+
if let Err(place_err) = self.is_mutable(place, is_local_mutation_allowed) {
error_reported = true;
+ let mut err_info = None;
+ match *place_err {
+
+ Place::Projection(box Projection {
+ ref base, elem:ProjectionElem::Deref}) => {
+ match *base {
+ Place::Local(local) => {
+ let locations = self.mir.find_assignments(local);
+ if locations.len() > 0 {
+ let item_msg = if error_reported {
+ self.get_secondary_err_msg(base)
+ } else {
+ self.get_default_err_msg(place)
+ };
+ err_info = Some((
+ self.mir.source_info(locations[0]).span,
+ "consider changing this to be a \
+ mutable reference: `&mut`", item_msg,
+ self.get_primary_err_msg(base)));
+ }
+ },
+ _ => {},
+ }
+ },
+ _ => {},
+ }
- let item_msg = match self.describe_place(place) {
- Some(name) => format!("immutable item `{}`", name),
- None => "immutable item".to_owned(),
- };
-
- let mut err = self.tcx.cannot_assign(span, &item_msg, Origin::Mir);
- err.span_label(span, "cannot mutate");
-
- if place != place_err {
- if let Some(name) = self.describe_place(place_err) {
- err.note(&format!("Value not mutable causing this error: `{}`", name));
+ if let Some((err_help_span, err_help_stmt, item_msg, sec_span)) = err_info {
+ let mut err = self.tcx.cannot_assign(span, &item_msg, Origin::Mir);
+ err.span_suggestion(err_help_span, err_help_stmt, format!(""));
+ if place != place_err {
+ err.span_label(span, sec_span);
}
+ err.emit()
+ } else {
+ let item_msg_ = self.get_default_err_msg(place);
+ let mut err = self.tcx.cannot_assign(span, &item_msg_, Origin::Mir);
+ err.span_label(span, "cannot mutate");
+ if place != place_err {
+ if let Some(name) = self.describe_place(place_err) {
+ err.note(&format!("the value which is causing this path not to be \
+ mutable is...: `{}`", name));
+ }
+ }
+ err.emit();
}
-
- err.emit();
}
}
Reservation(WriteKind::Move)
);
}
}
-
Activation(..) => {} // permission checks are done at Reservation point.
-
Read(ReadKind::Borrow(BorrowKind::Unique))
| Read(ReadKind::Borrow(BorrowKind::Mut { .. }))
| Read(ReadKind::Borrow(BorrowKind::Shared))
}
}
}
+
*/
-#![deny(warnings)]
-
#![feature(slice_patterns)]
+#![feature(slice_sort_by_cached_key)]
#![feature(from_ref)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)]
#![feature(nonzero)]
#![feature(inclusive_range_fields)]
+#![feature(crate_visibility_modifier)]
extern crate arena;
#[macro_use]
use rustc::ty::item_path::characteristic_def_id_of_type;
use rustc::util::nodemap::{FxHashMap, FxHashSet};
use std::collections::hash_map::Entry;
+use std::cmp;
use syntax::ast::NodeId;
use syntax::symbol::{Symbol, InternedString};
use rustc::mir::mono::MonoItem;
use monomorphize::item::{MonoItemExt, InstantiationMode};
-use core::usize;
pub use rustc::mir::mono::CodegenUnit;
}, item.symbol_name(tcx))
}
- let items: Vec<_> = self.items().iter().map(|(&i, &l)| (i, l)).collect();
- let mut items : Vec<_> = items.iter()
- .map(|il| (il, item_sort_key(tcx, il.0))).collect();
- items.sort_by(|&(_, ref key1), &(_, ref key2)| key1.cmp(key2));
- items.into_iter().map(|(&item_linkage, _)| item_linkage).collect()
+ let mut items: Vec<_> = self.items().iter().map(|(&i, &l)| (i, l)).collect();
+ items.sort_by_cached_key(|&(i, _)| item_sort_key(tcx, i));
+ items
}
}
// Merge the two smallest codegen units until the target size is reached.
while codegen_units.len() > target_cgu_count {
// Sort small cgus to the back
- codegen_units.sort_by_key(|cgu| usize::MAX - cgu.size_estimate());
+ codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate()));
let mut smallest = codegen_units.pop().unwrap();
let second_smallest = codegen_units.last_mut().unwrap();
self.cancel_if_wrong_origin(err, o)
}
- fn cannot_assign(self, span: Span, desc: &str, o: Origin) -> DiagnosticBuilder<'cx>
+ fn cannot_assign(self, span: Span, desc: &str, o: Origin)
+ -> DiagnosticBuilder<'cx>
{
let err = struct_span_err!(self, span, E0594,
"cannot assign to {}{OGN}",
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use rustc::mir::{Local, Location};
+use rustc::mir::Mir;
+use rustc::mir::visit::PlaceContext;
+use rustc::mir::visit::Visitor;
+
+crate trait FindAssignments {
+ // Finds all statements that assign directly to local (i.e., X = ...)
+ // and returns their locations.
+ fn find_assignments(&self, local: Local) -> Vec<Location>;
+}
+
+impl<'tcx> FindAssignments for Mir<'tcx>{
+ fn find_assignments(&self, local: Local) -> Vec<Location>{
+ let mut visitor = FindLocalAssignmentVisitor{ needle: local, locations: vec![]};
+ visitor.visit_mir(self);
+ visitor.locations
+ }
+}
+
+// The Visitor walks the MIR to return the assignment statements corresponding
+// to a Local.
+struct FindLocalAssignmentVisitor {
+ needle: Local,
+ locations: Vec<Location>,
+}
+
+impl<'tcx> Visitor<'tcx> for FindLocalAssignmentVisitor {
+ fn visit_local(&mut self,
+ local: &Local,
+ place_context: PlaceContext<'tcx>,
+ location: Location) {
+ if self.needle != *local {
+ return;
+ }
+
+ match place_context {
+ PlaceContext::Store | PlaceContext::Call => {
+ self.locations.push(location);
+ }
+ PlaceContext::AsmOutput |
+ PlaceContext::Drop |
+ PlaceContext::Inspect |
+ PlaceContext::Borrow { .. } |
+ PlaceContext::Projection(..) |
+ PlaceContext::Copy |
+ PlaceContext::Move |
+ PlaceContext::StorageLive |
+ PlaceContext::StorageDead |
+ PlaceContext::Validate => {
+ // TO-DO
+ // self.super_local(local)
+ }
+ }
+ }
+ // TO-DO
+ // fn super_local()
+}
mod graphviz;
pub(crate) mod pretty;
pub mod liveness;
+pub mod collect_writes;
pub use self::alignment::is_disaligned;
pub use self::pretty::{dump_enabled, dump_mir, write_mir_pretty, PassWhere};
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(rustc_diagnostic_macros)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![deny(warnings)]
#![allow(bad_style)]
pub struct Intrinsic {
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(rustc_diagnostic_macros)]
#![feature(staged_api)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(rustc_diagnostic_macros)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(rustc_diagnostic_macros)]
+#![feature(slice_sort_by_cached_key)]
#[macro_use]
extern crate log;
fn for_each_child_stable<F: FnMut(Ident, Namespace, &'a NameBinding<'a>)>(&self, mut f: F) {
let resolutions = self.resolutions.borrow();
- let mut resolutions = resolutions.iter().map(|(&(ident, ns), &resolution)| {
- // Pre-compute keys for sorting
- (ident.name.as_str(), ns, ident, resolution)
- })
- .collect::<Vec<_>>();
- resolutions.sort_unstable_by_key(|&(str, ns, ..)| (str, ns));
- for &(_, ns, ident, resolution) in resolutions.iter() {
+ let mut resolutions = resolutions.iter().collect::<Vec<_>>();
+ resolutions.sort_by_cached_key(|&(&(ident, ns), _)| (ident.name.as_str(), ns));
+ for &(&(ident, ns), &resolution) in resolutions.iter() {
resolution.borrow().binding.map(|binding| f(ident, ns, binding));
}
}
let is_mod = |def| match def { Def::Mod(..) => true, _ => false };
let mut candidates =
self.lookup_import_candidates(name, TypeNS, is_mod);
- candidates.sort_by_key(|c| (c.path.segments.len(), c.path.to_string()));
+ candidates.sort_by_cached_key(|c| {
+ (c.path.segments.len(), c.path.to_string())
+ });
if let Some(candidate) = candidates.get(0) {
format!("Did you mean `{}`?", candidate.path)
} else {
let name = path[path.len() - 1].name;
// Make sure error reporting is deterministic.
- names.sort_by_key(|name| name.as_str());
+ names.sort_by_cached_key(|name| name.as_str());
match find_best_match_for_name(names.iter(), &name.as_str(), None) {
Some(found) if found != name => Some(found),
_ => None,
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(custom_attribute)]
#![feature(macro_lifetime_matcher)]
#![allow(unused_attributes)]
//! New recursive solver modeled on Chalk's recursive solver. Most of
//! the guts are broken up into modules; see the comments in those modules.
-#![deny(warnings)]
-
#![feature(crate_visibility_modifier)]
#[macro_use]
use std::str;
use std::sync::Arc;
use std::time::{Instant, Duration};
-use std::{i32, usize};
+use std::i32;
+use std::cmp;
use std::sync::mpsc;
use syntax_pos::Span;
use syntax_pos::symbol::InternedString;
// a bit more efficiently.
let codegen_units = {
let mut codegen_units = codegen_units;
- codegen_units.sort_by_key(|cgu| usize::MAX - cgu.size_estimate());
+ codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate()));
codegen_units
};
use syntax_pos::{self, Span, Pos};
use syntax::ast;
-use syntax::symbol::Symbol;
+use syntax::symbol::{Symbol, InternedString};
use rustc::ty::layout::{self, LayoutOf};
pub mod gdb;
substs.types().zip(names).map(|(ty, name)| {
let actual_type = cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty);
let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP);
- let name = CString::new(name.as_str().as_bytes()).unwrap();
+ let name = CString::new(name.as_bytes()).unwrap();
unsafe {
llvm::LLVMRustDIBuilderCreateTemplateTypeParameter(
DIB(cx),
return create_DIArray(DIB(cx), &template_params[..]);
}
- fn get_type_parameter_names(cx: &CodegenCx, generics: &ty::Generics) -> Vec<ast::Name> {
+ fn get_type_parameter_names(cx: &CodegenCx, generics: &ty::Generics) -> Vec<InternedString> {
let mut names = generics.parent.map_or(vec![], |def_id| {
get_type_parameter_names(cx, cx.tcx.generics_of(def_id))
});
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(libc)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
+#![feature(slice_sort_by_cached_key)]
#![feature(optin_builtin_traits)]
#![feature(inclusive_range_fields)]
#![feature(underscore_lifetimes)]
("x86", "pclmulqdq") => "pclmul",
("x86", "rdrand") => "rdrnd",
("x86", "bmi1") => "bmi",
+ ("aarch64", "fp") => "fp-armv8",
("aarch64", "fp16") => "fullfp16",
(_, s) => s,
}
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(box_patterns)]
#![feature(box_syntax)]
let item_def_id = tcx.hir.local_def_id(item_id);
let generics = tcx.generics_of(item_def_id);
let index = generics.type_param_to_index[&tcx.hir.local_def_id(node_id)];
- tcx.mk_param(index, tcx.hir.name(node_id))
+ tcx.mk_param(index, tcx.hir.name(node_id).as_str())
}
Def::SelfTy(_, Some(def_id)) => {
// Self in impl (we know the concrete type).
/// and in libcore/intrinsics.rs
pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
it: &hir::ForeignItem) {
- let param = |n| tcx.mk_param(n, Symbol::intern(&format!("P{}", n)));
+ let param = |n| tcx.mk_param(n, Symbol::intern(&format!("P{}", n)).as_str());
let name = it.name.as_str();
let (n_tps, inputs, output) = if name.starts_with("atomic_") {
let split : Vec<&str> = name.split('_').collect();
pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
it: &hir::ForeignItem) {
let param = |n| {
- let name = Symbol::intern(&format!("P{}", n));
+ let name = Symbol::intern(&format!("P{}", n)).as_str();
tcx.mk_param(n, name)
};
.collect();
// sort them by the name so we have a stable result
- names.sort_by_key(|n| n.as_str());
+ names.sort_by_cached_key(|n| n.as_str());
names
}
// local so it should be okay to just unwrap everything.
let trait_def_id = impl_params[&method_param.name];
let trait_decl_span = tcx.def_span(trait_def_id);
- error_194(tcx, type_span, trait_decl_span, method_param.name);
+ error_194(tcx, type_span, trait_decl_span, &method_param.name[..]);
}
}
}
err
}
-fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: ast::Name) {
+fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: &str) {
struct_span_err!(tcx.sess, span, E0194,
"type parameter `{}` shadows another type parameter of the same name",
name)
let param_owner_def_id = tcx.hir.local_def_id(param_owner);
let generics = tcx.generics_of(param_owner_def_id);
let index = generics.type_param_to_index[&def_id];
- let ty = tcx.mk_param(index, tcx.hir.ty_param_name(param_id));
+ let ty = tcx.mk_param(index, tcx.hir.ty_param_name(param_id).as_str());
// Don't look for bounds where the type parameter isn't in scope.
let parent = if item_def_id == param_owner_def_id {
opt_self = Some(ty::TypeParameterDef {
index: 0,
- name: keywords::SelfType.name(),
+ name: keywords::SelfType.name().as_str(),
def_id: tcx.hir.local_def_id(param_id),
has_default: false,
object_lifetime_default: rl::Set1::Empty,
ty::TypeParameterDef {
index: type_start + i as u32,
- name: p.name,
+ name: p.name.as_str(),
def_id: tcx.hir.local_def_id(p.id),
has_default: p.default.is_some(),
object_lifetime_default:
// add a dummy parameter for the closure kind
types.push(ty::TypeParameterDef {
index: type_start,
- name: Symbol::intern("<closure_kind>"),
+ name: Symbol::intern("<closure_kind>").as_str(),
def_id,
has_default: false,
object_lifetime_default: rl::Set1::Empty,
// add a dummy parameter for the closure signature
types.push(ty::TypeParameterDef {
index: type_start + 1,
- name: Symbol::intern("<closure_signature>"),
+ name: Symbol::intern("<closure_signature>").as_str(),
def_id,
has_default: false,
object_lifetime_default: rl::Set1::Empty,
tcx.with_freevars(node_id, |fv| {
types.extend(fv.iter().zip(2..).map(|(_, i)| ty::TypeParameterDef {
index: type_start + i,
- name: Symbol::intern("<upvar>"),
+ name: Symbol::intern("<upvar>").as_str(),
def_id,
has_default: false,
object_lifetime_default: rl::Set1::Empty,
// Collect the predicates that were written inline by the user on each
// type parameter (e.g., `<T:Foo>`).
for param in ast_generics.ty_params() {
- let param_ty = ty::ParamTy::new(index, param.name).to_ty(tcx);
+ let param_ty = ty::ParamTy::new(index, param.name.as_str()).to_ty(tcx);
index += 1;
let bounds = compute_bounds(&icx,
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![allow(non_camel_case_types)]
#![feature(crate_visibility_modifier)]
#![feature(from_ref)]
#![feature(exhaustive_patterns)]
-#![feature(option_filter)]
#![feature(quote)]
#![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
+#![feature(slice_sort_by_cached_key)]
#![feature(dyn_trait)]
#[macro_use] extern crate log;
P(hir::Path {
span: DUMMY_SP,
def: Def::TyParam(param.def_id),
- segments: HirVec::from_vec(vec![hir::PathSegment::from_name(param.name)]),
+ segments: HirVec::from_vec(vec![
+ hir::PathSegment::from_name(Symbol::intern(¶m.name))
+ ]),
}),
)),
span: DUMMY_SP,
// involved (impls rarely have more than a few bounds) means that it
// shouldn't matter in practice.
fn unstable_debug_sort<T: Debug>(&self, vec: &mut Vec<T>) {
- vec.sort_unstable_by(|first, second| {
- format!("{:?}", first).cmp(&format!("{:?}", second))
- });
+ vec.sort_by_cached_key(|x| format!("{:?}", x))
}
fn is_fn_ty(&self, tcx: &TyCtxt, ty: &Type) -> bool {
use syntax::feature_gate::UnstableFeatures;
use syntax::ptr::P;
use syntax::symbol::keywords;
-use syntax::symbol::Symbol;
+use syntax::symbol::{Symbol, InternedString};
use syntax_pos::{self, DUMMY_SP, Pos, FileName};
use rustc::middle::const_val::ConstVal;
// predicates field (see rustc_typeck::collect::ty_generics), so remove
// them.
let stripped_typarams = gens.types.iter().filter_map(|tp| {
- if tp.name == keywords::SelfType.name() {
+ if tp.name == keywords::SelfType.name().as_str() {
assert_eq!(tp.index, 0);
None
} else {
}
}
+impl Clean<String> for InternedString {
+ fn clean(&self, _: &DocContext) -> String {
+ self.to_string()
+ }
+}
+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Typedef {
pub type_: Type,
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
html_playground_url = "https://play.rust-lang.org/")]
-#![deny(warnings)]
#![feature(ascii_ctype)]
#![feature(rustc_private)]
#![feature(box_syntax)]
#![feature(fs_read_write)]
#![feature(set_stdio)]
+#![feature(slice_sort_by_cached_key)]
#![feature(test)]
#![feature(unicode)]
#![feature(vec_remove_item)]
html_root_url = "https://doc.rust-lang.org/nightly/",
html_playground_url = "https://play.rust-lang.org/",
test(attr(allow(unused_variables), deny(warnings))))]
-#![deny(warnings)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
/// # Examples
///
/// ```no_run
- /// #![feature(take_set_limit)]
/// use std::io;
/// use std::io::prelude::*;
/// use std::fs::File;
/// Ok(())
/// }
/// ```
- #[unstable(feature = "take_set_limit", issue = "42781")]
+ #[stable(feature = "take_set_limit", since = "1.27.0")]
pub fn set_limit(&mut self, limit: u64) {
self.limit = limit;
}
// Tell the compiler to link to either panic_abort or panic_unwind
#![needs_panic_runtime]
-// Turn warnings into errors, but only after stage0, where it can be useful for
-// code to emit warnings during language transitions
-#![cfg_attr(not(stage0), deny(warnings))]
-
// std may use features in a platform-specific way
#![allow(unused_features)]
html_playground_url = "https://play.rust-lang.org/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
-#![deny(warnings)]
#![deny(missing_debug_implementations)]
#![no_std]
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
test(attr(deny(warnings))))]
-#![deny(warnings)]
#![feature(unicode)]
#![feature(rustc_diagnostic_macros)]
+#![feature(slice_sort_by_cached_key)]
#![feature(non_exhaustive)]
#![feature(const_atomic_usize_new)]
#![feature(rustc_attrs)]
.chain(inedible.iter().map(|x| TokenType::Token(x.clone())))
.chain(self.expected_tokens.iter().cloned())
.collect::<Vec<_>>();
- expected.sort_by(|a, b| a.to_string().cmp(&b.to_string()));
+ expected.sort_by_cached_key(|x| x.to_string());
expected.dedup();
let expect = tokens_to_string(&expected[..]);
let actual = self.this_token_to_string();
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(proc_macro_internals)]
#![feature(decl_macro)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
-#![deny(warnings)]
#![feature(const_fn)]
#![feature(custom_attribute)]
html_playground_url = "https://play.rust-lang.org/",
test(attr(deny(warnings))))]
#![deny(missing_docs)]
-#![deny(warnings)]
#![cfg_attr(windows, feature(libc))]
// Handle rustfmt skips
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
-#![deny(warnings)]
#![feature(asm)]
#![feature(fnbox)]
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
#![no_std]
#![unstable(feature = "panic_unwind", issue = "32837")]
-#![deny(warnings)]
#![feature(cfg_target_vendor)]
#![feature(link_cfg)]
// Set the stack size at link time on Windows. See rustc_driver::in_rustc_thread
// for the rationale.
+#[allow(unused_attributes)]
#[cfg_attr(all(windows, target_env = "msvc"), link_args = "/STACK:16777216")]
// We only build for msvc and gnu now, but we use a exhaustive condition here
// so we can expect either the stack size to be set or the build fails.
// CHECK: @VAR1 = constant <{ [4 x i8] }> <{ [4 x i8] c"\01\00\00\00" }>, section ".test_one"
#[no_mangle]
#[link_section = ".test_one"]
+#[cfg(target_endian = "little")]
pub static VAR1: u32 = 1;
+#[no_mangle]
+#[link_section = ".test_one"]
+#[cfg(target_endian = "big")]
+pub static VAR1: u32 = 0x01000000;
+
pub enum E {
A(u32),
B(f32)
let y: Box<_> = box &mut x;
let p = &y;
***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference
- //[mir]~^ ERROR cannot assign to immutable item `***p`
+ //[mir]~^ ERROR cannot assign to data in a `&` reference
drop(p);
}
static mut bar: isize = 1;
//~^ ERROR static variable `bar` should have an upper case name such as `BAR`
+#[no_mangle]
+pub static extern_foo: isize = 1; // OK, because #[no_mangle] supersedes the warning
+
fn main() { }
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(non_shorthand_field_patterns)]
+
+pub struct Value<A> { pub value: A }
+
+#[macro_export]
+macro_rules! pat {
+ ($a:pat) => {
+ Value { value: $a }
+ };
+}
+
+fn main() {
+ let pat!(value) = Value { value: () };
+}
B(u8, u16, u8),
}
+enum NicheFilledEnumWithInhabitedVariant {
+ A(&'static ()),
+ B(&'static (), !),
+ C,
+}
+
pub fn main() {
assert_eq!(size_of::<u8>(), 1 as usize);
assert_eq!(size_of::<u32>(), 4 as usize);
assert_eq!(size_of::<e3>(), 4 as usize);
assert_eq!(size_of::<ReorderedStruct>(), 4);
assert_eq!(size_of::<ReorderedEnum>(), 6);
+ assert_eq!(size_of::<NicheFilledEnumWithInhabitedVariant>(), size_of::<&'static ()>());
}
// ignore-emscripten
// ignore-powerpc
// ignore-sparc
+// ignore-mips
#![feature(asm)]
error[E0384]: cannot assign twice to immutable variable `x`
- --> $DIR/asm-out-assign-imm.rs:29:9
+ --> $DIR/asm-out-assign-imm.rs:30:9
|
LL | x = 1;
| ----- first assignment to `x`
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Regression test for #16223: without NLL the `if let` construct together with
+// the nested box-structure of `Root` causes an unwanted collateral move.
+
+// The exact error prevented here is:
+//
+// error[E0382]: use of collaterally moved value: `(root.boxed.rhs as SomeVariant::B).0`
+// --> src/main.rs:55:29
+// |
+// 56 | lhs: SomeVariant::A(a),
+// | - value moved here
+// 57 | rhs: SomeVariant::B(b),
+// | ^ value used here after move
+// |
+// = note: move occurs because the value has type `A`, which does not implement the `Copy` trait
+
+// must-compile-successfully
+
+#![feature(nll)]
+#![feature(box_patterns)]
+
+struct Root {
+ boxed: Box<SetOfVariants>,
+}
+
+struct SetOfVariants {
+ lhs: SomeVariant,
+ rhs: SomeVariant,
+}
+
+enum SomeVariant {
+ A(A),
+ B(B),
+}
+
+struct A(String);
+struct B(String);
+
+fn main() {
+ let root = Root {
+ boxed: Box::new(SetOfVariants {
+ lhs: SomeVariant::A(A(String::from("This is A"))),
+ rhs: SomeVariant::B(B(String::from("This is B"))),
+ }),
+ };
+ if let box SetOfVariants {
+ lhs: SomeVariant::A(a),
+ rhs: SomeVariant::B(b),
+ } = root.boxed
+ {
+ println!("a = {}", a.0);
+ println!("b = {}", b.0);
+ }
+}
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+#![feature(nll)]
+struct FancyNum {
+ num: u8,
+}
+
+fn main() {
+ let mut fancy = FancyNum{ num: 5 };
+ let fancy_ref = &(&mut fancy);
+ fancy_ref.num = 6; //~ ERROR E0594
+ println!("{}", fancy_ref.num);
+}
--- /dev/null
+error[E0594]: cannot assign to data in a `&` reference
+ --> $DIR/issue-47388.rs:18:5
+ |
+LL | let fancy_ref = &(&mut fancy);
+ | ------------- help: consider changing this to be a mutable reference: `&mut`
+LL | fancy_ref.num = 6; //~ ERROR E0594
+ | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
// ignore-aarch64
// ignore-wasm
// ignore-emscripten
+// ignore-mips
+// ignore-powerpc
+// ignore-s390x
#![feature(target_feature)]
warning: #[target_feature = ".."] is deprecated and will eventually be removed, use #[target_feature(enable = "..")] instead
- --> $DIR/target-feature-wrong.rs:18:1
+ --> $DIR/target-feature-wrong.rs:21:1
|
LL | #[target_feature = "+sse2"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: the feature named `foo` is not valid for this target
- --> $DIR/target-feature-wrong.rs:20:18
+ --> $DIR/target-feature-wrong.rs:23:18
|
LL | #[target_feature(enable = "foo")]
| ^^^^^^^^^^^^^^
error: #[target_feature(..)] only accepts sub-keys of `enable` currently
- --> $DIR/target-feature-wrong.rs:22:18
+ --> $DIR/target-feature-wrong.rs:25:18
|
LL | #[target_feature(bar)]
| ^^^
error: #[target_feature(..)] only accepts sub-keys of `enable` currently
- --> $DIR/target-feature-wrong.rs:24:18
+ --> $DIR/target-feature-wrong.rs:27:18
|
LL | #[target_feature(disable = "baz")]
| ^^^^^^^^^^^^^^^
error: #[target_feature(..)] can only be applied to `unsafe` function
- --> $DIR/target-feature-wrong.rs:28:1
+ --> $DIR/target-feature-wrong.rs:31:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: attribute should be applied to a function
- --> $DIR/target-feature-wrong.rs:32:1
+ --> $DIR/target-feature-wrong.rs:35:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| -------------- not a function
error: cannot use #[inline(always)] with #[target_feature]
- --> $DIR/target-feature-wrong.rs:36:1
+ --> $DIR/target-feature-wrong.rs:39:1
|
LL | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
fn has_cfg_prefix(&self, line: &str, prefix: &str) -> bool {
// returns whether this line contains this prefix or not. For prefix
// "ignore", returns true if line says "ignore-x86_64", "ignore-arch",
- // "ignore-andorid" etc.
+ // "ignore-android" etc.
line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-')
}
// except according to those terms.
#![feature(link_args)]
+
+#[allow(unused_attributes)]
// Set the stack size at link time on Windows. See rustc_driver::in_rustc_thread
// for the rationale.
#[cfg_attr(all(windows, target_env = "msvc"), link_args = "/STACK:16777216")]
//! This library contains the tidy lints and exposes it
//! to be used by tools.
-#![deny(warnings)]
-
extern crate serde;
extern crate serde_json;
#[macro_use]