Auto merge of #55095 - Manishearth:rollup, r=Manishearth
Rollup of 11 pull requests Successful merges: - #54820 (Closes #54538: `unused_patterns` lint) - #54963 (Cleanup rustc/session) - #54991 (add test for #23189) - #55025 (Add missing lifetime fragment specifier to error message.) - #55047 (doc: make core::fmt::Error example more simple) - #55048 (Don't collect to vectors where unnecessary) - #55060 (clarify pointer add/sub function safety concerns) - #55062 (Make EvalContext::step public again) - #55066 (Fix incorrect link in println! documentation) - #55081 (Deduplicate tests) - #55088 (Update rustc documentation link) Failed merges: r? @ghost
This commit is contained in:
@@ -646,7 +646,7 @@ are:
|
|||||||
* Don't be afraid to ask! The Rust community is friendly and helpful.
|
* Don't be afraid to ask! The Rust community is friendly and helpful.
|
||||||
|
|
||||||
[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html
|
[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html
|
||||||
[gdfrustc]: http://manishearth.github.io/rust-internals-docs/rustc/
|
[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
|
||||||
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
|
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
|
||||||
[rif]: http://internals.rust-lang.org
|
[rif]: http://internals.rust-lang.org
|
||||||
[rr]: https://doc.rust-lang.org/book/README.html
|
[rr]: https://doc.rust-lang.org/book/README.html
|
||||||
|
|||||||
@@ -96,9 +96,8 @@ pub type Result = result::Result<(), Error>;
|
|||||||
/// use std::fmt::{self, write};
|
/// use std::fmt::{self, write};
|
||||||
///
|
///
|
||||||
/// let mut output = String::new();
|
/// let mut output = String::new();
|
||||||
/// match write(&mut output, format_args!("Hello {}!", "world")) {
|
/// if let Err(fmt::Error) = write(&mut output, format_args!("Hello {}!", "world")) {
|
||||||
/// Err(fmt::Error) => panic!("An error occurred"),
|
/// panic!("An error occurred");
|
||||||
/// _ => (),
|
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|||||||
@@ -1037,7 +1037,7 @@ impl<T: ?Sized> *const T {
|
|||||||
/// Behavior:
|
/// Behavior:
|
||||||
///
|
///
|
||||||
/// * Both the starting and resulting pointer must be either in bounds or one
|
/// * Both the starting and resulting pointer must be either in bounds or one
|
||||||
/// byte past the end of *the same* allocated object.
|
/// byte past the end of the same allocated object.
|
||||||
///
|
///
|
||||||
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
||||||
///
|
///
|
||||||
@@ -1255,7 +1255,7 @@ impl<T: ?Sized> *const T {
|
|||||||
/// Behavior:
|
/// Behavior:
|
||||||
///
|
///
|
||||||
/// * Both the starting and resulting pointer must be either in bounds or one
|
/// * Both the starting and resulting pointer must be either in bounds or one
|
||||||
/// byte past the end of an allocated object.
|
/// byte past the end of the same allocated object.
|
||||||
///
|
///
|
||||||
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
||||||
///
|
///
|
||||||
@@ -1312,7 +1312,7 @@ impl<T: ?Sized> *const T {
|
|||||||
/// Behavior:
|
/// Behavior:
|
||||||
///
|
///
|
||||||
/// * Both the starting and resulting pointer must be either in bounds or one
|
/// * Both the starting and resulting pointer must be either in bounds or one
|
||||||
/// byte past the end of an allocated object.
|
/// byte past the end of the same allocated object.
|
||||||
///
|
///
|
||||||
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
|
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
|
||||||
///
|
///
|
||||||
@@ -1657,7 +1657,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// Behavior:
|
/// Behavior:
|
||||||
///
|
///
|
||||||
/// * Both the starting and resulting pointer must be either in bounds or one
|
/// * Both the starting and resulting pointer must be either in bounds or one
|
||||||
/// byte past the end of *the same* allocated object.
|
/// byte past the end of the same allocated object.
|
||||||
///
|
///
|
||||||
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
||||||
///
|
///
|
||||||
@@ -1893,7 +1893,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// Behavior:
|
/// Behavior:
|
||||||
///
|
///
|
||||||
/// * Both the starting and resulting pointer must be either in bounds or one
|
/// * Both the starting and resulting pointer must be either in bounds or one
|
||||||
/// byte past the end of an allocated object.
|
/// byte past the end of the same allocated object.
|
||||||
///
|
///
|
||||||
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
|
||||||
///
|
///
|
||||||
@@ -1950,7 +1950,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// Behavior:
|
/// Behavior:
|
||||||
///
|
///
|
||||||
/// * Both the starting and resulting pointer must be either in bounds or one
|
/// * Both the starting and resulting pointer must be either in bounds or one
|
||||||
/// byte past the end of an allocated object.
|
/// byte past the end of the same allocated object.
|
||||||
///
|
///
|
||||||
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
|
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ use util::nodemap::{DefIdMap, NodeMap};
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::iter;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
@@ -3888,9 +3887,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
.collect::<P<[hir::Field]>>();
|
.collect::<P<[hir::Field]>>();
|
||||||
|
|
||||||
let is_unit = fields.is_empty();
|
let is_unit = fields.is_empty();
|
||||||
let struct_path = iter::once("ops")
|
let struct_path = ["ops", path];
|
||||||
.chain(iter::once(path))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
|
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
|
||||||
let struct_path = hir::QPath::Resolved(None, P(struct_path));
|
let struct_path = hir::QPath::Resolved(None, P(struct_path));
|
||||||
|
|
||||||
|
|||||||
@@ -490,10 +490,10 @@ pub enum Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn filestem(&self) -> String {
|
pub fn filestem(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap().to_string(),
|
Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap(),
|
||||||
Input::Str { .. } => "rust_out".to_string(),
|
Input::Str { .. } => "rust_out",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,7 +765,6 @@ macro_rules! options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> dep_tracking::DepTrackingHash for $struct_name {
|
impl<'a> dep_tracking::DepTrackingHash for $struct_name {
|
||||||
|
|
||||||
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
|
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
|
||||||
let mut sub_hashes = BTreeMap::new();
|
let mut sub_hashes = BTreeMap::new();
|
||||||
$({
|
$({
|
||||||
@@ -1313,13 +1312,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||||||
profile: bool = (false, parse_bool, [TRACKED],
|
profile: bool = (false, parse_bool, [TRACKED],
|
||||||
"insert profiling code"),
|
"insert profiling code"),
|
||||||
pgo_gen: Option<String> = (None, parse_opt_string, [TRACKED],
|
pgo_gen: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||||
"Generate PGO profile data, to a given file, or to the default \
|
"Generate PGO profile data, to a given file, or to the default location if it's empty."),
|
||||||
location if it's empty."),
|
|
||||||
pgo_use: String = (String::new(), parse_string, [TRACKED],
|
pgo_use: String = (String::new(), parse_string, [TRACKED],
|
||||||
"Use PGO profile data from the given profile file."),
|
"Use PGO profile data from the given profile file."),
|
||||||
disable_instrumentation_preinliner: bool =
|
disable_instrumentation_preinliner: bool = (false, parse_bool, [TRACKED],
|
||||||
(false, parse_bool, [TRACKED], "Disable the instrumentation pre-inliner, \
|
"Disable the instrumentation pre-inliner, useful for profiling / PGO."),
|
||||||
useful for profiling / PGO."),
|
|
||||||
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
|
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
|
||||||
"choose which RELRO level to use"),
|
"choose which RELRO level to use"),
|
||||||
nll_subminimal_causes: bool = (false, parse_bool, [UNTRACKED],
|
nll_subminimal_causes: bool = (false, parse_bool, [UNTRACKED],
|
||||||
@@ -1409,6 +1406,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||||||
let atomic_cas = sess.target.target.options.atomic_cas;
|
let atomic_cas = sess.target.target.options.atomic_cas;
|
||||||
|
|
||||||
let mut ret = FxHashSet::default();
|
let mut ret = FxHashSet::default();
|
||||||
|
ret.reserve(6); // the minimum number of insertions
|
||||||
// Target bindings.
|
// Target bindings.
|
||||||
ret.insert((Symbol::intern("target_os"), Some(Symbol::intern(os))));
|
ret.insert((Symbol::intern("target_os"), Some(Symbol::intern(os))));
|
||||||
if let Some(ref fam) = sess.target.target.options.target_family {
|
if let Some(ref fam) = sess.target.target.options.target_family {
|
||||||
@@ -1455,7 +1453,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||||||
if sess.opts.crate_types.contains(&CrateType::ProcMacro) {
|
if sess.opts.crate_types.contains(&CrateType::ProcMacro) {
|
||||||
ret.insert((Symbol::intern("proc_macro"), None));
|
ret.insert((Symbol::intern("proc_macro"), None));
|
||||||
}
|
}
|
||||||
return ret;
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_configuration(sess: &Session, mut user_cfg: ast::CrateConfig) -> ast::CrateConfig {
|
pub fn build_configuration(sess: &Session, mut user_cfg: ast::CrateConfig) -> ast::CrateConfig {
|
||||||
@@ -1471,15 +1469,12 @@ pub fn build_configuration(sess: &Session, mut user_cfg: ast::CrateConfig) -> as
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
|
pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
|
||||||
let target = match Target::search(&opts.target_triple) {
|
let target = Target::search(&opts.target_triple).unwrap_or_else(|e| {
|
||||||
Ok(t) => t,
|
|
||||||
Err(e) => {
|
|
||||||
sp.struct_fatal(&format!("Error loading target specification: {}", e))
|
sp.struct_fatal(&format!("Error loading target specification: {}", e))
|
||||||
.help("Use `--print target-list` for a list of built-in targets")
|
.help("Use `--print target-list` for a list of built-in targets")
|
||||||
.emit();
|
.emit();
|
||||||
FatalError.raise();
|
FatalError.raise();
|
||||||
}
|
});
|
||||||
};
|
|
||||||
|
|
||||||
let (isize_ty, usize_ty) = match &target.target_pointer_width[..] {
|
let (isize_ty, usize_ty) = match &target.target_pointer_width[..] {
|
||||||
"16" => (ast::IntTy::I16, ast::UintTy::U16),
|
"16" => (ast::IntTy::I16, ast::UintTy::U16),
|
||||||
@@ -1502,7 +1497,6 @@ pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
|
|||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum OptionStability {
|
pub enum OptionStability {
|
||||||
Stable,
|
Stable,
|
||||||
|
|
||||||
Unstable,
|
Unstable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1845,9 +1839,8 @@ pub fn build_session_options_and_crate_config(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let edition = match matches.opt_str("edition") {
|
let edition = match matches.opt_str("edition") {
|
||||||
Some(arg) => match Edition::from_str(&arg){
|
Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_|
|
||||||
Ok(edition) => edition,
|
early_error(
|
||||||
Err(_) => early_error(
|
|
||||||
ErrorOutputType::default(),
|
ErrorOutputType::default(),
|
||||||
&format!(
|
&format!(
|
||||||
"argument for --edition must be one of: \
|
"argument for --edition must be one of: \
|
||||||
@@ -1856,7 +1849,7 @@ pub fn build_session_options_and_crate_config(
|
|||||||
arg
|
arg
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
}
|
),
|
||||||
None => DEFAULT_EDITION,
|
None => DEFAULT_EDITION,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1925,9 +1918,8 @@ pub fn build_session_options_and_crate_config(
|
|||||||
for output_type in list.split(',') {
|
for output_type in list.split(',') {
|
||||||
let mut parts = output_type.splitn(2, '=');
|
let mut parts = output_type.splitn(2, '=');
|
||||||
let shorthand = parts.next().unwrap();
|
let shorthand = parts.next().unwrap();
|
||||||
let output_type = match OutputType::from_shorthand(shorthand) {
|
let output_type = OutputType::from_shorthand(shorthand).unwrap_or_else(||
|
||||||
Some(output_type) => output_type,
|
early_error(
|
||||||
None => early_error(
|
|
||||||
error_format,
|
error_format,
|
||||||
&format!(
|
&format!(
|
||||||
"unknown emission type: `{}` - expected one of: {}",
|
"unknown emission type: `{}` - expected one of: {}",
|
||||||
@@ -1935,7 +1927,7 @@ pub fn build_session_options_and_crate_config(
|
|||||||
OutputType::shorthands_display(),
|
OutputType::shorthands_display(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
};
|
);
|
||||||
let path = parts.next().map(PathBuf::from);
|
let path = parts.next().map(PathBuf::from);
|
||||||
output_types.insert(output_type, path);
|
output_types.insert(output_type, path);
|
||||||
}
|
}
|
||||||
@@ -2063,12 +2055,8 @@ pub fn build_session_options_and_crate_config(
|
|||||||
let target_triple = if let Some(target) = matches.opt_str("target") {
|
let target_triple = if let Some(target) = matches.opt_str("target") {
|
||||||
if target.ends_with(".json") {
|
if target.ends_with(".json") {
|
||||||
let path = Path::new(&target);
|
let path = Path::new(&target);
|
||||||
match TargetTriple::from_path(&path) {
|
TargetTriple::from_path(&path).unwrap_or_else(|_|
|
||||||
Ok(triple) => triple,
|
early_error(error_format, &format!("target file {:?} does not exist", path)))
|
||||||
Err(_) => {
|
|
||||||
early_error(error_format, &format!("target file {:?} does not exist", path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
TargetTriple::TargetTriple(target)
|
TargetTriple::TargetTriple(target)
|
||||||
}
|
}
|
||||||
@@ -2169,7 +2157,7 @@ pub fn build_session_options_and_crate_config(
|
|||||||
let mut name_parts = name.splitn(2, ':');
|
let mut name_parts = name.splitn(2, ':');
|
||||||
let name = name_parts.next().unwrap();
|
let name = name_parts.next().unwrap();
|
||||||
let new_name = name_parts.next();
|
let new_name = name_parts.next();
|
||||||
(name.to_string(), new_name.map(|n| n.to_string()), kind)
|
(name.to_owned(), new_name.map(|n| n.to_owned()), kind)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@@ -2223,10 +2211,8 @@ pub fn build_session_options_and_crate_config(
|
|||||||
let mut externs: BTreeMap<_, BTreeSet<_>> = BTreeMap::new();
|
let mut externs: BTreeMap<_, BTreeSet<_>> = BTreeMap::new();
|
||||||
for arg in &matches.opt_strs("extern") {
|
for arg in &matches.opt_strs("extern") {
|
||||||
let mut parts = arg.splitn(2, '=');
|
let mut parts = arg.splitn(2, '=');
|
||||||
let name = match parts.next() {
|
let name = parts.next().unwrap_or_else(||
|
||||||
Some(s) => s,
|
early_error(error_format, "--extern value must not be empty"));
|
||||||
None => early_error(error_format, "--extern value must not be empty"),
|
|
||||||
};
|
|
||||||
let location = parts.next().map(|s| s.to_string());
|
let location = parts.next().map(|s| s.to_string());
|
||||||
if location.is_none() && !is_unstable_enabled {
|
if location.is_none() && !is_unstable_enabled {
|
||||||
early_error(
|
early_error(
|
||||||
@@ -2237,7 +2223,7 @@ pub fn build_session_options_and_crate_config(
|
|||||||
};
|
};
|
||||||
|
|
||||||
externs
|
externs
|
||||||
.entry(name.to_string())
|
.entry(name.to_owned())
|
||||||
.or_default()
|
.or_default()
|
||||||
.insert(location);
|
.insert(location);
|
||||||
}
|
}
|
||||||
@@ -2308,9 +2294,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
|
|||||||
"cdylib" => CrateType::Cdylib,
|
"cdylib" => CrateType::Cdylib,
|
||||||
"bin" => CrateType::Executable,
|
"bin" => CrateType::Executable,
|
||||||
"proc-macro" => CrateType::ProcMacro,
|
"proc-macro" => CrateType::ProcMacro,
|
||||||
_ => {
|
_ => return Err(format!("unknown crate type: `{}`", part))
|
||||||
return Err(format!("unknown crate type: `{}`", part));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if !crate_types.contains(&new_part) {
|
if !crate_types.contains(&new_part) {
|
||||||
crate_types.push(new_part)
|
crate_types.push(new_part)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ impl<'a> FileSearch<'a> {
|
|||||||
F: FnMut(&Path, PathKind)
|
F: FnMut(&Path, PathKind)
|
||||||
{
|
{
|
||||||
let mut visited_dirs = FxHashSet::default();
|
let mut visited_dirs = FxHashSet::default();
|
||||||
|
visited_dirs.reserve(self.search_paths.paths.len() + 1);
|
||||||
for (path, kind) in self.search_paths.iter(self.kind) {
|
for (path, kind) in self.search_paths.iter(self.kind) {
|
||||||
f(path, kind);
|
f(path, kind);
|
||||||
visited_dirs.insert(path.to_path_buf());
|
visited_dirs.insert(path.to_path_buf());
|
||||||
@@ -160,7 +160,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
|
|||||||
match env::current_exe() {
|
match env::current_exe() {
|
||||||
Ok(exe) => {
|
Ok(exe) => {
|
||||||
match canonicalize(Some(exe)) {
|
match canonicalize(Some(exe)) {
|
||||||
Some(mut p) => { p.pop(); p.pop(); return p; },
|
Some(mut p) => { p.pop(); p.pop(); p },
|
||||||
None => bug!("can't determine value for sysroot")
|
None => bug!("can't determine value for sysroot")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,15 +178,6 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
|
|||||||
// If --libdir is set during configuration to the value other than
|
// If --libdir is set during configuration to the value other than
|
||||||
// "lib" (i.e. non-default), this value is used (see issue #16552).
|
// "lib" (i.e. non-default), this value is used (see issue #16552).
|
||||||
|
|
||||||
match option_env!("CFG_LIBDIR_RELATIVE") {
|
|
||||||
Some(libdir) if libdir != "lib" => return libdir.into(),
|
|
||||||
_ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
|
|
||||||
return PRIMARY_LIB_DIR.into();
|
|
||||||
} else {
|
|
||||||
return SECONDARY_LIB_DIR.into();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
const PRIMARY_LIB_DIR: &'static str = "lib64";
|
const PRIMARY_LIB_DIR: &'static str = "lib64";
|
||||||
|
|
||||||
@@ -194,6 +185,15 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
|
|||||||
const PRIMARY_LIB_DIR: &'static str = "lib32";
|
const PRIMARY_LIB_DIR: &'static str = "lib32";
|
||||||
|
|
||||||
const SECONDARY_LIB_DIR: &'static str = "lib";
|
const SECONDARY_LIB_DIR: &'static str = "lib";
|
||||||
|
|
||||||
|
match option_env!("CFG_LIBDIR_RELATIVE") {
|
||||||
|
Some(libdir) if libdir != "lib" => libdir.into(),
|
||||||
|
_ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() {
|
||||||
|
PRIMARY_LIB_DIR.into()
|
||||||
|
} else {
|
||||||
|
SECONDARY_LIB_DIR.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The name of rustc's own place to organize libraries.
|
// The name of rustc's own place to organize libraries.
|
||||||
|
|||||||
@@ -727,15 +727,9 @@ impl Session {
|
|||||||
pub fn set_incr_session_load_dep_graph(&self, load: bool) {
|
pub fn set_incr_session_load_dep_graph(&self, load: bool) {
|
||||||
let mut incr_comp_session = self.incr_comp_session.borrow_mut();
|
let mut incr_comp_session = self.incr_comp_session.borrow_mut();
|
||||||
|
|
||||||
match *incr_comp_session {
|
if let IncrCompSession::Active { ref mut load_dep_graph, .. } = *incr_comp_session {
|
||||||
IncrCompSession::Active {
|
|
||||||
ref mut load_dep_graph,
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
*load_dep_graph = load;
|
*load_dep_graph = load;
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn incr_session_load_dep_graph(&self) -> bool {
|
pub fn incr_session_load_dep_graph(&self) -> bool {
|
||||||
@@ -872,9 +866,9 @@ impl Session {
|
|||||||
/// This expends fuel if applicable, and records fuel if applicable.
|
/// This expends fuel if applicable, and records fuel if applicable.
|
||||||
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
|
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
|
||||||
let mut ret = true;
|
let mut ret = true;
|
||||||
match self.optimization_fuel_crate {
|
if let Some(ref c) = self.optimization_fuel_crate {
|
||||||
Some(ref c) if c == crate_name => {
|
if c == crate_name {
|
||||||
assert!(self.query_threads() == 1);
|
assert_eq!(self.query_threads(), 1);
|
||||||
let fuel = self.optimization_fuel_limit.get();
|
let fuel = self.optimization_fuel_limit.get();
|
||||||
ret = fuel != 0;
|
ret = fuel != 0;
|
||||||
if fuel == 0 && !self.out_of_fuel.get() {
|
if fuel == 0 && !self.out_of_fuel.get() {
|
||||||
@@ -884,14 +878,12 @@ impl Session {
|
|||||||
self.optimization_fuel_limit.set(fuel - 1);
|
self.optimization_fuel_limit.set(fuel - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
match self.print_fuel_crate {
|
if let Some(ref c) = self.print_fuel_crate {
|
||||||
Some(ref c) if c == crate_name => {
|
if c == crate_name {
|
||||||
assert!(self.query_threads() == 1);
|
assert_eq!(self.query_threads(), 1);
|
||||||
self.print_fuel.set(self.print_fuel.get() + 1);
|
self.print_fuel.set(self.print_fuel.get() + 1);
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
@@ -1108,14 +1100,11 @@ pub fn build_session_(
|
|||||||
source_map: Lrc<source_map::SourceMap>,
|
source_map: Lrc<source_map::SourceMap>,
|
||||||
) -> Session {
|
) -> Session {
|
||||||
let host_triple = TargetTriple::from_triple(config::host_triple());
|
let host_triple = TargetTriple::from_triple(config::host_triple());
|
||||||
let host = match Target::search(&host_triple) {
|
let host = Target::search(&host_triple).unwrap_or_else(|e|
|
||||||
Ok(t) => t,
|
|
||||||
Err(e) => {
|
|
||||||
span_diagnostic
|
span_diagnostic
|
||||||
.fatal(&format!("Error loading host specification: {}", e))
|
.fatal(&format!("Error loading host specification: {}", e))
|
||||||
.raise();
|
.raise()
|
||||||
}
|
);
|
||||||
};
|
|
||||||
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
|
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
|
||||||
|
|
||||||
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map);
|
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map);
|
||||||
@@ -1135,12 +1124,11 @@ pub fn build_session_(
|
|||||||
let print_fuel_crate = sopts.debugging_opts.print_fuel.clone();
|
let print_fuel_crate = sopts.debugging_opts.print_fuel.clone();
|
||||||
let print_fuel = LockCell::new(0);
|
let print_fuel = LockCell::new(0);
|
||||||
|
|
||||||
let working_dir = match env::current_dir() {
|
let working_dir = env::current_dir().unwrap_or_else(|e|
|
||||||
Ok(dir) => dir,
|
p_s.span_diagnostic
|
||||||
Err(e) => p_s.span_diagnostic
|
|
||||||
.fatal(&format!("Current directory is invalid: {}", e))
|
.fatal(&format!("Current directory is invalid: {}", e))
|
||||||
.raise(),
|
.raise()
|
||||||
};
|
);
|
||||||
let working_dir = file_path_mapping.map_prefix(working_dir);
|
let working_dir = file_path_mapping.map_prefix(working_dir);
|
||||||
|
|
||||||
let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
|
let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use session::{early_error, config};
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct SearchPaths {
|
pub struct SearchPaths {
|
||||||
paths: Vec<(PathKind, PathBuf)>,
|
crate paths: Vec<(PathKind, PathBuf)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Iter<'a> {
|
pub struct Iter<'a> {
|
||||||
|
|||||||
@@ -1657,7 +1657,7 @@ pub fn build_output_filenames(
|
|||||||
.crate_name
|
.crate_name
|
||||||
.clone()
|
.clone()
|
||||||
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
|
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
|
||||||
.unwrap_or_else(|| input.filestem());
|
.unwrap_or_else(|| input.filestem().to_owned());
|
||||||
|
|
||||||
OutputFilenames {
|
OutputFilenames {
|
||||||
out_directory: dirpath,
|
out_directory: dirpath,
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ declare_lint! {
|
|||||||
pub struct UnusedParens;
|
pub struct UnusedParens;
|
||||||
|
|
||||||
impl UnusedParens {
|
impl UnusedParens {
|
||||||
fn check_unused_parens_core(&self,
|
fn check_unused_parens_expr(&self,
|
||||||
cx: &EarlyContext,
|
cx: &EarlyContext,
|
||||||
value: &ast::Expr,
|
value: &ast::Expr,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
@@ -281,15 +281,28 @@ impl UnusedParens {
|
|||||||
let necessary = struct_lit_needs_parens &&
|
let necessary = struct_lit_needs_parens &&
|
||||||
parser::contains_exterior_struct_lit(&inner);
|
parser::contains_exterior_struct_lit(&inner);
|
||||||
if !necessary {
|
if !necessary {
|
||||||
|
let pattern = pprust::expr_to_string(value);
|
||||||
|
Self::remove_outer_parens(cx, value.span, &pattern, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_unused_parens_pat(&self,
|
||||||
|
cx: &EarlyContext,
|
||||||
|
value: &ast::Pat,
|
||||||
|
msg: &str) {
|
||||||
|
if let ast::PatKind::Paren(_) = value.node {
|
||||||
|
let pattern = pprust::pat_to_string(value);
|
||||||
|
Self::remove_outer_parens(cx, value.span, &pattern, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_outer_parens(cx: &EarlyContext, span: Span, pattern: &str, msg: &str) {
|
||||||
let span_msg = format!("unnecessary parentheses around {}", msg);
|
let span_msg = format!("unnecessary parentheses around {}", msg);
|
||||||
let mut err = cx.struct_span_lint(UNUSED_PARENS,
|
let mut err = cx.struct_span_lint(UNUSED_PARENS, span, &span_msg);
|
||||||
value.span,
|
|
||||||
&span_msg);
|
|
||||||
// Remove exactly one pair of parentheses (rather than naïvely
|
|
||||||
// stripping all paren characters)
|
|
||||||
let mut ate_left_paren = false;
|
let mut ate_left_paren = false;
|
||||||
let mut ate_right_paren = false;
|
let mut ate_right_paren = false;
|
||||||
let parens_removed = pprust::expr_to_string(value)
|
let parens_removed = pattern
|
||||||
.trim_matches(|c| {
|
.trim_matches(|c| {
|
||||||
match c {
|
match c {
|
||||||
'(' => {
|
'(' => {
|
||||||
@@ -312,7 +325,7 @@ impl UnusedParens {
|
|||||||
}
|
}
|
||||||
}).to_owned();
|
}).to_owned();
|
||||||
err.span_suggestion_short_with_applicability(
|
err.span_suggestion_short_with_applicability(
|
||||||
value.span,
|
span,
|
||||||
"remove these parentheses",
|
"remove these parentheses",
|
||||||
parens_removed,
|
parens_removed,
|
||||||
Applicability::MachineApplicable
|
Applicability::MachineApplicable
|
||||||
@@ -320,8 +333,6 @@ impl UnusedParens {
|
|||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LintPass for UnusedParens {
|
impl LintPass for UnusedParens {
|
||||||
fn get_lints(&self) -> LintArray {
|
fn get_lints(&self) -> LintArray {
|
||||||
@@ -349,7 +360,9 @@ impl EarlyLintPass for UnusedParens {
|
|||||||
// first "argument" is self (which sometimes needs parens)
|
// first "argument" is self (which sometimes needs parens)
|
||||||
MethodCall(_, ref args) => (&args[1..], "method"),
|
MethodCall(_, ref args) => (&args[1..], "method"),
|
||||||
// actual catch-all arm
|
// actual catch-all arm
|
||||||
_ => { return; }
|
_ => {
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// Don't lint if this is a nested macro expansion: otherwise, the lint could
|
// Don't lint if this is a nested macro expansion: otherwise, the lint could
|
||||||
// trigger in situations that macro authors shouldn't have to care about, e.g.,
|
// trigger in situations that macro authors shouldn't have to care about, e.g.,
|
||||||
@@ -362,18 +375,32 @@ impl EarlyLintPass for UnusedParens {
|
|||||||
}
|
}
|
||||||
let msg = format!("{} argument", call_kind);
|
let msg = format!("{} argument", call_kind);
|
||||||
for arg in args_to_check {
|
for arg in args_to_check {
|
||||||
self.check_unused_parens_core(cx, arg, &msg, false);
|
self.check_unused_parens_expr(cx, arg, &msg, false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.check_unused_parens_core(cx, &value, msg, struct_lit_needs_parens);
|
self.check_unused_parens_expr(cx, &value, msg, struct_lit_needs_parens);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_pat(&mut self, cx: &EarlyContext, p: &ast::Pat) {
|
||||||
|
use ast::PatKind::{Paren, Range};
|
||||||
|
// The lint visitor will visit each subpattern of `p`. We do not want to lint any range
|
||||||
|
// pattern no matter where it occurs in the pattern. For something like `&(a..=b)`, there
|
||||||
|
// is a recursive `check_pat` on `a` and `b`, but we will assume that if there are
|
||||||
|
// unnecessry parens they serve a purpose of readability.
|
||||||
|
if let Paren(ref pat) = p.node {
|
||||||
|
match pat.node {
|
||||||
|
Range(..) => {}
|
||||||
|
_ => self.check_unused_parens_pat(cx, &p, "pattern")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
|
fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
|
||||||
if let ast::StmtKind::Local(ref local) = s.node {
|
if let ast::StmtKind::Local(ref local) = s.node {
|
||||||
if let Some(ref value) = local.init {
|
if let Some(ref value) = local.init {
|
||||||
self.check_unused_parens_core(cx, &value, "assigned value", false);
|
self.check_unused_parens_expr(cx, &value, "assigned value", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true as long as there are more things to do.
|
/// Returns true as long as there are more things to do.
|
||||||
fn step(&mut self) -> EvalResult<'tcx, bool> {
|
///
|
||||||
|
/// This is used by [priroda](https://github.com/oli-obk/priroda)
|
||||||
|
pub fn step(&mut self) -> EvalResult<'tcx, bool> {
|
||||||
if self.stack.is_empty() {
|
if self.stack.is_empty() {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,8 +306,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
|
|||||||
let wf_conditions = iter::once(ty::Binder::dummy(trait_pred.lower()))
|
let wf_conditions = iter::once(ty::Binder::dummy(trait_pred.lower()))
|
||||||
.chain(
|
.chain(
|
||||||
where_clauses
|
where_clauses
|
||||||
.iter()
|
.into_iter()
|
||||||
.cloned()
|
|
||||||
.map(|wc| wc.map_bound(|goal| goal.into_well_formed_goal()))
|
.map(|wc| wc.map_bound(|goal| goal.into_well_formed_goal()))
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -350,15 +349,13 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
|
|||||||
// `WC`
|
// `WC`
|
||||||
let where_clauses = tcx.predicates_of(def_id).predicates
|
let where_clauses = tcx.predicates_of(def_id).predicates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(wc, _)| wc.lower())
|
.map(|(wc, _)| wc.lower());
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
// `Implemented(A0: Trait<A1..An>) :- WC`
|
// `Implemented(A0: Trait<A1..An>) :- WC`
|
||||||
let clause = ProgramClause {
|
let clause = ProgramClause {
|
||||||
goal: trait_pred,
|
goal: trait_pred,
|
||||||
hypotheses: tcx.mk_goals(
|
hypotheses: tcx.mk_goals(
|
||||||
where_clauses
|
where_clauses
|
||||||
.into_iter()
|
|
||||||
.map(|wc| tcx.mk_goal(GoalKind::from_poly_domain_goal(wc, tcx))),
|
.map(|wc| tcx.mk_goal(GoalKind::from_poly_domain_goal(wc, tcx))),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
// field is of the found type, suggest such variants. See Issue
|
// field is of the found type, suggest such variants. See Issue
|
||||||
// #42764.
|
// #42764.
|
||||||
if let ty::Adt(expected_adt, substs) = expected.sty {
|
if let ty::Adt(expected_adt, substs) = expected.sty {
|
||||||
let compatible_variants = expected_adt.variants
|
let mut compatible_variants = expected_adt.variants
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|variant| variant.fields.len() == 1)
|
.filter(|variant| variant.fields.len() == 1)
|
||||||
.filter_map(|variant| {
|
.filter_map(|variant| {
|
||||||
@@ -127,12 +127,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).peekable();
|
||||||
|
|
||||||
if !compatible_variants.is_empty() {
|
if compatible_variants.peek().is_some() {
|
||||||
let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr));
|
let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr));
|
||||||
let suggestions = compatible_variants.iter()
|
let suggestions = compatible_variants.map(|v|
|
||||||
.map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>();
|
format!("{}({})", v, expr_text)).collect::<Vec<_>>();
|
||||||
err.span_suggestions_with_applicability(
|
err.span_suggestions_with_applicability(
|
||||||
expr.span,
|
expr.span,
|
||||||
"try using a variant of the expected type",
|
"try using a variant of the expected type",
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ macro_rules! print {
|
|||||||
///
|
///
|
||||||
/// [`format!`]: ../std/macro.format.html
|
/// [`format!`]: ../std/macro.format.html
|
||||||
/// [`std::fmt`]: ../std/fmt/index.html
|
/// [`std::fmt`]: ../std/fmt/index.html
|
||||||
/// [`eprintln!`]: ../std/macro.eprint.html
|
/// [`eprintln!`]: ../std/macro.eprintln.html
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if writing to `io::stdout` fails.
|
/// Panics if writing to `io::stdout` fails.
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ use std::collections::hash_map::Entry;
|
|||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use errors::Applicability;
|
use errors::Applicability;
|
||||||
|
|
||||||
|
const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
|
||||||
|
`ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, \
|
||||||
|
`path`, `meta`, `tt`, `item` and `vis`";
|
||||||
|
|
||||||
pub struct ParserAnyMacro<'a> {
|
pub struct ParserAnyMacro<'a> {
|
||||||
parser: Parser<'a>,
|
parser: Parser<'a>,
|
||||||
|
|
||||||
@@ -708,8 +712,7 @@ fn check_matcher_core(sess: &ParseSess,
|
|||||||
if let Err(bad_frag) = has_legal_fragment_specifier(sess, features, attrs, token) {
|
if let Err(bad_frag) = has_legal_fragment_specifier(sess, features, attrs, token) {
|
||||||
let msg = format!("invalid fragment specifier `{}`", bad_frag);
|
let msg = format!("invalid fragment specifier `{}`", bad_frag);
|
||||||
sess.span_diagnostic.struct_span_err(token.span(), &msg)
|
sess.span_diagnostic.struct_span_err(token.span(), &msg)
|
||||||
.help("valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, \
|
.help(VALID_FRAGMENT_NAMES_MSG)
|
||||||
`pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`")
|
|
||||||
.emit();
|
.emit();
|
||||||
// (This eliminates false positives and duplicates
|
// (This eliminates false positives and duplicates
|
||||||
// from error messages.)
|
// from error messages.)
|
||||||
@@ -938,9 +941,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result<bool, (String, &'
|
|||||||
},
|
},
|
||||||
"" => Ok(true), // keywords::Invalid
|
"" => Ok(true), // keywords::Invalid
|
||||||
_ => Err((format!("invalid fragment specifier `{}`", frag),
|
_ => Err((format!("invalid fragment specifier `{}`", frag),
|
||||||
"valid fragment specifiers are `ident`, `block`, \
|
VALID_FRAGMENT_NAMES_MSG))
|
||||||
`stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt`, \
|
|
||||||
`literal`, `item` and `vis`"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
// run-pass
|
// run-pass
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[allow(unused_parens)]
|
||||||
match 0 {
|
match 0 {
|
||||||
(pat) => assert_eq!(pat, 0)
|
(pat) => assert_eq!(pat, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ error: invalid fragment specifier `t_ty`
|
|||||||
LL | macro_rules! test { ($wrong:t_ty ..) => () }
|
LL | macro_rules! test { ($wrong:t_ty ..) => () }
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
|
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
//
|
//
|
||||||
@@ -7,13 +7,9 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
struct Ref<'a, 'b> {
|
|
||||||
a: &'a u32,
|
|
||||||
b: &'b u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn foo(mut x: Ref) {
|
mod module {}
|
||||||
x.a = x.b; //~ ERROR lifetime mismatch
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {
|
||||||
|
let _ = module { x: 0 }; //~ERROR expected struct
|
||||||
|
}
|
||||||
9
src/test/ui/issues/issue-23189.stderr
Normal file
9
src/test/ui/issues/issue-23189.stderr
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
error[E0574]: expected struct, variant or union type, found module `module`
|
||||||
|
--> $DIR/issue-23189.rs:14:13
|
||||||
|
|
|
||||||
|
LL | let _ = module { x: 0 }; //~ERROR expected struct
|
||||||
|
| ^^^^^^ not a struct, variant or union type
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0574`.
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
error: unsatisfied lifetime constraints
|
|
||||||
--> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:5
|
|
||||||
|
|
|
||||||
LL | fn foo(mut x: Ref) {
|
|
||||||
| -----
|
|
||||||
| |
|
|
||||||
| has type `Ref<'_, '1>`
|
|
||||||
| has type `Ref<'2, '_>`
|
|
||||||
LL | x.a = x.b; //~ ERROR lifetime mismatch
|
|
||||||
| ^^^^^^^^^ assignment requires that `'1` must outlive `'2`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
error[E0623]: lifetime mismatch
|
|
||||||
--> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:11
|
|
||||||
|
|
|
||||||
LL | fn foo(mut x: Ref) {
|
|
||||||
| ---
|
|
||||||
| |
|
|
||||||
| this type is declared with multiple lifetimes...
|
|
||||||
LL | x.a = x.b; //~ ERROR lifetime mismatch
|
|
||||||
| ^^^ ...but data with one lifetime flows into the other here
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0623`.
|
|
||||||
38
src/test/ui/lint/issue-54538-unused-parens-lint.rs
Normal file
38
src/test/ui/lint/issue-54538-unused-parens-lint.rs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// compile-pass
|
||||||
|
|
||||||
|
#![allow(unreachable_patterns)]
|
||||||
|
#![allow(unused_variables)]
|
||||||
|
#![warn(unused_parens)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
match 1 {
|
||||||
|
(_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
(y) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
(ref r) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
(e @ 1..=2) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||||
|
(1..=2) => {} // Non ambiguous range pattern should not warn
|
||||||
|
e @ (3..=4) => {} // Non ambiguous range pattern should not warn
|
||||||
|
}
|
||||||
|
|
||||||
|
match &1 {
|
||||||
|
(e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||||
|
&(_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
e @ &(1...2) => {} // Ambiguous range pattern should not warn
|
||||||
|
&(1..=2) => {} // Ambiguous range pattern should not warn
|
||||||
|
}
|
||||||
|
|
||||||
|
match &1 {
|
||||||
|
e @ &(1...2) | e @ &(3..=4) => {} // Complex ambiguous pattern should not warn
|
||||||
|
&_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/test/ui/lint/issue-54538-unused-parens-lint.stderr
Normal file
42
src/test/ui/lint/issue-54538-unused-parens-lint.stderr
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
warning: unnecessary parentheses around pattern
|
||||||
|
--> $DIR/issue-54538-unused-parens-lint.rs:19:9
|
||||||
|
|
|
||||||
|
LL | (_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
| ^^^ help: remove these parentheses
|
||||||
|
|
|
||||||
|
note: lint level defined here
|
||||||
|
--> $DIR/issue-54538-unused-parens-lint.rs:15:9
|
||||||
|
|
|
||||||
|
LL | #![warn(unused_parens)]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: unnecessary parentheses around pattern
|
||||||
|
--> $DIR/issue-54538-unused-parens-lint.rs:20:9
|
||||||
|
|
|
||||||
|
LL | (y) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
| ^^^ help: remove these parentheses
|
||||||
|
|
||||||
|
warning: unnecessary parentheses around pattern
|
||||||
|
--> $DIR/issue-54538-unused-parens-lint.rs:21:9
|
||||||
|
|
|
||||||
|
LL | (ref r) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
| ^^^^^^^ help: remove these parentheses
|
||||||
|
|
||||||
|
warning: unnecessary parentheses around pattern
|
||||||
|
--> $DIR/issue-54538-unused-parens-lint.rs:22:9
|
||||||
|
|
|
||||||
|
LL | (e @ 1..=2) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||||
|
| ^^^^^^^^^^^ help: remove these parentheses
|
||||||
|
|
||||||
|
warning: unnecessary parentheses around pattern
|
||||||
|
--> $DIR/issue-54538-unused-parens-lint.rs:28:9
|
||||||
|
|
|
||||||
|
LL | (e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||||
|
| ^^^^^^^^^^^^^^ help: remove these parentheses
|
||||||
|
|
||||||
|
warning: unnecessary parentheses around pattern
|
||||||
|
--> $DIR/issue-54538-unused-parens-lint.rs:29:10
|
||||||
|
|
|
||||||
|
LL | &(_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||||
|
| ^^^ help: remove these parentheses
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
// Copyright 2014–2017 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <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(nonstandard_style)]
|
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
fn CamelCase() {} //~ ERROR should have a snake
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
mod test {
|
|
||||||
fn CamelCase() {}
|
|
||||||
|
|
||||||
#[forbid(nonstandard_style)]
|
|
||||||
mod bad {
|
|
||||||
fn CamelCase() {} //~ ERROR should have a snake
|
|
||||||
|
|
||||||
static bad: isize = 1; //~ ERROR should have an upper
|
|
||||||
}
|
|
||||||
|
|
||||||
mod warn {
|
|
||||||
#![warn(nonstandard_style)]
|
|
||||||
|
|
||||||
fn CamelCase() {} //~ WARN should have a snake
|
|
||||||
|
|
||||||
struct snake_case; //~ WARN should have a camel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
error: function `CamelCase` should have a snake case name such as `camel_case`
|
|
||||||
--> $DIR/lint-group-style.rs:14:1
|
|
||||||
|
|
|
||||||
LL | fn CamelCase() {} //~ ERROR should have a snake
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: lint level defined here
|
|
||||||
--> $DIR/lint-group-style.rs:11:9
|
|
||||||
|
|
|
||||||
LL | #![deny(nonstandard_style)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
= note: #[deny(non_snake_case)] implied by #[deny(nonstandard_style)]
|
|
||||||
|
|
||||||
error: function `CamelCase` should have a snake case name such as `camel_case`
|
|
||||||
--> $DIR/lint-group-style.rs:22:9
|
|
||||||
|
|
|
||||||
LL | fn CamelCase() {} //~ ERROR should have a snake
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: lint level defined here
|
|
||||||
--> $DIR/lint-group-style.rs:20:14
|
|
||||||
|
|
|
||||||
LL | #[forbid(nonstandard_style)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
= note: #[forbid(non_snake_case)] implied by #[forbid(nonstandard_style)]
|
|
||||||
|
|
||||||
error: static variable `bad` should have an upper case name such as `BAD`
|
|
||||||
--> $DIR/lint-group-style.rs:24:9
|
|
||||||
|
|
|
||||||
LL | static bad: isize = 1; //~ ERROR should have an upper
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: lint level defined here
|
|
||||||
--> $DIR/lint-group-style.rs:20:14
|
|
||||||
|
|
|
||||||
LL | #[forbid(nonstandard_style)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
= note: #[forbid(non_upper_case_globals)] implied by #[forbid(nonstandard_style)]
|
|
||||||
|
|
||||||
warning: function `CamelCase` should have a snake case name such as `camel_case`
|
|
||||||
--> $DIR/lint-group-style.rs:30:9
|
|
||||||
|
|
|
||||||
LL | fn CamelCase() {} //~ WARN should have a snake
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: lint level defined here
|
|
||||||
--> $DIR/lint-group-style.rs:28:17
|
|
||||||
|
|
|
||||||
LL | #![warn(nonstandard_style)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
= note: #[warn(non_snake_case)] implied by #[warn(nonstandard_style)]
|
|
||||||
|
|
||||||
warning: type `snake_case` should have a camel case name such as `SnakeCase`
|
|
||||||
--> $DIR/lint-group-style.rs:32:9
|
|
||||||
|
|
|
||||||
LL | struct snake_case; //~ WARN should have a camel
|
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: lint level defined here
|
|
||||||
--> $DIR/lint-group-style.rs:28:17
|
|
||||||
|
|
|
||||||
LL | #![warn(nonstandard_style)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
= note: #[warn(non_camel_case_types)] implied by #[warn(nonstandard_style)]
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ error: invalid fragment specifier `foo`
|
|||||||
LL | ($x:foo) => ()
|
LL | ($x:foo) => ()
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
|
|
||||||
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
|
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ error: invalid fragment specifier `t_ty`
|
|||||||
LL | ($wrong:t_ty) => () //~ ERROR invalid fragment specifier `t_ty`
|
LL | ($wrong:t_ty) => () //~ ERROR invalid fragment specifier `t_ty`
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
|
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user