Auto merge of #41846 - frewsxcv:rollup, r=frewsxcv
Rollup of 8 pull requests - Successful merges: #41293, #41520, #41827, #41828, #41833, #41836, #41838, #41842 - Failed merges:
This commit is contained in:
commit
bedd7da3d2
14
src/Cargo.lock
generated
14
src/Cargo.lock
generated
@ -411,16 +411,16 @@ version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "rls-data"
|
||||
version = "0.1.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rls-span 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rls-span"
|
||||
version = "0.1.0"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -719,8 +719,8 @@ name = "rustc_save_analysis"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rls-data 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rls-span 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rls-data 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc 0.0.0",
|
||||
"rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_typeck 0.0.0",
|
||||
@ -1021,8 +1021,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0aad603e8d7fb67da22dbdf1f4b826ce8829e406124109e73cf1b2454b93a71c"
|
||||
"checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01"
|
||||
"checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457"
|
||||
"checksum rls-data 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af1dfff00189fd7b78edb9af131b0de703676c04fa8126aed77fd2c586775a4d"
|
||||
"checksum rls-span 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8656f7b850ac85fb204ef94318c641bbb15a32766e12f9a589a23e4c0fbc38db"
|
||||
"checksum rls-data 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc4277ce3c57f456b11fe3145b181a844a25201bab5cbaa1978457e6e2f27d47"
|
||||
"checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
|
||||
"checksum rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "684ce48436d6465300c9ea783b6b14c4361d6b8dcbb1375b486a69cc19e2dfb0"
|
||||
"checksum serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)" = "a702319c807c016e51f672e5c77d6f0b46afddd744b5e437d6b8436b888b458f"
|
||||
"checksum serde_json 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)" = "dbc45439552eb8fb86907a2c41c1fd0ef97458efb87ff7f878db466eb581824e"
|
||||
|
@ -1,14 +1,14 @@
|
||||
% Rustc UX guidelines
|
||||
|
||||
Don't forget the user. Whether human or another program, such as an IDE, a
|
||||
good user experience with the compiler goes a long way into making developer
|
||||
lives better. We don't want users to be baffled by compiler output or
|
||||
good user experience with the compiler goes a long way toward making developers'
|
||||
lives better. We do not want users to be baffled by compiler output or
|
||||
learn arcane patterns to compile their program.
|
||||
|
||||
## Error, Warning, Help, Note Messages
|
||||
|
||||
When the compiler detects a problem, it can emit either an error, warning,
|
||||
note, or help message.
|
||||
When the compiler detects a problem, it can emit one of the following: an error, a warning,
|
||||
a note, or a help message.
|
||||
|
||||
An `error` is emitted when the compiler detects a problem that makes it unable
|
||||
to compile the program, either because the program is invalid or the
|
||||
@ -17,11 +17,11 @@ An `error` is emitted when the compiler detects a problem that makes it unable
|
||||
A `warning` is emitted when the compiler detects something odd about a
|
||||
program. For instance, dead code and unused `Result` values.
|
||||
|
||||
A `help` is emitted following either an `error` or `warning` giving extra
|
||||
A `help` message is emitted following an `error` or `warning` to give additional
|
||||
information to the user about how to solve their problem.
|
||||
|
||||
A `note` is for identifying additional circumstances and parts of the code
|
||||
that lead to a warning or error. For example, the borrow checker will note any
|
||||
A `note` is emitted to identify additional circumstances and parts of the code
|
||||
that caused the warning or error. For example, the borrow checker will note any
|
||||
previous conflicting borrows.
|
||||
|
||||
* Write in plain simple English. If your message, when shown on a – possibly
|
||||
|
@ -102,7 +102,7 @@ impl<'tcx> fmt::Debug for Kind<'tcx> {
|
||||
} else if let Some(r) = self.as_region() {
|
||||
write!(f, "{:?}", r)
|
||||
} else {
|
||||
write!(f, "<unknwon @ {:p}>", self.ptr.get() as *const ())
|
||||
write!(f, "<unknown @ {:p}>", self.ptr.get() as *const ())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -388,6 +388,14 @@ impl Handler {
|
||||
pub fn span_note_without_error<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
|
||||
self.emit(&sp.into(), msg, Note);
|
||||
}
|
||||
pub fn span_note_diag<'a>(&'a self,
|
||||
sp: Span,
|
||||
msg: &str)
|
||||
-> DiagnosticBuilder<'a> {
|
||||
let mut db = DiagnosticBuilder::new(self, Note, msg);
|
||||
db.set_span(sp);
|
||||
db
|
||||
}
|
||||
pub fn span_unimpl<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
|
||||
self.span_bug(sp, &format!("unimplemented {}", msg));
|
||||
}
|
||||
|
@ -692,6 +692,82 @@ impl EarlyLintPass for DeprecatedAttr {
|
||||
}
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
pub ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
|
||||
Warn,
|
||||
"floating-point literals cannot be used in patterns"
|
||||
}
|
||||
|
||||
/// Checks for floating point literals in patterns.
|
||||
#[derive(Clone)]
|
||||
pub struct IllegalFloatLiteralPattern;
|
||||
|
||||
impl LintPass for IllegalFloatLiteralPattern {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN)
|
||||
}
|
||||
}
|
||||
|
||||
fn fl_lit_check_expr(cx: &EarlyContext, expr: &ast::Expr) {
|
||||
use self::ast::{ExprKind, LitKind};
|
||||
match expr.node {
|
||||
ExprKind::Lit(ref l) => {
|
||||
match l.node {
|
||||
LitKind::FloatUnsuffixed(..) |
|
||||
LitKind::Float(..) => {
|
||||
cx.span_lint(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
|
||||
l.span,
|
||||
"floating-point literals cannot be used in patterns");
|
||||
error!("span mc spanspam");
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
// These may occur in patterns
|
||||
// and can maybe contain float literals
|
||||
ExprKind::Unary(_, ref f) => fl_lit_check_expr(cx, f),
|
||||
// These may occur in patterns
|
||||
// and can't contain float literals
|
||||
ExprKind::Path(..) => (),
|
||||
// If something unhandled is encountered, we need to expand the
|
||||
// search or ignore more ExprKinds.
|
||||
_ => span_bug!(expr.span, "Unhandled expression {:?} in float lit pattern lint",
|
||||
expr.node),
|
||||
}
|
||||
}
|
||||
|
||||
impl EarlyLintPass for IllegalFloatLiteralPattern {
|
||||
fn check_pat(&mut self, cx: &EarlyContext, pat: &ast::Pat) {
|
||||
use self::ast::PatKind;
|
||||
pat.walk(&mut |p| {
|
||||
match p.node {
|
||||
// Wildcard patterns and paths are uninteresting for the lint
|
||||
PatKind::Wild |
|
||||
PatKind::Path(..) => (),
|
||||
|
||||
// The walk logic recurses inside these
|
||||
PatKind::Ident(..) |
|
||||
PatKind::Struct(..) |
|
||||
PatKind::Tuple(..) |
|
||||
PatKind::TupleStruct(..) |
|
||||
PatKind::Ref(..) |
|
||||
PatKind::Box(..) |
|
||||
PatKind::Slice(..) => (),
|
||||
|
||||
// Extract the expressions and check them
|
||||
PatKind::Lit(ref e) => fl_lit_check_expr(cx, e),
|
||||
PatKind::Range(ref st, ref en, _) => {
|
||||
fl_lit_check_expr(cx, st);
|
||||
fl_lit_check_expr(cx, en);
|
||||
},
|
||||
|
||||
PatKind::Mac(_) => bug!("lint must run post-expansion"),
|
||||
}
|
||||
true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
pub UNCONDITIONAL_RECURSION,
|
||||
Warn,
|
||||
|
@ -113,6 +113,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
|
||||
UnusedParens,
|
||||
UnusedImportBraces,
|
||||
AnonymousParameters,
|
||||
IllegalFloatLiteralPattern,
|
||||
);
|
||||
|
||||
add_early_builtin_with_new!(sess,
|
||||
@ -201,6 +202,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
|
||||
id: LintId::of(ILLEGAL_FLOATING_POINT_CONSTANT_PATTERN),
|
||||
reference: "issue #36890 <https://github.com/rust-lang/rust/issues/36890>",
|
||||
},
|
||||
FutureIncompatibleInfo {
|
||||
id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN),
|
||||
reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
|
||||
},
|
||||
FutureIncompatibleInfo {
|
||||
id: LintId::of(ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN),
|
||||
reference: "issue #36891 <https://github.com/rust-lang/rust/issues/36891>",
|
||||
|
@ -14,7 +14,7 @@ rustc = { path = "../librustc" }
|
||||
rustc_typeck = { path = "../librustc_typeck" }
|
||||
syntax = { path = "../libsyntax" }
|
||||
syntax_pos = { path = "../libsyntax_pos" }
|
||||
rls-data = "0.1"
|
||||
rls-span = "0.1"
|
||||
rls-data = "0.3"
|
||||
rls-span = "0.4"
|
||||
# FIXME(#40527) should move rustc serialize out of tree
|
||||
rustc-serialize = "0.3"
|
||||
|
@ -126,6 +126,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
(sig, kind)
|
||||
}
|
||||
ty::TyInfer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid),
|
||||
ty::TyFnPtr(sig) => (Some(sig.skip_binder().clone()), Some(ty::ClosureKind::Fn)),
|
||||
_ => (None, None),
|
||||
}
|
||||
}
|
||||
|
@ -433,22 +433,11 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||
for (i, &expr) in exprs.iter().rev().enumerate() {
|
||||
debug!("convert_lvalue_derefs_to_mutable: i={} expr={:?}", i, expr);
|
||||
|
||||
// Fix up the adjustment.
|
||||
let autoderefs = match self.tables.borrow_mut().adjustments.get_mut(&expr.id) {
|
||||
Some(&mut Adjustment {
|
||||
kind: Adjust::DerefRef { autoderefs, ref mut autoref, .. }, ref mut target
|
||||
}) => {
|
||||
if let &mut Some(AutoBorrow::Ref(_, ref mut mutbl)) = autoref {
|
||||
*mutbl = hir::Mutability::MutMutable;
|
||||
*target = match target.sty {
|
||||
ty::TyRef(r, ty::TypeAndMut { ty, .. }) =>
|
||||
self.tcx.mk_ref(r, ty::TypeAndMut { ty, mutbl: *mutbl }),
|
||||
_ => span_bug!(expr.span, "AutoBorrow::Ref resulted in non-ref {:?}",
|
||||
target)
|
||||
};
|
||||
}
|
||||
autoderefs
|
||||
}
|
||||
// Fix up the autoderefs. Autorefs can only occur immediately preceding
|
||||
// overloaded lvalue ops, and will be fixed by them in order to get
|
||||
// the correct region.
|
||||
let autoderefs = match self.tables.borrow().adjustments.get(&expr.id) {
|
||||
Some(&Adjustment { kind: Adjust::DerefRef { autoderefs, .. }, .. }) => autoderefs,
|
||||
Some(_) | None => 0
|
||||
};
|
||||
|
||||
@ -502,10 +491,35 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
|
||||
|
||||
let method = self.try_overloaded_lvalue_op(
|
||||
expr.span, None, base_ty, arg_tys, PreferMutLvalue, op);
|
||||
let ok = method.expect("re-trying op failed");
|
||||
let ok = match method {
|
||||
Some(method) => method,
|
||||
None => return self.tcx.sess.delay_span_bug(expr.span, "re-trying op failed")
|
||||
};
|
||||
let method = self.register_infer_ok_obligations(ok);
|
||||
debug!("convert_lvalue_op_to_mutable: method={:?}", method);
|
||||
self.tables.borrow_mut().method_map.insert(method_call, method);
|
||||
|
||||
// Convert the autoref in the base expr to mutable with the correct
|
||||
// region and mutability.
|
||||
if let Some(&mut Adjustment {
|
||||
ref mut target, kind: Adjust::DerefRef {
|
||||
autoref: Some(AutoBorrow::Ref(ref mut r, ref mut mutbl)), ..
|
||||
}
|
||||
}) = self.tables.borrow_mut().adjustments.get_mut(&base_expr.id) {
|
||||
debug!("convert_lvalue_op_to_mutable: converting autoref of {:?}", target);
|
||||
|
||||
// extract method return type, which will be &mut T;
|
||||
// all LB regions should have been instantiated during method lookup
|
||||
let method_sig = self.tcx.no_late_bound_regions(&method.ty.fn_sig()).unwrap();
|
||||
|
||||
*target = method_sig.inputs()[0];
|
||||
if let ty::TyRef(r_, mt) = target.sty {
|
||||
*r = r_;
|
||||
*mutbl = mt.mutbl;
|
||||
} else {
|
||||
span_bug!(expr.span, "input to lvalue op is not a ref?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -24,6 +24,7 @@ use ptr::P;
|
||||
use symbol::Symbol;
|
||||
use util::small_vector::SmallVector;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::default::Default;
|
||||
@ -643,6 +644,7 @@ pub struct ExtCtxt<'a> {
|
||||
pub resolver: &'a mut Resolver,
|
||||
pub resolve_err_count: usize,
|
||||
pub current_expansion: ExpansionData,
|
||||
pub expansions: HashMap<Span, Vec<String>>,
|
||||
}
|
||||
|
||||
impl<'a> ExtCtxt<'a> {
|
||||
@ -662,6 +664,7 @@ impl<'a> ExtCtxt<'a> {
|
||||
module: Rc::new(ModuleData { mod_path: Vec::new(), directory: PathBuf::new() }),
|
||||
directory_ownership: DirectoryOwnership::Owned,
|
||||
},
|
||||
expansions: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -765,6 +768,15 @@ impl<'a> ExtCtxt<'a> {
|
||||
pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
|
||||
self.parse_sess.span_diagnostic.span_bug(sp, msg);
|
||||
}
|
||||
pub fn trace_macros_diag(&self) {
|
||||
for (sp, notes) in self.expansions.iter() {
|
||||
let mut db = self.parse_sess.span_diagnostic.span_note_diag(*sp, &"trace_macro");
|
||||
for note in notes {
|
||||
db.note(¬e);
|
||||
}
|
||||
db.emit();
|
||||
}
|
||||
}
|
||||
pub fn bug(&self, msg: &str) -> ! {
|
||||
self.parse_sess.span_diagnostic.bug(msg);
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
self.cx.trace_macros_diag();
|
||||
krate
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ use symbol::Symbol;
|
||||
use tokenstream::{TokenStream, TokenTree};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{HashMap};
|
||||
use std::collections::hash_map::{Entry};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct ParserAnyMacro<'a> {
|
||||
@ -85,7 +85,7 @@ impl TTMacroExpander for MacroRulesMacroExpander {
|
||||
}
|
||||
|
||||
/// Given `lhses` and `rhses`, this is the new macro we create
|
||||
fn generic_extension<'cx>(cx: &'cx ExtCtxt,
|
||||
fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
|
||||
sp: Span,
|
||||
name: ast::Ident,
|
||||
arg: TokenStream,
|
||||
@ -93,7 +93,9 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
|
||||
rhses: &[quoted::TokenTree])
|
||||
-> Box<MacResult+'cx> {
|
||||
if cx.trace_macros() {
|
||||
println!("{}! {{ {} }}", name, arg);
|
||||
let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp);
|
||||
let mut values: &mut Vec<String> = cx.expansions.entry(sp).or_insert(vec![]);
|
||||
values.push(format!("expands to `{}! {{ {} }}`", name, arg));
|
||||
}
|
||||
|
||||
// Which arm's failure should we report? (the one furthest along)
|
||||
|
@ -504,7 +504,7 @@ impl<'a> StringReader<'a> {
|
||||
self.bump();
|
||||
|
||||
// line comments starting with "///" or "//!" are doc-comments
|
||||
let doc_comment = self.ch_is('/') || self.ch_is('!');
|
||||
let doc_comment = (self.ch_is('/') && !self.nextch_is('/')) || self.ch_is('!');
|
||||
let start_bpos = self.pos - BytePos(2);
|
||||
|
||||
while !self.is_eof() {
|
||||
|
@ -15,10 +15,4 @@ fn main() {
|
||||
let mut a = 0u8;
|
||||
let foo: fn(u8) -> u8 = |v: u8| { a += v; a };
|
||||
//~^ ERROR mismatched types
|
||||
let b = 0u8;
|
||||
let bar: fn() -> u8 = || { b };
|
||||
//~^ ERROR mismatched types
|
||||
let baz: fn() -> u8 = || { b } as fn() -> u8;
|
||||
//~^ ERROR mismatched types
|
||||
//~^^ ERROR non-scalar cast
|
||||
}
|
18
src/test/compile-fail/closure-no-fn-2.rs
Normal file
18
src/test/compile-fail/closure-no-fn-2.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 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.
|
||||
|
||||
// Ensure that capturing closures are never coerced to fns
|
||||
// Especially interesting as non-capturing closures can be.
|
||||
|
||||
fn main() {
|
||||
let b = 0u8;
|
||||
let bar: fn() -> u8 = || { b };
|
||||
//~^ ERROR mismatched types
|
||||
}
|
18
src/test/compile-fail/closure-no-fn-3.rs
Normal file
18
src/test/compile-fail/closure-no-fn-3.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 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.
|
||||
|
||||
// Ensure that capturing closures are never coerced to fns
|
||||
// Especially interesting as non-capturing closures can be.
|
||||
|
||||
fn main() {
|
||||
let b = 0u8;
|
||||
let baz: fn() -> u8 = (|| { b }) as fn() -> u8;
|
||||
//~^ ERROR non-scalar cast
|
||||
}
|
@ -11,8 +11,7 @@
|
||||
#![feature(closure_to_fn_coercion)]
|
||||
|
||||
fn main() {
|
||||
let bar: fn(&mut u32) = |_| {}; //~ ERROR mismatched types
|
||||
//~| expected concrete lifetime, found bound lifetime parameter
|
||||
let bar: fn(&mut u32) = |_| {};
|
||||
|
||||
fn foo(x: Box<Fn(&i32)>) {}
|
||||
let bar = Box::new(|x: &i32| {}) as Box<Fn(_)>;
|
||||
|
55
src/test/compile-fail/issue-41255.rs
Normal file
55
src/test/compile-fail/issue-41255.rs
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright 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.
|
||||
|
||||
// Matching against float literals should result in a linter error
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
#![allow(unused)]
|
||||
#![forbid(illegal_floating_point_literal_pattern)]
|
||||
|
||||
fn main() {
|
||||
let x = 42.0;
|
||||
match x {
|
||||
5.0 => {}, //~ ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
5.0f32 => {}, //~ ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
-5.0 => {}, //~ ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
1.0 .. 33.0 => {}, //~ ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
//~| ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
39.0 ... 70.0 => {}, //~ ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
//~| ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
_ => {},
|
||||
};
|
||||
let y = 5.0;
|
||||
// Same for tuples
|
||||
match (x, 5) {
|
||||
(3.14, 1) => {}, //~ ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
//~| ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
_ => {},
|
||||
}
|
||||
// Or structs
|
||||
struct Foo { x: f32 };
|
||||
match (Foo { x }) {
|
||||
Foo { x: 2.0 } => {}, //~ ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
//~| ERROR floating-point literals cannot be used
|
||||
//~| WARNING hard error
|
||||
_ => {},
|
||||
}
|
||||
}
|
17
src/test/compile-fail/issue-41726.rs
Normal file
17
src/test/compile-fail/issue-41726.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 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.
|
||||
|
||||
use std::collections::HashMap;
|
||||
fn main() {
|
||||
let things: HashMap<String, Vec<String>> = HashMap::new();
|
||||
for src in things.keys() {
|
||||
things[src.as_str()].sort(); //~ ERROR cannot borrow immutable
|
||||
}
|
||||
}
|
35
src/test/compile-fail/issue-41742.rs
Normal file
35
src/test/compile-fail/issue-41742.rs
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 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.
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct S;
|
||||
struct H;
|
||||
|
||||
impl S {
|
||||
fn f(&mut self) {}
|
||||
}
|
||||
|
||||
impl Index<u32> for H {
|
||||
type Output = S;
|
||||
fn index(&self, index: u32) -> &S {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<u32> for H {
|
||||
fn index_mut(&mut self, index: u32) -> &mut S {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
H["?"].f(); //~ ERROR mismatched types
|
||||
}
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
#![allow(illegal_floating_point_literal_pattern)]
|
||||
|
||||
enum t { a, b, }
|
||||
|
||||
|
26
src/test/compile-fail/regions-adjusted-lvalue-op.rs
Normal file
26
src/test/compile-fail/regions-adjusted-lvalue-op.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 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.
|
||||
|
||||
// check that we link regions in mutable lvalue ops correctly - issue #41774
|
||||
|
||||
struct Data(i32);
|
||||
|
||||
trait OhNo {
|
||||
fn oh_no(&mut self, other: &Vec<Data>) { loop {} }
|
||||
}
|
||||
|
||||
impl OhNo for Data {}
|
||||
impl OhNo for [Data] {}
|
||||
|
||||
fn main() {
|
||||
let mut v = vec![Data(0)];
|
||||
v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because
|
||||
(*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because
|
||||
}
|
@ -21,6 +21,12 @@ pub fn bar() {}
|
||||
//~^^ ERROR: bare CR not allowed in block doc-comment
|
||||
|
||||
fn main() {
|
||||
//! doc comment with bare CR: '
'
|
||||
//~^ ERROR: bare CR not allowed in doc-comment
|
||||
|
||||
/*! block doc comment with bare CR: '
' */
|
||||
//~^ ERROR: bare CR not allowed in block doc-comment
|
||||
|
||||
// the following string literal has a bare CR in it
|
||||
let _s = "foo
bar"; //~ ERROR: bare CR not allowed in string
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
# This test verifies that "-Z trace-macros" works as it should. The traditional
|
||||
# "hello world" program provides a small example of this as not only println! is
|
||||
# listed, but also print! (since println! expands to this)
|
||||
|
||||
-include ../tools.mk
|
||||
|
||||
all:
|
||||
$(RUSTC) -Z trace-macros hello.rs > $(TMPDIR)/hello.out
|
||||
diff -u $(TMPDIR)/hello.out hello.trace
|
@ -1,2 +0,0 @@
|
||||
println! { "Hello, World!" }
|
||||
print! { concat ! ( "Hello, World!" , "\n" ) }
|
17
src/test/run-pass/closure_to_fn_coercion-expected-types.rs
Normal file
17
src/test/run-pass/closure_to_fn_coercion-expected-types.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2012 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.
|
||||
// Ensure that we deduce expected argument types when a `fn()` type is expected (#41755)
|
||||
|
||||
#![feature(closure_to_fn_coercion)]
|
||||
fn foo(f: fn(Vec<u32>) -> usize) { }
|
||||
|
||||
fn main() {
|
||||
foo(|x| x.len())
|
||||
}
|
18
src/test/run-pass/lex-bare-cr-nondoc-comment.rs
Normal file
18
src/test/run-pass/lex-bare-cr-nondoc-comment.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <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.
|
||||
|
||||
// ignore-tidy-cr
|
||||
|
||||
// nondoc comment with bare CR: '
'
|
||||
//// nondoc comment with bare CR: '
'
|
||||
/* block nondoc comment with bare CR: '
' */
|
||||
|
||||
fn main() {
|
||||
}
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z trace-macros
|
||||
|
||||
fn main() {
|
||||
println!("Hello, World!");
|
||||
}
|
9
src/test/ui/macros/trace-macro.stderr
Normal file
9
src/test/ui/macros/trace-macro.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
note: trace_macro
|
||||
--> $DIR/trace-macro.rs:14:5
|
||||
|
|
||||
14 | println!("Hello, World!");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: expands to `println! { "Hello, World!" }`
|
||||
= note: expands to `print! { concat ! ( "Hello, World!" , "/n" ) }`
|
||||
|
Loading…
Reference in New Issue
Block a user