}
} else {
for path in paths {
+ // strip CurDir prefix if present
+ let path = match path.strip_prefix(".") {
+ Ok(p) => p,
+ Err(_) => path,
+ };
+
let mut attempted_run = false;
for (desc, should_run) in v.iter().zip(&should_runs) {
if let Some(suite) = should_run.is_suite_path(path) {
// Get test-args by striping suite path
let mut test_args: Vec<&str> = paths
.iter()
+ .map(|p| {
+ match p.strip_prefix(".") {
+ Ok(path) => path,
+ Err(_) => p,
+ }
+ })
.filter(|p| p.starts_with(suite_path) && p.is_file())
.map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap())
.collect();
compiles, then the test will fail. However please note that code failing
with the current Rust release may work in a future release, as new features
are added.
+
+## Syntax reference
+
+The *exact* syntax for code blocks, including the edge cases, can be found
+in the [Fenced Code Blocks](https://spec.commonmark.org/0.28/#fenced-code-blocks)
+section of the CommonMark specification.
+
+Rustdoc also accepts *indented* code blocks as an alternative to fenced
+code blocks: instead of surrounding your code with three backticks, you
+can indent each line by four or more spaces.
+
+``````markdown
+ let foo = "foo";
+ assert_eq!(foo, "foo");
+``````
+
+These, too, are documented in the CommonMark specification, in the
+[Indented Code Blocks](https://spec.commonmark.org/0.28/#indented-code-blocks)
+section.
+
+However, it's preferable to use fenced code blocks over indented code blocks.
+Not only are fenced code blocks considered more idiomatic for Rust code,
+but there is no way to use directives such as `ignore` or `should_panic` with
+indented code blocks.
debug!("consume_body(body={:?})", body);
for arg in &body.arguments {
- let arg_ty = return_if_err!(self.mc.node_ty(arg.pat.hir_id));
+ let arg_ty = return_if_err!(self.mc.pat_ty_adjusted(&arg.pat));
+ debug!("consume_body: arg_ty = {:?}", arg_ty);
let fn_body_scope_r =
self.tcx().mk_region(ty::ReScope(region::Scope::Node(body.value.hir_id.local_id)));
/// implicit deref patterns attached (e.g., it is really
/// `&Some(x)`). In that case, we return the "outermost" type
/// (e.g., `&Option<T>).
- fn pat_ty(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
+ pub fn pat_ty_adjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
// Check for implicit `&` types wrapping the pattern; note
// that these are never attached to binding patterns, so
// actually this is somewhat "disjoint" from the code below
};
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {
- let subpat_ty = self.pat_ty(&subpat)?; // see (*2)
+ let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2)
let interior = InteriorField(FieldIndex(i, Name::intern(&i.to_string())));
let subcmt = Rc::new(self.cat_imm_interior(pat, cmt.clone(), subpat_ty, interior));
self.cat_pattern_(subcmt, &subpat, op)?;
};
for fp in field_pats {
- let field_ty = self.pat_ty(&fp.node.pat)?; // see (*2)
+ let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2)
let f_index = self.tcx.field_index(fp.node.id, self.tables);
let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index,
fp.node.ident, field_ty));
ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
};
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {
- let subpat_ty = self.pat_ty(&subpat)?; // see (*2)
+ let subpat_ty = self.pat_ty_unadjusted(&subpat)?; // see (*2)
let interior = InteriorField(FieldIndex(i, Name::intern(&i.to_string())));
let subcmt = Rc::new(self.cat_imm_interior(pat, cmt.clone(), subpat_ty, interior));
self.cat_pattern_(subcmt, &subpat, op)?;
lifetimeuseset
);
match lifetimeuseset {
- Some(LifetimeUseSet::One(_)) => {
+ Some(LifetimeUseSet::One(lifetime)) => {
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
debug!("node id first={:?}", node_id);
if let Some((id, span, name)) = match self.tcx.hir.get(node_id) {
_ => None,
} {
debug!("id = {:?} span = {:?} name = {:?}", node_id, span, name);
- self.tcx.struct_span_lint_node(
+ let mut err = self.tcx.struct_span_lint_node(
lint::builtin::SINGLE_USE_LIFETIMES,
id,
span,
&format!("lifetime parameter `{}` only used once", name),
- ).emit();
+ );
+ err.span_label(span, "this lifetime...");
+ err.span_label(lifetime.span, "...is used only here");
+ err.emit();
}
}
Some(LifetimeUseSet::Many) => {
debug!("stability: \
inspecting def_id={:?} span={:?} of stability={:?}", def_id, span, stability);
- if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, .. }), ..})
+ if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, since }), ..})
= stability {
if let Some(id) = id {
- lint_deprecated(def_id, id, Some(reason));
+ if deprecation_in_effect(&since.as_str()) {
+ lint_deprecated(def_id, id, Some(reason));
+ }
}
}
return;
}
+ // probestack doesn't play nice either with gcov profiling.
+ if cx.sess().opts.debugging_opts.profile {
+ return;
+ }
+
// Flag our internal `__rust_probestack` function as the stack probe symbol.
// This is defined in the `compiler-builtins` crate for each architecture.
llvm::AddFunctionAttrStringValue(
crate mod place_ext;
mod prefixes;
mod path_utils;
+mod used_muts;
pub(crate) mod nll;
.filter(|&local| !mbcx.mir.local_decls[*local].is_user_variable.is_some())
.cloned()
.collect();
-
- for local in temporary_used_locals {
- for location in mbcx.mir.find_assignments(local) {
- for moi in &mbcx.move_data.loc_map[location] {
- let mpi = &mbcx.move_data.moves[*moi].path;
- let path = &mbcx.move_data.move_paths[*mpi];
- debug!("assignment of {:?} to {:?}, adding {:?} to used mutable set",
- path.place, local, path.place);
- if let Place::Local(user_local) = path.place {
- mbcx.used_mut.insert(user_local);
- }
- }
- }
- }
+ mbcx.gather_used_muts(temporary_used_locals);
debug!("mbcx.used_mut: {:?}", mbcx.used_mut);
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use rustc::mir::visit::{PlaceContext, Visitor};
+use rustc::mir::{Local, Location, Place};
+
+use rustc_data_structures::fx::FxHashSet;
+
+use borrow_check::MirBorrowckCtxt;
+use util::collect_writes::is_place_assignment;
+
+impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
+ /// Walks the MIR looking for assignments to a set of locals, as part of the unused mutable
+ /// local variables lint, to update the context's `used_mut` in a single walk.
+ crate fn gather_used_muts(&mut self, locals: FxHashSet<Local>) {
+ let mut visitor = GatherUsedMutsVisitor {
+ needles: locals,
+ mbcx: self,
+ };
+ visitor.visit_mir(visitor.mbcx.mir);
+ }
+}
+
+/// MIR visitor gathering the assignments to a set of locals, in a single walk.
+/// 'visit = the duration of the MIR walk
+struct GatherUsedMutsVisitor<'visit, 'cx: 'visit, 'gcx: 'tcx, 'tcx: 'cx> {
+ needles: FxHashSet<Local>,
+ mbcx: &'visit mut MirBorrowckCtxt<'cx, 'gcx, 'tcx>,
+}
+
+impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'gcx, 'tcx> {
+ fn visit_local(
+ &mut self,
+ local: &Local,
+ place_context: PlaceContext<'tcx>,
+ location: Location,
+ ) {
+ if !self.needles.contains(local) {
+ return;
+ }
+
+ if is_place_assignment(&place_context) {
+ // Propagate the Local assigned at this Location as a used mutable local variable
+ for moi in &self.mbcx.move_data.loc_map[location] {
+ let mpi = &self.mbcx.move_data.moves[*moi].path;
+ let path = &self.mbcx.move_data.move_paths[*mpi];
+ debug!(
+ "assignment of {:?} to {:?}, adding {:?} to used mutable set",
+ path.place, local, path.place
+ );
+ if let Place::Local(user_local) = path.place {
+ self.mbcx.used_mut.insert(user_local);
+ }
+ }
+ }
+ }
+}
let def = self.tables.qpath_def(qpath, pat.hir_id);
let adt_def = match ty.sty {
ty::TyAdt(adt_def, _) => adt_def,
- _ => span_bug!(pat.span, "tuple struct pattern not applied to an ADT"),
+ ty::TyError => { // Avoid ICE (#50585)
+ return Pattern {
+ span: pat.span,
+ ty,
+ kind: Box::new(PatternKind::Wild),
+ };
+ }
+ _ => span_bug!(pat.span,
+ "tuple struct pattern not applied to an ADT {:?}",
+ ty.sty),
};
let variant_def = adt_def.variant_of_def(def);
let substs = match ty.sty {
ty::TyAdt(_, substs) |
ty::TyFnDef(_, substs) => substs,
+ ty::TyError => { // Avoid ICE (#50585)
+ return PatternKind::Wild;
+ }
_ => bug!("inappropriate type for def: {:?}", ty.sty),
};
PatternKind::Variant {
return;
}
- match place_context {
- PlaceContext::Store | PlaceContext::Call => {
- self.locations.push(location);
- }
- PlaceContext::AsmOutput |
- PlaceContext::Drop |
- PlaceContext::Inspect |
- PlaceContext::Borrow { .. } |
- PlaceContext::Projection(..) |
- PlaceContext::Copy |
- PlaceContext::Move |
- PlaceContext::StorageLive |
- PlaceContext::StorageDead |
- PlaceContext::Validate => {
- // TO-DO
- // self.super_local(local)
- }
+ if is_place_assignment(&place_context) {
+ self.locations.push(location);
}
}
- // TO-DO
- // fn super_local()
+}
+
+/// Returns true if this place context represents an assignment statement
+crate fn is_place_assignment(place_context: &PlaceContext) -> bool {
+ match *place_context {
+ PlaceContext::Store | PlaceContext::Call | PlaceContext::AsmOutput => true,
+ PlaceContext::Drop
+ | PlaceContext::Inspect
+ | PlaceContext::Borrow { .. }
+ | PlaceContext::Projection(..)
+ | PlaceContext::Copy
+ | PlaceContext::Move
+ | PlaceContext::StorageLive
+ | PlaceContext::StorageDead
+ | PlaceContext::Validate => false,
+ }
}
use syntax::ast;
use syntax::util::lev_distance::find_best_match_for_name;
use errors::DiagnosticBuilder;
-use syntax_pos::Span;
+use syntax_pos::{Span, FileName};
+
use rustc::hir::def_id::LOCAL_CRATE;
use rustc::hir;
out_of_scope_traits,
lev_candidate,
mode,
- ..
}) => {
let tcx = self.tcx;
let span = tcx.hir.span(node_id);
let snippet = tcx.sess.codemap().span_to_snippet(span)
.unwrap();
- err.span_suggestion(span,
- &format!("you must specify a type for \
- this binding, like `{}`",
- concrete_type),
- format!("{}: {}",
- snippet,
- concrete_type));
+ let filename = tcx.sess.codemap().span_to_filename(span);
+
+ let parent_node = self.tcx.hir.get(
+ self.tcx.hir.get_parent_node(node_id),
+ );
+ let msg = format!(
+ "you must specify a type for this binding, like `{}`",
+ concrete_type,
+ );
+
+ match (filename, parent_node) {
+ (FileName::Real(_), hir_map::NodeLocal(hir::Local {
+ source: hir::LocalSource::Normal,
+ ty,
+ ..
+ })) => {
+ err.span_suggestion(
+ // account for `let x: _ = 42;`
+ // ^^^^
+ span.to(ty.as_ref().map(|ty| ty.span)
+ .unwrap_or(span)),
+ &msg,
+ format!("{}: {}", snippet, concrete_type),
+ );
+ }
+ _ => {
+ err.span_label(span, msg);
+ }
+ }
}
}
}
.content table:not(.table-display) {
border-spacing: 0 5px;
- border-collapse: separate;
}
.content td { vertical-align: top; }
.content td:first-child { padding-right: 20px; }
.content td p:first-child { margin-top: 0; }
.content td h1, .content td h2 { margin-left: 0; font-size: 1.1em; }
+.content tr:first-child td { border-top: 0; }
.docblock table {
- border: 1px solid;
margin: .5em 0;
- border-collapse: collapse;
width: 100%;
}
.docblock table td {
padding: .5em;
- border-top: 1px dashed;
- border-bottom: 1px dashed;
+ border: 1px dashed;
}
.docblock table th {
padding: .5em;
text-align: left;
- border-top: 1px solid;
- border-bottom: 1px solid;
+ border: 1px solid;
}
.fields + table {
mod imp {
#[link(name = "zircon")]
extern {
- fn zx_cprng_draw(buffer: *mut u8, len: usize, actual: *mut usize) -> i32;
+ fn zx_cprng_draw_new(buffer: *mut u8, len: usize) -> i32;
}
fn getrandom(buf: &mut [u8]) -> Result<usize, i32> {
unsafe {
- let mut actual = 0;
- let status = zx_cprng_draw(buf.as_mut_ptr(), buf.len(), &mut actual);
+ let status = zx_cprng_draw_new(buf.as_mut_ptr(), buf.len());
if status == 0 {
- Ok(actual)
+ Ok(buf.len())
} else {
Err(status)
}
/// Parse a string representing a string literal into its final form. Does
/// unescaping.
-fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String {
+pub fn str_lit(lit: &str, diag: Option<(Span, &Handler)>) -> String {
debug!("str_lit: given {}", lit.escape_default());
let mut res = String::with_capacity(lit.len());
err.span_label(self.span, format!("expected identifier, found {}", token_descr));
} else {
err.span_label(self.span, "expected identifier");
+ if self.token == token::Comma && self.look_ahead(1, |t| t.is_ident()) {
+ err.span_suggestion(self.span, "remove this comma", "".into());
+ }
}
err
}
/// Parse a sequence, not including the closing delimiter. The function
/// f must consume tokens until reaching the next separator or
/// closing bracket.
- fn parse_seq_to_before_end<T, F>(&mut self,
+ pub fn parse_seq_to_before_end<T, F>(&mut self,
ket: &token::Token,
sep: SeqSep,
f: F)
ExprKind::AssignOp(binop, lhs, rhs)
}
- fn mk_mac_expr(&mut self, span: Span, m: Mac_, attrs: ThinVec<Attribute>) -> P<Expr> {
+ pub fn mk_mac_expr(&mut self, span: Span, m: Mac_, attrs: ThinVec<Attribute>) -> P<Expr> {
P(Expr {
id: ast::DUMMY_NODE_ID,
node: ExprKind::Mac(codemap::Spanned {node: m, span: span}),
Err(mut e) => {
e.span_label(struct_sp, "while parsing this struct");
e.emit();
- self.recover_stmt();
- break;
+
+ // If the next token is a comma, then try to parse
+ // what comes next as additional fields, rather than
+ // bailing out until next `}`.
+ if self.token != token::Comma {
+ self.recover_stmt();
+ break;
+ }
}
}
if macro_legacy_warnings && self.token != token::Semi {
self.warn_missing_semicolon();
} else {
- self.expect_one_of(&[token::Semi], &[])?;
+ self.expect_one_of(&[], &[token::Semi])?;
}
}
_ => {}
}
/// Parse an impl item.
- crate fn parse_impl_item(&mut self, at_end: &mut bool) -> PResult<'a, ImplItem> {
+ pub fn parse_impl_item(&mut self, at_end: &mut bool) -> PResult<'a, ImplItem> {
maybe_whole!(self, NtImplItem, |x| x);
let attrs = self.parse_outer_attributes()?;
let (mut item, tokens) = self.collect_tokens(|this| {
})
}
- fn parse_optional_str(&mut self) -> Option<(Symbol, ast::StrStyle, Option<ast::Name>)> {
+ pub fn parse_optional_str(&mut self) -> Option<(Symbol, ast::StrStyle, Option<ast::Name>)> {
let ret = match self.token {
token::Literal(token::Str_(s), suf) => (s, ast::StrStyle::Cooked, suf),
token::Literal(token::StrRaw(s, n), suf) => (s, ast::StrStyle::Raw(n), suf),
// <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.
+
#![crate_name="lint_stability"]
#![crate_type = "lib"]
#![feature(staged_api)]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated_text() {}
+#[stable(feature = "test_feature", since = "1.0.0")]
+#[rustc_deprecated(since = "99.99.99", reason = "text")]
+pub fn deprecated_future() {}
+
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated_unstable() {}
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
+ deprecated_future(); // Fine; no error.
+
deprecated_unstable();
//~^ ERROR use of unstable library feature
Trait::trait_deprecated_unstable(&foo);
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated_text() {}
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[rustc_deprecated(since = "99.99.99", reason = "text")]
+ pub fn deprecated_future() {}
+
#[unstable(feature = "test_feature", issue = "0")]
pub fn unstable() {}
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
+ deprecated_future();
+
unstable();
foo.method_unstable();
Foo::method_unstable(&foo);
--- /dev/null
+error[E0507]: cannot move out of borrowed content
+ --> $DIR/issue-51415.rs:16:47
+ |
+LL | let opt = a.iter().enumerate().find(|(_, &s)| {
+ | ^ cannot move out of borrowed content
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.
--- /dev/null
+// 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.
+
+// Regression test for #51415: match default bindings were failing to
+// see the "move out" implied by `&s` below.
+
+fn main() {
+ let a = vec![String::from("a")];
+ let opt = a.iter().enumerate().find(|(_, &s)| {
+ //~^ ERROR cannot move out
+ *s == String::from("d")
+ }).map(|(i, _)| i);
+ println!("{:?}", opt);
+}
--- /dev/null
+error[E0507]: cannot move out of borrowed content
+ --> $DIR/issue-51415.rs:16:46
+ |
+LL | let opt = a.iter().enumerate().find(|(_, &s)| {
+ | ^-
+ | ||
+ | |hint: to prevent move, use `ref s` or `ref mut s`
+ | cannot move out of borrowed content
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ |y: Vec<[(); for x in 0..2 {}]>| {};
+ //~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/issue-50585.rs:12:18
+ |
+LL | fn main() {
+ | - expected `()` because of default return type
+LL | |y: Vec<[(); for x in 0..2 {}]>| {};
+ | ^^^^^^^^^^^^^^^^ expected usize, found ()
+ |
+ = note: expected type `usize`
+ found type `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--> $DIR/fn-types.rs:19:10
|
LL | a: for<'a> fn(&'a u32), //~ ERROR `'a` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
|
note: lint level defined here
--> $DIR/fn-types.rs:11:9
|
LL | fn a(x: &'a u32, y: &'b u32) {
| ^^
+ | |
+ | this lifetime...
+ | ...is used only here
|
note: lint level defined here
--> $DIR/one-use-in-fn-argument-in-band.rs:12:9
|
LL | fn a(x: &'a u32, y: &'b u32) {
| ^^
+ | |
+ | this lifetime...
+ | ...is used only here
error: aborting due to 2 previous errors
--> $DIR/one-use-in-fn-argument.rs:18:6
|
LL | fn a<'a>(x: &'a u32) { //~ ERROR `'a` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
|
note: lint level defined here
--> $DIR/one-use-in-fn-argument.rs:11:9
--> $DIR/one-use-in-inherent-impl-header.rs:24:6
|
LL | impl<'f> Foo<'f> { //~ ERROR `'f` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
|
note: lint level defined here
--> $DIR/one-use-in-inherent-impl-header.rs:11:9
--> $DIR/one-use-in-inherent-method-argument.rs:22:19
|
LL | fn inherent_a<'a>(&self, data: &'a u32) { //~ ERROR `'a` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
|
note: lint level defined here
--> $DIR/one-use-in-inherent-method-argument.rs:11:9
--> $DIR/one-use-in-inherent-method-argument.rs:21:6
|
LL | impl<'f> Foo<'f> { //~ ERROR `'f` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
error: aborting due to 2 previous errors
--> $DIR/one-use-in-inherent-method-return.rs:22:6
|
LL | impl<'f> Foo<'f> { //~ ERROR `'f` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
|
note: lint level defined here
--> $DIR/one-use-in-inherent-method-return.rs:11:9
--> $DIR/one-use-in-trait-method-argument.rs:25:13
|
LL | fn next<'g>(&'g mut self) -> Option<Self::Item> { //~ ERROR `'g` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
|
note: lint level defined here
--> $DIR/one-use-in-trait-method-argument.rs:14:9
--> $DIR/two-uses-in-inherent-method-argument-and-return.rs:22:6
|
LL | impl<'f> Foo<'f> { //~ ERROR `'f` only used once
- | ^^
+ | ^^ -- ...is used only here
+ | |
+ | this lifetime...
|
note: lint level defined here
--> $DIR/two-uses-in-inherent-method-argument-and-return.rs:14:9
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: -Z parse-only
+
+// Issue #50974
+
+struct Foo {
+ a: u8,
+ b: u8
+}
+
+fn main() {
+ let bar = Foo {
+ a: 0,,
+ //~^ ERROR expected identifier
+ b: 42
+ };
+}
+
--- /dev/null
+error: expected identifier, found `,`
+ --> $DIR/struct-duplicate-comma.rs:22:14
+ |
+LL | let bar = Foo {
+ | --- while parsing this struct
+LL | a: 0,,
+ | ^
+ | |
+ | expected identifier
+ | help: remove this comma
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[macro_export]
+macro_rules! mac {
+ ($ident:ident) => { let $ident = 42; }
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// aux-build:macro-in-other-crate.rs
+
+#[macro_use] extern crate macro_in_other_crate;
+
+macro_rules! local_mac {
+ ($ident:ident) => { let $ident = 42; }
+}
+
fn main() {
let x = 2.0.neg();
//~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
+
let y = 2.0;
let x = y.neg();
//~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
println!("{:?}", x);
+
+ for i in 0..100 {
+ println!("{}", i.pow(2));
+ //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+ }
+
+ local_mac!(local_bar);
+ local_bar.pow(2);
+ //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+}
+
+fn qux() {
+ mac!(bar);
+ bar.pow(2);
+ //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
}
error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
- --> $DIR/method-on-ambiguous-numeric-type.rs:12:17
+ --> $DIR/method-on-ambiguous-numeric-type.rs:20:17
|
LL | let x = 2.0.neg();
| ^^^
| ^^^^^^^
error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
- --> $DIR/method-on-ambiguous-numeric-type.rs:15:15
+ --> $DIR/method-on-ambiguous-numeric-type.rs:24:15
|
LL | let x = y.neg();
| ^^^
LL | let y: f32 = 2.0;
| ^^^^^^
-error: aborting due to 2 previous errors
+error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
+ --> $DIR/method-on-ambiguous-numeric-type.rs:29:26
+ |
+LL | for i in 0..100 {
+ | - you must specify a type for this binding, like `i32`
+LL | println!("{}", i.pow(2));
+ | ^^^
+
+error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
+ --> $DIR/method-on-ambiguous-numeric-type.rs:34:15
+ |
+LL | local_bar.pow(2);
+ | ^^^
+help: you must specify a type for this binding, like `i32`
+ |
+LL | ($ident:ident) => { let $ident: i32 = 42; }
+ | ^^^^^^^^^^^
+
+error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
+ --> $DIR/method-on-ambiguous-numeric-type.rs:40:9
+ |
+LL | mac!(bar);
+ | ---------- you must specify a type for this binding, like `i32`
+LL | bar.pow(2);
+ | ^^^
+ |
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0689`.
let cargo_release = args.next().unwrap();
let rls_release = args.next().unwrap();
let rustfmt_release = args.next().unwrap();
+ let _llvm_tools_vers = args.next().unwrap(); // FIXME do something with it?
let s3_address = args.next().unwrap();
let mut passphrase = String::new();
t!(io::stdin().read_to_string(&mut passphrase));