Skip to content

Rollup of 11 pull requests #55095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Oct 15, 2018
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8552c61
Add initial impl of check_pat() for UnusedParens
kleimkuhler Oct 2, 2018
5217527
Share outer paren trimming logic
kleimkuhler Oct 4, 2018
46b07d6
Simply unused_parens check and add tests
kleimkuhler Oct 6, 2018
47014df
Fix Range warning and improve tests
kleimkuhler Oct 7, 2018
0e411c2
Add clarifying pattern lint comment and revert test
kleimkuhler Oct 10, 2018
3855af5
add test for #23189
euclio Oct 11, 2018
09f42dd
Add missing lifetime fragment specifier to error message.
ehuss Oct 13, 2018
af6c871
doc: make core::fmt::Error example more simple
tshepang Oct 13, 2018
12b5c7b
Don't collect to vectors where unnecessary
ljedrz Oct 13, 2018
9d3643d
Make EvalContext::step public again
bjorn3 Oct 14, 2018
8a228fd
Add comment about step being used by priroda
bjorn3 Oct 14, 2018
1b355a8
Fix incorrect link in println! documentation
Oct 14, 2018
e8ec498
clarify pointer add/sub function safety concerns
jannic Oct 14, 2018
6cc84ac
remove unnecessary emphasis in doc comment
jannic Oct 14, 2018
ac6b3f8
Deduplicate tests
sinkuu Oct 15, 2018
942a796
rustc/session: whitespace & formatting improvements
ljedrz Oct 10, 2018
675f00b
rustc/session: improve allocations
ljedrz Oct 10, 2018
0b2e9f7
rustc/session: improve common patterns
ljedrz Oct 10, 2018
e5eb538
rustc/session: use to_owned when no string conversion is needed
ljedrz Oct 10, 2018
42ae9dc
rustc/session: move consts up to improve readability
ljedrz Oct 10, 2018
e03d24e
Update rustc documentation link
juchiast Oct 15, 2018
7ba24e8
Rollup merge of #54820 - kleimkuhler:issue-54538-unused_patterns-lint…
Manishearth Oct 15, 2018
3ffb16f
Rollup merge of #54963 - ljedrz:cleanup_rustc_session, r=varkor
Manishearth Oct 15, 2018
defcb16
Rollup merge of #54991 - euclio:issue-23189, r=tmandry
Manishearth Oct 15, 2018
78765e5
Rollup merge of #55025 - ehuss:missing-lifetime-err-msg, r=petrochenkov
Manishearth Oct 15, 2018
dc87247
Rollup merge of #55047 - tshepang:simple, r=alexcrichton
Manishearth Oct 15, 2018
2e8b61d
Rollup merge of #55048 - ljedrz:begone_vecc, r=estebank
Manishearth Oct 15, 2018
8e42f01
Rollup merge of #55060 - jannic:patch-1, r=joshtriplett
Manishearth Oct 15, 2018
96ab4a8
Rollup merge of #55062 - bjorn3:ecx-step-public, r=oli-obk
Manishearth Oct 15, 2018
6993a05
Rollup merge of #55066 - iaz3:patch-1, r=sfackler
Manishearth Oct 15, 2018
4d837be
Rollup merge of #55081 - sinkuu:dedup_test, r=Manishearth
Manishearth Oct 15, 2018
562625d
Rollup merge of #55088 - juchiast:master, r=varkor
Manishearth Oct 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -646,7 +646,7 @@ are:
* 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
[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
[rif]: http://internals.rust-lang.org
[rr]: https://doc.rust-lang.org/book/README.html
5 changes: 2 additions & 3 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
@@ -96,9 +96,8 @@ pub type Result = result::Result<(), Error>;
/// use std::fmt::{self, write};
///
/// let mut output = String::new();
/// match write(&mut output, format_args!("Hello {}!", "world")) {
/// Err(fmt::Error) => panic!("An error occurred"),
/// _ => (),
/// if let Err(fmt::Error) = write(&mut output, format_args!("Hello {}!", "world")) {
/// panic!("An error occurred");
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
12 changes: 6 additions & 6 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
@@ -1037,7 +1037,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * 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`.
///
@@ -1255,7 +1255,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * 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`.
///
@@ -1312,7 +1312,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * 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**.
///
@@ -1657,7 +1657,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * 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`.
///
@@ -1893,7 +1893,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * 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`.
///
@@ -1950,7 +1950,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * 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**.
///
5 changes: 1 addition & 4 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
@@ -60,7 +60,6 @@ use util::nodemap::{DefIdMap, NodeMap};

use std::collections::BTreeMap;
use std::fmt::Debug;
use std::iter;
use std::mem;
use smallvec::SmallVec;
use syntax::attr;
@@ -3888,9 +3887,7 @@ impl<'a> LoweringContext<'a> {
.collect::<P<[hir::Field]>>();

let is_unit = fields.is_empty();
let struct_path = iter::once("ops")
.chain(iter::once(path))
.collect::<Vec<_>>();
let struct_path = ["ops", path];
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
let struct_path = hir::QPath::Resolved(None, P(struct_path));

214 changes: 99 additions & 115 deletions src/librustc/session/config.rs

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/librustc/session/filesearch.rs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ impl<'a> FileSearch<'a> {
F: FnMut(&Path, PathKind)
{
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) {
f(path, kind);
visited_dirs.insert(path.to_path_buf());
@@ -160,7 +160,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
match env::current_exe() {
Ok(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")
}
}
@@ -175,25 +175,25 @@ fn find_libdir(sysroot: &Path) -> Cow<'static, str> {
// to lib64/lib32. This would be more foolproof by basing the sysroot off
// of the directory where librustc is located, rather than where the rustc
// binary is.
//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).

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")]
const PRIMARY_LIB_DIR: &'static str = "lib64";

#[cfg(target_pointer_width = "32")]
const PRIMARY_LIB_DIR: &'static str = "lib32";

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.
50 changes: 19 additions & 31 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
@@ -703,8 +703,8 @@ impl Session {
match self.opts.maybe_sysroot {
Some(ref sysroot) => sysroot,
None => self.default_sysroot
.as_ref()
.expect("missing sysroot and default_sysroot in Session"),
.as_ref()
.expect("missing sysroot and default_sysroot in Session"),
}
}
pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> {
@@ -727,14 +727,8 @@ impl Session {
pub fn set_incr_session_load_dep_graph(&self, load: bool) {
let mut incr_comp_session = self.incr_comp_session.borrow_mut();

match *incr_comp_session {
IncrCompSession::Active {
ref mut load_dep_graph,
..
} => {
*load_dep_graph = load;
}
_ => {}
if let IncrCompSession::Active { ref mut load_dep_graph, .. } = *incr_comp_session {
*load_dep_graph = load;
}
}

@@ -872,9 +866,9 @@ impl Session {
/// This expends fuel if applicable, and records fuel if applicable.
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
let mut ret = true;
match self.optimization_fuel_crate {
Some(ref c) if c == crate_name => {
assert!(self.query_threads() == 1);
if let Some(ref c) = self.optimization_fuel_crate {
if c == crate_name {
assert_eq!(self.query_threads(), 1);
let fuel = self.optimization_fuel_limit.get();
ret = fuel != 0;
if fuel == 0 && !self.out_of_fuel.get() {
@@ -884,14 +878,12 @@ impl Session {
self.optimization_fuel_limit.set(fuel - 1);
}
}
_ => {}
}
match self.print_fuel_crate {
Some(ref c) if c == crate_name => {
assert!(self.query_threads() == 1);
if let Some(ref c) = self.print_fuel_crate {
if c == crate_name {
assert_eq!(self.query_threads(), 1);
self.print_fuel.set(self.print_fuel.get() + 1);
}
_ => {}
}
ret
}
@@ -1108,14 +1100,11 @@ pub fn build_session_(
source_map: Lrc<source_map::SourceMap>,
) -> Session {
let host_triple = TargetTriple::from_triple(config::host_triple());
let host = match Target::search(&host_triple) {
Ok(t) => t,
Err(e) => {
span_diagnostic
.fatal(&format!("Error loading host specification: {}", e))
.raise();
}
};
let host = Target::search(&host_triple).unwrap_or_else(|e|
span_diagnostic
.fatal(&format!("Error loading host specification: {}", e))
.raise()
);
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);

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 = LockCell::new(0);

let working_dir = match env::current_dir() {
Ok(dir) => dir,
Err(e) => p_s.span_diagnostic
let working_dir = env::current_dir().unwrap_or_else(|e|
p_s.span_diagnostic
.fatal(&format!("Current directory is invalid: {}", e))
.raise(),
};
.raise()
);
let working_dir = file_path_mapping.map_prefix(working_dir);

let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
2 changes: 1 addition & 1 deletion src/librustc/session/search_paths.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ use session::{early_error, config};

#[derive(Clone, Debug)]
pub struct SearchPaths {
paths: Vec<(PathKind, PathBuf)>,
crate paths: Vec<(PathKind, PathBuf)>,
}

pub struct Iter<'a> {
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
@@ -1657,7 +1657,7 @@ pub fn build_output_filenames(
.crate_name
.clone()
.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 {
out_directory: dirpath,
111 changes: 69 additions & 42 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
@@ -272,7 +272,7 @@ declare_lint! {
pub struct UnusedParens;

impl UnusedParens {
fn check_unused_parens_core(&self,
fn check_unused_parens_expr(&self,
cx: &EarlyContext,
value: &ast::Expr,
msg: &str,
@@ -281,46 +281,57 @@ impl UnusedParens {
let necessary = struct_lit_needs_parens &&
parser::contains_exterior_struct_lit(&inner);
if !necessary {
let span_msg = format!("unnecessary parentheses around {}", msg);
let mut err = cx.struct_span_lint(UNUSED_PARENS,
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_right_paren = false;
let parens_removed = pprust::expr_to_string(value)
.trim_matches(|c| {
match c {
'(' => {
if ate_left_paren {
false
} else {
ate_left_paren = true;
true
}
},
')' => {
if ate_right_paren {
false
} else {
ate_right_paren = true;
true
}
},
_ => false,
}
}).to_owned();
err.span_suggestion_short_with_applicability(
value.span,
"remove these parentheses",
parens_removed,
Applicability::MachineApplicable
);
err.emit();
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 mut err = cx.struct_span_lint(UNUSED_PARENS, span, &span_msg);
let mut ate_left_paren = false;
let mut ate_right_paren = false;
let parens_removed = pattern
.trim_matches(|c| {
match c {
'(' => {
if ate_left_paren {
false
} else {
ate_left_paren = true;
true
}
},
')' => {
if ate_right_paren {
false
} else {
ate_right_paren = true;
true
}
},
_ => false,
}
}).to_owned();
err.span_suggestion_short_with_applicability(
span,
"remove these parentheses",
parens_removed,
Applicability::MachineApplicable
);
err.emit();
}
}

impl LintPass for UnusedParens {
@@ -349,7 +360,9 @@ impl EarlyLintPass for UnusedParens {
// first "argument" is self (which sometimes needs parens)
MethodCall(_, ref args) => (&args[1..], "method"),
// actual catch-all arm
_ => { return; }
_ => {
return;
}
};
// 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.,
@@ -362,18 +375,32 @@ impl EarlyLintPass for UnusedParens {
}
let msg = format!("{} argument", call_kind);
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;
}
};
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) {
if let ast::StmtKind::Local(ref local) = s.node {
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);
}
}
}
4 changes: 3 additions & 1 deletion src/librustc_mir/interpret/step.rs
Original file line number Diff line number Diff line change
@@ -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.
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() {
return Ok(false);
}
7 changes: 2 additions & 5 deletions src/librustc_traits/lowering.rs
Original file line number Diff line number Diff line change
@@ -306,8 +306,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
let wf_conditions = iter::once(ty::Binder::dummy(trait_pred.lower()))
.chain(
where_clauses
.iter()
.cloned()
.into_iter()
.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`
let where_clauses = tcx.predicates_of(def_id).predicates
.into_iter()
.map(|(wc, _)| wc.lower())
.collect::<Vec<_>>();
.map(|(wc, _)| wc.lower());

// `Implemented(A0: Trait<A1..An>) :- WC`
let clause = ProgramClause {
goal: trait_pred,
hypotheses: tcx.mk_goals(
where_clauses
.into_iter()
.map(|wc| tcx.mk_goal(GoalKind::from_poly_domain_goal(wc, tcx))),
),
};
10 changes: 5 additions & 5 deletions src/librustc_typeck/check/demand.rs
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// field is of the found type, suggest such variants. See Issue
// #42764.
if let ty::Adt(expected_adt, substs) = expected.sty {
let compatible_variants = expected_adt.variants
let mut compatible_variants = expected_adt.variants
.iter()
.filter(|variant| variant.fields.len() == 1)
.filter_map(|variant| {
@@ -127,12 +127,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} else {
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 suggestions = compatible_variants.iter()
.map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>();
let suggestions = compatible_variants.map(|v|
format!("{}({})", v, expr_text)).collect::<Vec<_>>();
err.span_suggestions_with_applicability(
expr.span,
"try using a variant of the expected type",
2 changes: 1 addition & 1 deletion src/libstd/macros.rs
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ macro_rules! print {
///
/// [`format!`]: ../std/macro.format.html
/// [`std::fmt`]: ../std/fmt/index.html
/// [`eprintln!`]: ../std/macro.eprint.html
/// [`eprintln!`]: ../std/macro.eprintln.html
/// # Panics
///
/// Panics if writing to `io::stdout` fails.
11 changes: 6 additions & 5 deletions src/libsyntax/ext/tt/macro_rules.rs
Original file line number Diff line number Diff line change
@@ -34,6 +34,10 @@ use std::collections::hash_map::Entry;
use rustc_data_structures::sync::Lrc;
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> {
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) {
let msg = format!("invalid fragment specifier `{}`", bad_frag);
sess.span_diagnostic.struct_span_err(token.span(), &msg)
.help("valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, \
`pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`")
.help(VALID_FRAGMENT_NAMES_MSG)
.emit();
// (This eliminates false positives and duplicates
// from error messages.)
@@ -938,9 +941,7 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> Result<bool, (String, &'
},
"" => Ok(true), // keywords::Invalid
_ => Err((format!("invalid fragment specifier `{}`", frag),
"valid fragment specifiers are `ident`, `block`, \
`stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt`, \
`literal`, `item` and `vis`"))
VALID_FRAGMENT_NAMES_MSG))
}
}
}
1 change: 1 addition & 0 deletions src/test/run-pass/binding/pat-tuple-7.rs
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
// run-pass

fn main() {
#[allow(unused_parens)]
match 0 {
(pat) => assert_eq!(pat, 0)
}
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-21356.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error: invalid fragment specifier `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

Original file line number Diff line number Diff line change
@@ -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
// http://rust-lang.org/COPYRIGHT.
//
@@ -7,13 +7,9 @@
// <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.
struct Ref<'a, 'b> {
a: &'a u32,
b: &'b u32,
}

fn foo(mut x: Ref) {
x.a = x.b; //~ ERROR lifetime mismatch
}
mod module {}

fn main() {}
fn main() {
let _ = module { x: 0 }; //~ERROR expected struct
}
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-23189.stderr
Original file line number Diff line number Diff line change
@@ -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`.

This file was deleted.

This file was deleted.

38 changes: 38 additions & 0 deletions src/test/ui/lint/issue-54538-unused-parens-lint.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 42 additions & 0 deletions src/test/ui/lint/issue-54538-unused-parens-lint.stderr
Original file line number Diff line number Diff line change
@@ -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

36 changes: 0 additions & 36 deletions src/test/ui/lint/lint-group-style.rs

This file was deleted.

67 changes: 0 additions & 67 deletions src/test/ui/lint/lint-group-style.stderr

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/ui/macros/macro-invalid-fragment-spec.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ error: invalid fragment specifier `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

2 changes: 1 addition & 1 deletion src/test/ui/unused/unused-macro-with-bad-frag-spec.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ 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