diff --git a/Cargo.lock b/Cargo.lock index 365d14c579bdb..5e6bde1db7cd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,7 @@ dependencies = [ "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/src/liballoc/Cargo.toml b/src/liballoc/Cargo.toml index b2eb3566c04a7..861c7cecb8879 100644 --- a/src/liballoc/Cargo.toml +++ b/src/liballoc/Cargo.toml @@ -15,6 +15,7 @@ compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] } [dev-dependencies] rand = "0.6" +rand_xorshift = "0.1" [[test]] name = "collectionstests" diff --git a/src/liballoc/benches/btree/map.rs b/src/liballoc/benches/btree/map.rs index 20b9091a07bfc..6e2b5e06b7a91 100644 --- a/src/liballoc/benches/btree/map.rs +++ b/src/liballoc/benches/btree/map.rs @@ -12,7 +12,7 @@ use std::iter::Iterator; use std::vec::Vec; use std::collections::BTreeMap; -use rand::{Rng, thread_rng}; +use rand::{Rng, seq::SliceRandom, thread_rng}; use test::{Bencher, black_box}; macro_rules! map_insert_rand_bench { @@ -78,7 +78,7 @@ macro_rules! map_find_rand_bench { map.insert(k, k); } - rng.shuffle(&mut keys); + keys.shuffle(&mut rng); // measure let mut i = 0; diff --git a/src/liballoc/benches/lib.rs b/src/liballoc/benches/lib.rs index b4f4fd74f3a39..9502a7dc3c075 100644 --- a/src/liballoc/benches/lib.rs +++ b/src/liballoc/benches/lib.rs @@ -13,6 +13,7 @@ #![feature(test)] extern crate rand; +extern crate rand_xorshift; extern crate test; mod btree; diff --git a/src/liballoc/benches/slice.rs b/src/liballoc/benches/slice.rs index 490320f57cbf7..fc58899406332 100644 --- a/src/liballoc/benches/slice.rs +++ b/src/liballoc/benches/slice.rs @@ -12,8 +12,9 @@ use rand::{thread_rng}; use std::mem; use std::ptr; -use rand::{Rng, SeedableRng, XorShiftRng}; +use rand::{Rng, SeedableRng}; use rand::distributions::{Standard, Alphanumeric}; +use rand_xorshift::XorShiftRng; use test::{Bencher, black_box}; #[bench] diff --git a/src/liballoc/benches/str.rs b/src/liballoc/benches/str.rs index 38c94d4d8b5f3..c5e1576d24e26 100644 --- a/src/liballoc/benches/str.rs +++ b/src/liballoc/benches/str.rs @@ -274,11 +274,11 @@ make_test!(split_a_str, s, s.split("a").count()); make_test!(trim_ascii_char, s, { s.trim_matches(|c: char| c.is_ascii()) }); -make_test!(trim_left_ascii_char, s, { - s.trim_left_matches(|c: char| c.is_ascii()) +make_test!(trim_start_ascii_char, s, { + s.trim_start_matches(|c: char| c.is_ascii()) }); -make_test!(trim_right_ascii_char, s, { - s.trim_right_matches(|c: char| c.is_ascii()) +make_test!(trim_end_ascii_char, s, { + s.trim_end_matches(|c: char| c.is_ascii()) }); make_test!(find_underscore_char, s, s.find('_')); diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 4881f10fac25e..80dcdde4424c1 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -402,7 +402,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { hir::ExprKind::Closure(..) | hir::ExprKind::Lit(..) | - hir::ExprKind::Path(_) => { + hir::ExprKind::Path(_) | + hir::ExprKind::Err => { self.straightline(expr, pred, None::.iter()) } } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index f7e2c7036f6f8..db94a48b9b1d7 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -1109,6 +1109,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { ExprKind::Yield(ref subexpression) => { visitor.visit_expr(subexpression); } + ExprKind::Err => {} } } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 6958801d865bf..83e56b56c6c61 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2719,7 +2719,6 @@ impl<'a> LoweringContext<'a> { rules: self.lower_block_check_mode(&b.rules), span: b.span, targeted_by_break, - recovered: b.recovered, }) } @@ -3791,7 +3790,6 @@ impl<'a> LoweringContext<'a> { rules: hir::DefaultBlock, span, targeted_by_break: false, - recovered: blk.recovered, }); P(self.expr_block(blk, ThinVec::new())) } @@ -4127,6 +4125,8 @@ impl<'a> LoweringContext<'a> { hir::ExprKind::Yield(P(expr)) } + ExprKind::Err => hir::ExprKind::Err, + // Desugar `ExprIfLet` // from: `if let = []` ExprKind::IfLet(ref pats, ref sub_expr, ref body, ref else_opt) => { @@ -4831,7 +4831,6 @@ impl<'a> LoweringContext<'a> { rules: hir::DefaultBlock, span, targeted_by_break: false, - recovered: false, } } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 156d55b9e2fe6..9bcb54d05828a 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -817,11 +817,6 @@ pub struct Block { /// break out of this block early. /// Used by `'label: {}` blocks and by `catch` statements. pub targeted_by_break: bool, - /// If true, don't emit return value type errors as the parser had - /// to recover from a parse error so this block will not have an - /// appropriate type. A parse error will have been emitted so the - /// compilation will never succeed if this is true. - pub recovered: bool, } #[derive(Clone, RustcEncodable, RustcDecodable)] @@ -1372,6 +1367,7 @@ impl Expr { ExprKind::Struct(..) => ExprPrecedence::Struct, ExprKind::Repeat(..) => ExprPrecedence::Repeat, ExprKind::Yield(..) => ExprPrecedence::Yield, + ExprKind::Err => ExprPrecedence::Err, } } @@ -1422,7 +1418,8 @@ impl Expr { ExprKind::AddrOf(..) | ExprKind::Binary(..) | ExprKind::Yield(..) | - ExprKind::Cast(..) => { + ExprKind::Cast(..) | + ExprKind::Err => { false } } @@ -1535,6 +1532,9 @@ pub enum ExprKind { /// A suspension point for generators. This is `yield ` in Rust. Yield(P), + + /// Placeholder for an expression that wasn't syntactically well formed in some way. + Err, } /// Optionally `Self`-qualified value/type path or associated extension. @@ -1979,6 +1979,15 @@ pub enum FunctionRetTy { Return(P), } +impl fmt::Display for FunctionRetTy { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Return(ref ty) => print::to_string(print::NO_ANN, |s| s.print_type(ty)).fmt(f), + DefaultReturn(_) => "()".fmt(f), + } + } +} + impl FunctionRetTy { pub fn span(&self) -> Span { match *self { @@ -2119,7 +2128,7 @@ impl StructField { /// Id of the whole enum lives in `Item`. /// /// For structs: `NodeId` represents an Id of the structure's constructor, so it is not actually -/// used for `Struct`-structs (but still presents). Structures don't have an analogue of "Id of +/// used for `Struct`-structs (but still present). Structures don't have an analogue of "Id of /// the variant itself" from enum variants. /// Id of the whole struct lives in `Item`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 5c6845181afd1..93194870a4a1e 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -440,7 +440,9 @@ impl<'a> State<'a> { self.s.word("_")?; } hir::TyKind::Err => { - self.s.word("?")?; + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()?; } } self.end() @@ -1550,6 +1552,11 @@ impl<'a> State<'a> { self.word_space("yield")?; self.print_expr_maybe_paren(&expr, parser::PREC_JUMP)?; } + hir::ExprKind::Err => { + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()?; + } } self.ann.post(self, AnnNode::Expr(expr))?; self.end() diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index ae0d78d2958ad..cd8360678b50c 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -420,7 +420,6 @@ impl_stable_hash_for!(struct hir::Block { rules, span, targeted_by_break, - recovered, }); impl_stable_hash_for!(struct hir::Pat { @@ -602,7 +601,8 @@ impl_stable_hash_for!(enum hir::ExprKind { InlineAsm(asm, inputs, outputs), Struct(path, fields, base), Repeat(val, times), - Yield(val) + Yield(val), + Err }); impl_stable_hash_for!(enum hir::LocalSource { diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 9ab8e89df72e6..219429d4cbc0c 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -232,14 +232,13 @@ impl<'a> LintLevelsBuilder<'a> { match item.node { ast::MetaItemKind::Word => {} // actual lint names handled later ast::MetaItemKind::NameValue(ref name_value) => { - let gate_reasons = !self.sess.features_untracked().lint_reasons; if item.ident == "reason" { // found reason, reslice meta list to exclude it metas = &metas[0..metas.len()-1]; // FIXME (#55112): issue unused-attributes lint if we thereby // don't have any lint names (`#[level(reason = "foo")]`) if let ast::LitKind::Str(rationale, _) = name_value.node { - if gate_reasons { + if !self.sess.features_untracked().lint_reasons { feature_gate::emit_feature_err( &self.sess.parse_sess, "lint_reasons", @@ -247,9 +246,8 @@ impl<'a> LintLevelsBuilder<'a> { feature_gate::GateIssue::Language, "lint reasons are experimental" ); - } else { - reason = Some(rationale); } + reason = Some(rationale); } else { let mut err = bad_attr(name_value.span); err.help("reason must be a string literal"); diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 934d7c12be552..d2175c28309b1 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -25,6 +25,8 @@ use middle::privacy; use ty::{self, TyCtxt}; use util::nodemap::FxHashSet; +use rustc_data_structures::fx::FxHashMap; + use syntax::{ast, source_map}; use syntax::attr; use syntax_pos; @@ -55,12 +57,15 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> { in_pat: bool, inherited_pub_visibility: bool, ignore_variant_stack: Vec, + // maps from tuple struct constructors to tuple struct items + struct_constructors: FxHashMap, } impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { fn check_def_id(&mut self, def_id: DefId) { if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) { - if should_explore(self.tcx, node_id) { + if should_explore(self.tcx, node_id) || + self.struct_constructors.contains_key(&node_id) { self.worklist.push(node_id); } self.live_symbols.insert(node_id); @@ -137,19 +142,23 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { continue } - if let Some(ref node) = self.tcx.hir().find(id) { + // in the case of tuple struct constructors we want to check the item, not the generated + // tuple struct constructor function + let id = self.struct_constructors.get(&id).cloned().unwrap_or(id); + + if let Some(node) = self.tcx.hir().find(id) { self.live_symbols.insert(id); self.visit_node(node); } } } - fn visit_node(&mut self, node: &Node<'tcx>) { + fn visit_node(&mut self, node: Node<'tcx>) { let had_repr_c = self.repr_has_repr_c; self.repr_has_repr_c = false; let had_inherited_pub_visibility = self.inherited_pub_visibility; self.inherited_pub_visibility = false; - match *node { + match node { Node::Item(item) => { match item.node { hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { @@ -337,6 +346,8 @@ struct LifeSeeder<'k, 'tcx: 'k> { worklist: Vec, krate: &'k hir::Crate, tcx: TyCtxt<'k, 'tcx, 'tcx>, + // see `MarkSymbolVisitor::struct_constructors` + struct_constructors: FxHashMap, } impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { @@ -379,6 +390,9 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { } } } + hir::ItemKind::Struct(ref variant_data, _) => { + self.struct_constructors.insert(variant_data.id(), item.id); + } _ => () } } @@ -392,11 +406,11 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> { } } -fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - access_levels: &privacy::AccessLevels, - krate: &hir::Crate) - -> Vec -{ +fn create_and_seed_worklist<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + access_levels: &privacy::AccessLevels, + krate: &hir::Crate, +) -> (Vec, FxHashMap) { let worklist = access_levels.map.iter().filter_map(|(&id, level)| { if level >= &privacy::AccessLevel::Reachable { Some(id) @@ -413,17 +427,18 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, worklist, krate, tcx, + struct_constructors: Default::default(), }; krate.visit_all_item_likes(&mut life_seeder); - return life_seeder.worklist; + (life_seeder.worklist, life_seeder.struct_constructors) } fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &privacy::AccessLevels, krate: &hir::Crate) -> FxHashSet { - let worklist = create_and_seed_worklist(tcx, access_levels, krate); + let (worklist, struct_constructors) = create_and_seed_worklist(tcx, access_levels, krate); let mut symbol_visitor = MarkSymbolVisitor { worklist, tcx, @@ -433,20 +448,12 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, in_pat: false, inherited_pub_visibility: false, ignore_variant_stack: vec![], + struct_constructors, }; symbol_visitor.mark_live_symbols(); symbol_visitor.live_symbols } -fn get_struct_ctor_id(item: &hir::Item) -> Option { - match item.node { - hir::ItemKind::Struct(ref struct_def, _) if !struct_def.is_struct() => { - Some(struct_def.id()) - } - _ => None - } -} - struct DeadVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, live_symbols: FxHashSet, @@ -464,46 +471,35 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { | hir::ItemKind::Union(..) => true, _ => false }; - let ctor_id = get_struct_ctor_id(item); - should_warn && !self.symbol_is_live(item.id, ctor_id) + should_warn && !self.symbol_is_live(item.id) } fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool { let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id)); !field.is_positional() - && !self.symbol_is_live(field.id, None) + && !self.symbol_is_live(field.id) && !field_type.is_phantom_data() && !has_allow_dead_code_or_lang_attr(self.tcx, field.id, &field.attrs) } fn should_warn_about_variant(&mut self, variant: &hir::VariantKind) -> bool { - !self.symbol_is_live(variant.data.id(), None) + !self.symbol_is_live(variant.data.id()) && !has_allow_dead_code_or_lang_attr(self.tcx, variant.data.id(), &variant.attrs) } fn should_warn_about_foreign_item(&mut self, fi: &hir::ForeignItem) -> bool { - !self.symbol_is_live(fi.id, None) + !self.symbol_is_live(fi.id) && !has_allow_dead_code_or_lang_attr(self.tcx, fi.id, &fi.attrs) } // id := node id of an item's definition. - // ctor_id := `Some` if the item is a struct_ctor (tuple struct), - // `None` otherwise. - // If the item is a struct_ctor, then either its `id` or - // `ctor_id` (unwrapped) is in the live_symbols set. More specifically, - // DefMap maps the ExprKind::Path of a struct_ctor to the node referred by - // `ctor_id`. On the other hand, in a statement like - // `type = ;` where refers to a struct_ctor, - // DefMap maps to `id` instead. - fn symbol_is_live(&mut self, - id: ast::NodeId, - ctor_id: Option) - -> bool { - if self.live_symbols.contains(&id) - || ctor_id.map_or(false, |ctor| self.live_symbols.contains(&ctor)) - { + fn symbol_is_live( + &mut self, + id: ast::NodeId, + ) -> bool { + if self.live_symbols.contains(&id) { return true; } // If it's a type whose items are live, then it's live, too. @@ -611,7 +607,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { match impl_item.node { hir::ImplItemKind::Const(_, body_id) => { - if !self.symbol_is_live(impl_item.id, None) { + if !self.symbol_is_live(impl_item.id) { self.warn_dead_code(impl_item.id, impl_item.span, impl_item.ident.name, @@ -621,7 +617,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { self.visit_nested_body(body_id) } hir::ImplItemKind::Method(_, body_id) => { - if !self.symbol_is_live(impl_item.id, None) { + if !self.symbol_is_live(impl_item.id) { let span = self.tcx.sess.source_map().def_span(impl_item.span); self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used"); } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index f1bc37d03e5a1..02ae4737eaacb 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -489,7 +489,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } hir::ExprKind::Continue(..) | - hir::ExprKind::Lit(..) => {} + hir::ExprKind::Lit(..) | + hir::ExprKind::Err => {} hir::ExprKind::Loop(ref blk, _, _) => { self.walk_block(&blk); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index d1d2fa298a6ca..b5937697c5183 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -525,6 +525,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { hir::ExprKind::Box(..) | hir::ExprKind::Yield(..) | hir::ExprKind::Type(..) | + hir::ExprKind::Err | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { intravisit::walk_expr(ir, expr); } @@ -1264,7 +1265,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_exprs(inputs, succ) } - hir::ExprKind::Lit(..) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { + hir::ExprKind::Lit(..) | hir::ExprKind::Err | + hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { succ } @@ -1531,7 +1533,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { hir::ExprKind::Block(..) | hir::ExprKind::AddrOf(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | hir::ExprKind::Closure(..) | hir::ExprKind::Path(_) | hir::ExprKind::Yield(..) | - hir::ExprKind::Box(..) | hir::ExprKind::Type(..) => { + hir::ExprKind::Box(..) | hir::ExprKind::Type(..) | hir::ExprKind::Err => { intravisit::walk_expr(this, expr); } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index a04914e977493..bd1817fff5399 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -697,7 +697,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Match(..) | hir::ExprKind::Lit(..) | hir::ExprKind::Break(..) | hir::ExprKind::Continue(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | - hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) => { + hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) | hir::ExprKind::Err => { Ok(self.cat_rvalue_node(expr.hir_id, expr.span, expr_ty)) } } diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 90aa9f6cbc763..5fad4a24b262e 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -335,11 +335,20 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { bx: &mut Bx, llindex: V ) -> Self { + // Statically compute the offset if we can, otherwise just use the element size, + // as this will yield the lowest alignment. + let layout = self.layout.field(bx, 0); + let offset = if bx.is_const_integral(llindex) { + layout.size.checked_mul(bx.const_to_uint(llindex), bx).unwrap_or(layout.size) + } else { + layout.size + }; + PlaceRef { llval: bx.inbounds_gep(self.llval, &[bx.cx().const_usize(0), llindex]), llextra: None, - layout: self.layout.field(bx.cx(), 0), - align: self.align + layout, + align: self.align.restrict_for_offset(offset), } } diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index c932ffd1c1bda..052342dd7597b 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -131,8 +131,9 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let keep_going = header_bx.icmp(IntPredicate::IntNE, current, end); header_bx.cond_br(keep_going, body_bx.llbb(), next_bx.llbb()); + let align = dest.align.restrict_for_offset(dest.layout.field(bx.cx(), 0).size); cg_elem.val.store(&mut body_bx, - PlaceRef::new_sized(current, cg_elem.layout, dest.align)); + PlaceRef::new_sized(current, cg_elem.layout, align)); let next = body_bx.inbounds_gep(current, &[bx.cx().const_usize(1)]); body_bx.br(header_bx.llbb()); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 55e052882ea5b..43fc91ea4827f 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -997,7 +997,6 @@ where }; let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver); - let err_count = ecx.parse_sess.span_diagnostic.err_count(); // Expand macros now! let krate = time(sess, "expand crate", || { @@ -1023,9 +1022,6 @@ where let msg = "missing fragment specifier"; sess.buffer_lint(lint, ast::CRATE_NODE_ID, span, msg); } - if ecx.parse_sess.span_diagnostic.err_count() - ecx.resolve_err_count > err_count { - ecx.parse_sess.span_diagnostic.abort_if_errors(); - } if cfg!(windows) { env::set_var("PATH", &old_path); } @@ -1129,12 +1125,6 @@ where }) })?; - // Unresolved macros might be due to mistyped `#[macro_use]`, - // so abort after checking for unknown attributes. (#49074) - if resolver.found_unresolved_macro { - sess.diagnostic().abort_if_errors(); - } - // Lower ast -> hir. // First, we need to collect the dep_graph. let dep_graph = match future_dep_graph { diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index bc991016bbee5..551244f7fe227 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -751,7 +751,6 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { fn fold_block(&mut self, b: P) -> P { fn stmt_to_block(rules: ast::BlockCheckMode, - recovered: bool, s: Option, sess: &Session) -> ast::Block { ast::Block { @@ -759,7 +758,6 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { rules, id: sess.next_node_id(), span: syntax_pos::DUMMY_SP, - recovered, } } @@ -778,7 +776,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { } } - let empty_block = stmt_to_block(BlockCheckMode::Default, false, None, self.sess); + let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess); let loop_expr = P(ast::Expr { node: ast::ExprKind::Loop(P(empty_block), None), id: self.sess.next_node_id(), @@ -819,7 +817,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { old_blocks.push(new_block); } - stmt_to_block(b.rules, b.recovered, Some(loop_stmt), self.sess) + stmt_to_block(b.rules, Some(loop_stmt), self.sess) } else { //push `loop {}` onto the end of our fresh block and yield that new_block.stmts.push(loop_stmt); diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 146bf53830656..64defaf78a487 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -126,18 +126,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ExprKind::LogicalOp { op, lhs, rhs } => { // And: // - // [block: If(lhs)] -true-> [else_block: If(rhs)] -true-> [true_block] - // | | (false) - // +----------false-----------+------------------> [false_block] + // [block: If(lhs)] -true-> [else_block: dest = (rhs)] + // | (false) + // [shortcurcuit_block: dest = false] // // Or: // - // [block: If(lhs)] -false-> [else_block: If(rhs)] -true-> [true_block] - // | (true) | (false) - // [true_block] [false_block] + // [block: If(lhs)] -false-> [else_block: dest = (rhs)] + // | (true) + // [shortcurcuit_block: dest = true] - let (true_block, false_block, mut else_block, join_block) = ( - this.cfg.start_new_block(), + let (shortcircuit_block, mut else_block, join_block) = ( this.cfg.start_new_block(), this.cfg.start_new_block(), this.cfg.start_new_block(), @@ -145,47 +144,41 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let lhs = unpack!(block = this.as_local_operand(block, lhs)); let blocks = match op { - LogicalOp::And => (else_block, false_block), - LogicalOp::Or => (true_block, else_block), + LogicalOp::And => (else_block, shortcircuit_block), + LogicalOp::Or => (shortcircuit_block, else_block), }; let term = TerminatorKind::if_(this.hir.tcx(), lhs, blocks.0, blocks.1); this.cfg.terminate(block, source_info, term); - let rhs = unpack!(else_block = this.as_local_operand(else_block, rhs)); - let term = TerminatorKind::if_(this.hir.tcx(), rhs, true_block, false_block); - this.cfg.terminate(else_block, source_info, term); - this.cfg.push_assign_constant( - true_block, + shortcircuit_block, source_info, destination, Constant { span: expr_span, ty: this.hir.bool_ty(), user_ty: None, - literal: this.hir.true_literal(), + literal: match op { + LogicalOp::And => this.hir.false_literal(), + LogicalOp::Or => this.hir.true_literal(), + }, }, ); - - this.cfg.push_assign_constant( - false_block, + this.cfg.terminate( + shortcircuit_block, source_info, - destination, - Constant { - span: expr_span, - ty: this.hir.bool_ty(), - user_ty: None, - literal: this.hir.false_literal(), - }, + TerminatorKind::Goto { target: join_block }, ); - this.cfg.terminate( - true_block, + let rhs = unpack!(else_block = this.as_local_operand(else_block, rhs)); + this.cfg.push_assign( + else_block, source_info, - TerminatorKind::Goto { target: join_block }, + destination, + Rvalue::Use(rhs), ); this.cfg.terminate( - false_block, + else_block, source_info, TerminatorKind::Goto { target: join_block }, ); diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index f93dbce97b54a..5a8ffb8059840 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -790,6 +790,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, hir::ExprKind::Tup(ref fields) => ExprKind::Tuple { fields: fields.to_ref() }, hir::ExprKind::Yield(ref v) => ExprKind::Yield { value: v.to_ref() }, + hir::ExprKind::Err => unreachable!(), }; Expr { diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index b854f029e5106..646a671d4a2ce 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -518,7 +518,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { // Only allow statics (not consts) to refer to other statics. if self.mode == Mode::Static || self.mode == Mode::StaticMut { - if context.is_mutating_use() { + if self.mode == Mode::Static && context.is_mutating_use() { // this is not strictly necessary as miri will also bail out // For interior mutability we can't really catch this statically as that // goes through raw pointers and intermediate temporaries, so miri has diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 9a35721e3e1c4..259888412a98d 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -288,25 +288,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> { visit::walk_ty(self, ty) } - fn visit_use_tree(&mut self, use_tree: &'a UseTree, id: NodeId, _nested: bool) { - // Check if the path in this `use` is not generic, such as `use foo::bar;` While this - // can't happen normally thanks to the parser, a generic might sneak in if the `use` is - // built using a macro. - // - // macro_use foo { - // ($p:path) => { use $p; } - // } - // foo!(bar::baz); - use_tree.prefix.segments.iter().find(|segment| { - segment.args.is_some() - }).map(|segment| { - self.err_handler().span_err(segment.args.as_ref().unwrap().span(), - "generic arguments in import path"); - }); - - visit::walk_use_tree(self, use_tree, id); - } - fn visit_label(&mut self, label: &'a Label) { self.check_label(label.ident); visit::walk_label(self, label); @@ -443,17 +424,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> { visit::walk_foreign_item(self, fi) } - fn visit_vis(&mut self, vis: &'a Visibility) { - if let VisibilityKind::Restricted { ref path, .. } = vis.node { - path.segments.iter().find(|segment| segment.args.is_some()).map(|segment| { - self.err_handler().span_err(segment.args.as_ref().unwrap().span(), - "generic arguments in visibility path"); - }); - } - - visit::walk_vis(self, vis) - } - fn visit_generics(&mut self, generics: &'a Generics) { let mut seen_non_lifetime_param = false; let mut seen_default = None; diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index bfe8b677a5e80..2f0fbe477754f 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -459,7 +459,8 @@ fn check_expr_kind<'a, 'tcx>( struct_result } - hir::ExprKind::Lit(_) => Promotable, + hir::ExprKind::Lit(_) | + hir::ExprKind::Err => Promotable, hir::ExprKind::AddrOf(_, ref expr) | hir::ExprKind::Repeat(ref expr, _) => { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 794e5741d62ca..aca38a6d5874d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1584,7 +1584,6 @@ pub struct Resolver<'a> { macro_map: FxHashMap>, macro_defs: FxHashMap, local_macro_def_scopes: FxHashMap>, - pub found_unresolved_macro: bool, /// List of crate local macros that we need to warn about as being unused. /// Right now this only includes macro_rules! macros, and macros 2.0. @@ -1919,7 +1918,6 @@ impl<'a> Resolver<'a> { name_already_seen: FxHashMap::default(), potentially_unused_imports: Vec::new(), struct_constructors: Default::default(), - found_unresolved_macro: false, unused_macros: FxHashSet::default(), current_type_ascription: Vec::new(), injected_crate: None, @@ -2032,8 +2030,10 @@ impl<'a> Resolver<'a> { record_used_id: Option, path_span: Span) -> Option> { - let record_used = record_used_id.is_some(); assert!(ns == TypeNS || ns == ValueNS); + if ident.name == keywords::Invalid.name() { + return Some(LexicalScopeBinding::Def(Def::Err)); + } if ns == TypeNS { ident.span = if ident.name == keywords::SelfUpper.name() { // FIXME(jseyfried) improve `Self` hygiene @@ -2046,6 +2046,7 @@ impl<'a> Resolver<'a> { } // Walk backwards up the ribs in scope. + let record_used = record_used_id.is_some(); let mut module = self.graph_root; for i in (0 .. self.ribs[ns].len()).rev() { if let Some(def) = self.ribs[ns][i].bindings.get(&ident).cloned() { @@ -3213,23 +3214,43 @@ impl<'a> Resolver<'a> { let enum_candidates = this.lookup_import_candidates(ident, ns, is_enum_variant); let mut enum_candidates = enum_candidates.iter() - .map(|suggestion| import_candidate_to_paths(&suggestion)).collect::>(); + .map(|suggestion| { + import_candidate_to_enum_paths(&suggestion) + }).collect::>(); enum_candidates.sort(); - for (sp, variant_path, enum_path) in enum_candidates { - if sp.is_dummy() { - let msg = format!("there is an enum variant `{}`, \ - try using `{}`?", - variant_path, - enum_path); - err.help(&msg); + + if !enum_candidates.is_empty() { + // contextualize for E0412 "cannot find type", but don't belabor the point + // (that it's a variant) for E0573 "expected type, found variant" + let preamble = if def.is_none() { + let others = match enum_candidates.len() { + 1 => String::new(), + 2 => " and 1 other".to_owned(), + n => format!(" and {} others", n) + }; + format!("there is an enum variant `{}`{}; ", + enum_candidates[0].0, others) } else { - err.span_suggestion_with_applicability( - span, - "you can try using the variant's enum", - enum_path, - Applicability::MachineApplicable, - ); - } + String::new() + }; + let msg = format!("{}try using the variant's enum", preamble); + + err.span_suggestions_with_applicability( + span, + &msg, + enum_candidates.into_iter() + .map(|(_variant_path, enum_ty_path)| enum_ty_path) + // variants reĆ«xported in prelude doesn't mean `prelude::v1` is the + // type name! FIXME: is there a more principled way to do this that + // would work for other reĆ«xports? + .filter(|enum_ty_path| enum_ty_path != "std::prelude::v1") + // also say `Option` rather than `std::prelude::v1::Option` + .map(|enum_ty_path| { + // FIXME #56861: DRYer prelude filtering + enum_ty_path.trim_start_matches("std::prelude::v1::").to_owned() + }), + Applicability::MachineApplicable, + ); } } if path.len() == 1 && this.self_type_is_available(span) { @@ -5128,8 +5149,8 @@ fn path_names_to_string(path: &Path) -> String { .collect::>()) } -/// Get the path for an enum and the variant from an `ImportSuggestion` for an enum variant. -fn import_candidate_to_paths(suggestion: &ImportSuggestion) -> (Span, String, String) { +/// Get the stringified path for an enum from an `ImportSuggestion` for an enum variant. +fn import_candidate_to_enum_paths(suggestion: &ImportSuggestion) -> (String, String) { let variant_path = &suggestion.path; let variant_path_string = path_names_to_string(variant_path); @@ -5140,7 +5161,7 @@ fn import_candidate_to_paths(suggestion: &ImportSuggestion) -> (Span, String, St }; let enum_path_string = path_names_to_string(&enum_path); - (suggestion.path.span, variant_path_string, enum_path_string) + (variant_path_string, enum_path_string) } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 81633c8f57f9e..64a5f1e3b6fb4 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -192,7 +192,14 @@ impl<'a> base::Resolver for Resolver<'a> { }; let parent_scope = self.invoc_parent_scope(invoc_id, derives_in_scope); - let (def, ext) = self.resolve_macro_to_def(path, kind, &parent_scope, true, force)?; + let (def, ext) = match self.resolve_macro_to_def(path, kind, &parent_scope, true, force) { + Ok((def, ext)) => (def, ext), + Err(Determinacy::Determined) if kind == MacroKind::Attr => { + // Replace unresolved attributes with used inert attributes for better recovery. + return Ok(Some(Lrc::new(SyntaxExtension::NonMacroAttr { mark_used: true }))); + } + Err(determinacy) => return Err(determinacy), + }; if let Def::Macro(def_id, _) = def { if after_derive { @@ -347,7 +354,6 @@ impl<'a> Resolver<'a> { } PathResult::Indeterminate if !force => return Err(Determinacy::Undetermined), PathResult::NonModule(..) | PathResult::Indeterminate | PathResult::Failed(..) => { - self.found_unresolved_macro = true; Err(Determinacy::Determined) } PathResult::Module(..) => unreachable!(), @@ -363,10 +369,8 @@ impl<'a> Resolver<'a> { let binding = self.early_resolve_ident_in_lexical_scope( path[0].ident, ScopeSet::Macro(kind), parent_scope, false, force, path_span ); - match binding { - Ok(..) => {} - Err(Determinacy::Determined) => self.found_unresolved_macro = true, - Err(Determinacy::Undetermined) => return Err(Determinacy::Undetermined), + if let Err(Determinacy::Undetermined) = binding { + return Err(Determinacy::Undetermined); } if trace { @@ -868,14 +872,23 @@ impl<'a> Resolver<'a> { pub fn finalize_current_module_macro_resolutions(&mut self) { let module = self.current_module; - let check_consistency = |this: &mut Self, path: &[Segment], span, - kind: MacroKind, initial_def, def| { + let check_consistency = |this: &mut Self, path: &[Segment], span, kind: MacroKind, + initial_def: Option, def: Def| { if let Some(initial_def) = initial_def { if def != initial_def && def != Def::Err && this.ambiguity_errors.is_empty() { // Make sure compilation does not succeed if preferred macro resolution // has changed after the macro had been expanded. In theory all such // situations should be reported as ambiguity errors, so this is a bug. - span_bug!(span, "inconsistent resolution for a macro"); + if initial_def == Def::NonMacroAttr(NonMacroAttrKind::Custom) { + // Yeah, legacy custom attributes are implemented using forced resolution + // (which is a best effort error recovery tool, basically), so we can't + // promise their resolution won't change later. + let msg = format!("inconsistent resolution for a macro: first {}, then {}", + initial_def.kind_name(), def.kind_name()); + this.session.span_err(span, &msg); + } else { + span_bug!(span, "inconsistent resolution for a macro"); + } } } else { // It's possible that the macro was unresolved (indeterminate) and silently diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 9a1f9784192c1..8b2be84942388 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1169,7 +1169,6 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> // `expression_ty` will be unit). // // Another example is `break` with no argument expression. - assert!(expression_ty.is_unit()); assert!(expression_ty.is_unit(), "if let hack without unit type"); fcx.at(cause, fcx.param_env) .eq_exp(label_expression_as_expected, expression_ty, self.merged_ty()) @@ -1210,13 +1209,14 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> (self.final_ty.unwrap_or(self.expected_ty), expression_ty) }; + let reason_label = "expected because of this statement"; let mut db; match cause.code { ObligationCauseCode::ReturnNoExpression => { db = struct_span_err!( fcx.tcx.sess, cause.span, E0069, "`return;` in a function whose return type is not `()`"); - db.span_label(cause.span, "return type is not ()"); + db.span_label(cause.span, "return type is not `()`"); } ObligationCauseCode::BlockTailExpression(blk_id) => { db = fcx.report_mismatched_types(cause, expected, found, err); @@ -1234,9 +1234,19 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> cause.span, blk_id, ); + if let Some(sp) = fcx.ret_coercion_span.borrow().as_ref() { + if !sp.overlaps(cause.span) { + db.span_label(*sp, reason_label); + } + } } _ => { db = fcx.report_mismatched_types(cause, expected, found, err); + if let Some(sp) = fcx.ret_coercion_span.borrow().as_ref() { + if !sp.overlaps(cause.span) { + db.span_label(*sp, reason_label); + } + } } } diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index db4b68611c51b..996b57f558cc5 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -123,6 +123,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let sole_field_ty = sole_field.ty(self.tcx, substs); if self.can_coerce(expr_ty, sole_field_ty) { let variant_path = self.tcx.item_path_str(variant.did); + // FIXME #56861: DRYer prelude filtering Some(variant_path.trim_start_matches("std::prelude::v1::").to_string()) } else { None diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d45f8fd6de8d9..9c82640af844e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -538,6 +538,7 @@ pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { err_count_on_creation: usize, ret_coercion: Option>>, + ret_coercion_span: RefCell>, yield_ty: Option>, @@ -1987,6 +1988,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { param_env, err_count_on_creation: inh.tcx.sess.err_count(), ret_coercion: None, + ret_coercion_span: RefCell::new(None), yield_ty: None, ps: RefCell::new(UnsafetyState::function(hir::Unsafety::Normal, ast::CRATE_NODE_ID)), @@ -3440,7 +3442,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { len.assert_usize(self.tcx), field.as_str().parse::() ) { - let base = self.tcx.hir().node_to_pretty_string(base.id); + let base = self.tcx.sess.source_map() + .span_to_snippet(base.span) + .unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id)); let help = "instead of using tuple indexing, use array indexing"; let suggestion = format!("{}[{}]", base, field); let applicability = if len < user_index { @@ -3454,11 +3458,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } ty::RawPtr(..) => { - let base = self.tcx.hir().node_to_pretty_string(base.id); - let msg = format!("`{}` is a native pointer; try dereferencing it", base); + let base = self.tcx.sess.source_map() + .span_to_snippet(base.span) + .unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id)); + let msg = format!("`{}` is a raw pointer; try dereferencing it", base); let suggestion = format!("(*{}).{}", base, field); err.span_suggestion_with_applicability( - field.span, + expr.span, &msg, suggestion, Applicability::MaybeIncorrect, @@ -4168,11 +4174,30 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { struct_span_err!(self.tcx.sess, expr.span, E0572, "return statement outside of function body").emit(); } else if let Some(ref e) = *expr_opt { + *self.ret_coercion_span.borrow_mut() = Some(e.span); self.check_return_expr(e); } else { let mut coercion = self.ret_coercion.as_ref().unwrap().borrow_mut(); + *self.ret_coercion_span.borrow_mut() = Some(expr.span); let cause = self.cause(expr.span, ObligationCauseCode::ReturnNoExpression); - coercion.coerce_forced_unit(self, &cause, &mut |_| (), true); + if let Some((fn_decl, _)) = self.get_fn_decl(expr.id) { + coercion.coerce_forced_unit( + self, + &cause, + &mut |db| { + db.span_label( + fn_decl.output.span(), + format!( + "expected `{}` because of this return type", + fn_decl.output, + ), + ); + }, + true, + ); + } else { + coercion.coerce_forced_unit(self, &cause, &mut |_| (), true); + } } tcx.types.never } @@ -4498,6 +4523,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } tcx.mk_unit() } + hir::ExprKind::Err => { + tcx.types.err + } } } @@ -4754,12 +4782,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // // #41425 -- label the implicit `()` as being the // "found type" here, rather than the "expected type". - // - // #44579 -- if the block was recovered during parsing, - // the type would be nonsensical and it is not worth it - // to perform the type check, so we avoid generating the - // diagnostic output. - if !self.diverges.get().always() && !blk.recovered { + if !self.diverges.get().always() { coerce.coerce_forced_unit(self, &self.misc(blk.span), &mut |err| { if let Some(expected_ty) = expected.only_has_type(self) { self.consider_hint_about_removing_semicolon(blk, diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index a4eafee36d1a1..5e70c7be1fef1 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2220,7 +2220,6 @@ fn from_target_feature( feature_gate::GateIssue::Language, &format!("the target feature `{}` is currently unstable", feature), ); - return None; } Some(Symbol::intern(feature)) })); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0792b2dc49c27..46d12a1706564 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -454,7 +454,6 @@ pub struct Block { /// Distinguishes between `unsafe { ... }` and `{ ... }` pub rules: BlockCheckMode, pub span: Span, - pub recovered: bool, } #[derive(Clone, RustcEncodable, RustcDecodable)] @@ -1011,6 +1010,7 @@ impl Expr { ExprKind::Paren(..) => ExprPrecedence::Paren, ExprKind::Try(..) => ExprPrecedence::Try, ExprKind::Yield(..) => ExprPrecedence::Yield, + ExprKind::Err => ExprPrecedence::Err, } } } @@ -1170,6 +1170,9 @@ pub enum ExprKind { /// A `yield`, with an optional value to be yielded. Yield(Option>), + + /// Placeholder for an expression that wasn't syntactically well formed in some way. + Err, } /// The explicit `Self` type in a "qualified path". The actual diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b807a65f6aed6..5adb9868e238f 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -12,7 +12,7 @@ pub use self::SyntaxExtension::*; use ast::{self, Attribute, Name, PatKind, MetaItem}; use attr::HasAttrs; -use source_map::{self, SourceMap, Spanned, respan}; +use source_map::{SourceMap, Spanned, respan}; use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use edition::Edition; use errors::{DiagnosticBuilder, DiagnosticId}; @@ -466,7 +466,8 @@ impl MacResult for MacEager { #[derive(Copy, Clone)] pub struct DummyResult { expr_only: bool, - span: Span + is_error: bool, + span: Span, } impl DummyResult { @@ -474,8 +475,13 @@ impl DummyResult { /// /// Use this as a return value after hitting any errors and /// calling `span_err`. - pub fn any(sp: Span) -> Box { - Box::new(DummyResult { expr_only: false, span: sp }) + pub fn any(span: Span) -> Box { + Box::new(DummyResult { expr_only: false, is_error: true, span }) + } + + /// Same as `any`, but must be a valid fragment, not error. + pub fn any_valid(span: Span) -> Box { + Box::new(DummyResult { expr_only: false, is_error: false, span }) } /// Create a default MacResult that can only be an expression. @@ -483,15 +489,15 @@ impl DummyResult { /// Use this for macros that must expand to an expression, so even /// if an error is encountered internally, the user will receive /// an error that they also used it in the wrong place. - pub fn expr(sp: Span) -> Box { - Box::new(DummyResult { expr_only: true, span: sp }) + pub fn expr(span: Span) -> Box { + Box::new(DummyResult { expr_only: true, is_error: true, span }) } /// A plain dummy expression. - pub fn raw_expr(sp: Span) -> P { + pub fn raw_expr(sp: Span, is_error: bool) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Lit(source_map::respan(sp, ast::LitKind::Bool(false))), + node: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) }, span: sp, attrs: ThinVec::new(), }) @@ -506,10 +512,11 @@ impl DummyResult { } } - pub fn raw_ty(sp: Span) -> P { + /// A plain dummy type. + pub fn raw_ty(sp: Span, is_error: bool) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: ast::TyKind::Infer, + node: if is_error { ast::TyKind::Err } else { ast::TyKind::Tup(Vec::new()) }, span: sp }) } @@ -517,7 +524,7 @@ impl DummyResult { impl MacResult for DummyResult { fn make_expr(self: Box) -> Option> { - Some(DummyResult::raw_expr(self.span)) + Some(DummyResult::raw_expr(self.span, self.is_error)) } fn make_pat(self: Box) -> Option> { @@ -560,13 +567,13 @@ impl MacResult for DummyResult { fn make_stmts(self: Box) -> Option> { Some(smallvec![ast::Stmt { id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Expr(DummyResult::raw_expr(self.span)), + node: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)), span: self.span, }]) } fn make_ty(self: Box) -> Option> { - Some(DummyResult::raw_ty(self.span)) + Some(DummyResult::raw_ty(self.span, self.is_error)) } } @@ -806,7 +813,6 @@ pub struct ExtCtxt<'a> { pub ecfg: expand::ExpansionConfig<'a>, pub root_path: PathBuf, pub resolver: &'a mut dyn Resolver, - pub resolve_err_count: usize, pub current_expansion: ExpansionData, pub expansions: FxHashMap>, } @@ -821,7 +827,6 @@ impl<'a> ExtCtxt<'a> { ecfg, root_path: PathBuf::new(), resolver, - resolve_err_count: 0, current_expansion: ExpansionData { mark: Mark::root(), depth: 0, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 5770f6bb8a28c..b1673a807e304 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -597,7 +597,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, rules: BlockCheckMode::Default, span, - recovered: false, }) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 57ccc3e981720..d2320af11dcf8 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -354,8 +354,10 @@ impl<'a, 'b> MacroExpander<'a, 'b> { // FIXME(jseyfried): Refactor out the following logic let (expanded_fragment, new_invocations) = if let Some(ext) = ext { if let Some(ext) = ext { - let dummy = invoc.fragment_kind.dummy(invoc.span()).unwrap(); - let fragment = self.expand_invoc(invoc, &*ext).unwrap_or(dummy); + let (invoc_fragment_kind, invoc_span) = (invoc.fragment_kind, invoc.span()); + let fragment = self.expand_invoc(invoc, &*ext).unwrap_or_else(|| { + invoc_fragment_kind.dummy(invoc_span).unwrap() + }); self.collect_invocations(fragment, &[]) } else if let InvocationKind::Attr { attr: None, traits, item, .. } = invoc.kind { if !item.derive_allowed() { @@ -441,9 +443,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { fn resolve_imports(&mut self) { if self.monotonic { - let err_count = self.cx.parse_sess.span_diagnostic.err_count(); self.cx.resolver.resolve_imports(); - self.cx.resolve_err_count += self.cx.parse_sess.span_diagnostic.err_count() - err_count; } } @@ -467,11 +467,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }; if self.monotonic { - let err_count = self.cx.parse_sess.span_diagnostic.err_count(); - let mark = self.cx.current_expansion.mark; - self.cx.resolver.visit_ast_fragment_with_placeholders(mark, &fragment_with_placeholders, - derives); - self.cx.resolve_err_count += self.cx.parse_sess.span_diagnostic.err_count() - err_count; + self.cx.resolver.visit_ast_fragment_with_placeholders( + self.cx.current_expansion.mark, &fragment_with_placeholders, derives + ); } (fragment_with_placeholders, invocations) @@ -734,7 +732,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { emit_feature_err(this.cx.parse_sess, &*feature.as_str(), span, GateIssue::Library(Some(issue)), &explain); this.cx.trace_macros_diag(); - return Err(kind.dummy(span)); } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 941a3a288da5c..134aa24ebe9c2 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1283,16 +1283,15 @@ impl<'a> Context<'a> { return; } } - if name.starts_with("rustc_") { - gate_feature!(self, rustc_attrs, attr.span, - "unless otherwise specified, attributes \ - with the prefix `rustc_` \ - are reserved for internal compiler diagnostics"); - } else if !attr::is_known(attr) { - // Only run the custom attribute lint during regular feature gate - // checking. Macro gating runs before the plugin attributes are - // registered, so we skip this in that case. - if !is_macro { + if !attr::is_known(attr) { + if name.starts_with("rustc_") { + let msg = "unless otherwise specified, attributes with the prefix `rustc_` \ + are reserved for internal compiler diagnostics"; + gate_feature!(self, rustc_attrs, attr.span, msg); + } else if !is_macro { + // Only run the custom attribute lint during regular feature gate + // checking. Macro gating runs before the plugin attributes are + // registered, so we skip this in that case. let msg = format!("The attribute `{}` is currently unknown to the compiler and \ may have meaning added to it in the future", attr.path); gate_feature!(self, custom_attribute, attr.span, &msg); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index ecb0245263853..df13ff6e6c81e 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -902,12 +902,11 @@ fn noop_fold_bounds(bounds: GenericBounds, folder: &mut T) } pub fn noop_fold_block(b: P, folder: &mut T) -> P { - b.map(|Block {id, stmts, rules, span, recovered}| Block { + b.map(|Block {id, stmts, rules, span}| Block { id: folder.new_id(id), stmts: stmts.move_flat_map(|s| folder.fold_stmt(s).into_iter()), rules, span: folder.new_span(span), - recovered, }) } @@ -1377,6 +1376,7 @@ pub fn noop_fold_expr(Expr {id, node, span, attrs}: Expr, folder: &mu ExprKind::Yield(ex) => ExprKind::Yield(ex.map(|x| folder.fold_expr(x))), ExprKind::Try(ex) => ExprKind::Try(folder.fold_expr(ex)), ExprKind::TryBlock(body) => ExprKind::TryBlock(folder.fold_block(body)), + ExprKind::Err => ExprKind::Err, }, id: folder.new_id(id), span: folder.new_span(span), diff --git a/src/libsyntax/parse/lexer/tokentrees.rs b/src/libsyntax/parse/lexer/tokentrees.rs index 6f9dc247a7897..265ff5f57e4c0 100644 --- a/src/libsyntax/parse/lexer/tokentrees.rs +++ b/src/libsyntax/parse/lexer/tokentrees.rs @@ -11,7 +11,7 @@ use print::pprust::token_to_string; use parse::lexer::StringReader; use parse::{token, PResult}; -use tokenstream::{DelimSpan, TokenStream, TokenTree}; +use tokenstream::{DelimSpan, IsJoint::*, TokenStream, TokenTree}; impl<'a> StringReader<'a> { // Parse a stream of tokens into a list of `TokenTree`s, up to an `Eof`. @@ -186,8 +186,7 @@ impl<'a> StringReader<'a> { let raw = self.span_src_raw; self.real_token(); let is_joint = raw.hi() == self.span_src_raw.lo() && token::is_op(&self.token); - - Ok(if is_joint { tt.joint() } else { tt.into() }) + Ok(TokenStream::Tree(tt, if is_joint { Joint } else { NonJoint })) } } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5a51b629826dd..99014964aa52c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -42,6 +42,7 @@ use ast::{UseTree, UseTreeKind}; use ast::{BinOpKind, UnOp}; use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; +use ext::base::DummyResult; use source_map::{self, SourceMap, Spanned, respan}; use syntax_pos::{self, Span, MultiSpan, BytePos, FileName}; use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId}; @@ -2880,6 +2881,7 @@ impl<'a> Parser<'a> { let mut err = self.fatal(&format!("unknown macro variable `{}`", name)); err.span_label(self.span, "unknown macro variable"); err.emit(); + self.bump(); return } token::Interpolated(ref nt) => { @@ -4976,16 +4978,16 @@ impl<'a> Parser<'a> { /// Precondition: already parsed the '{'. fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P> { let mut stmts = vec![]; - let mut recovered = false; - while !self.eat(&token::CloseDelim(token::Brace)) { let stmt = match self.parse_full_stmt(false) { Err(mut err) => { err.emit(); self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); - self.eat(&token::CloseDelim(token::Brace)); - recovered = true; - break; + Some(Stmt { + id: ast::DUMMY_NODE_ID, + node: StmtKind::Expr(DummyResult::raw_expr(self.span, true)), + span: self.span, + }) } Ok(stmt) => stmt, }; @@ -5003,7 +5005,6 @@ impl<'a> Parser<'a> { id: ast::DUMMY_NODE_ID, rules: s, span: lo.to(self.prev_span), - recovered, })) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5e7707f4e5c3c..3c4a051b85880 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1103,7 +1103,9 @@ impl<'a> State<'a> { self.s.word("_")?; } ast::TyKind::Err => { - self.s.word("?")?; + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()?; } ast::TyKind::ImplicitSelf => { self.s.word("Self")?; @@ -2401,6 +2403,11 @@ impl<'a> State<'a> { self.s.space()?; self.print_block_with_attrs(blk, attrs)? } + ast::ExprKind::Err => { + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()? + } } self.ann.post(self, AnnNode::Expr(expr))?; self.end() diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 013ecd3d343c2..b04495d751a85 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -123,7 +123,7 @@ impl TokenTree { } pub fn joint(self) -> TokenStream { - TokenStream::JointTree(self) + TokenStream::Tree(self, Joint) } /// Returns the opening delimiter as a token tree. @@ -156,8 +156,7 @@ impl TokenTree { #[derive(Clone, Debug)] pub enum TokenStream { Empty, - Tree(TokenTree), - JointTree(TokenTree), + Tree(TokenTree, IsJoint), Stream(Lrc>), } @@ -165,6 +164,14 @@ pub enum TokenStream { #[cfg(target_arch = "x86_64")] static_assert!(MEM_SIZE_OF_TOKEN_STREAM: mem::size_of::() == 32); +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum IsJoint { + Joint, + NonJoint +} + +use self::IsJoint::*; + impl TokenStream { /// Given a `TokenStream` with a `Stream` of only two arguments, return a new `TokenStream` /// separating the two arguments with a comma for diagnostic suggestions. @@ -176,16 +183,16 @@ impl TokenStream { while let Some((pos, ts)) = iter.next() { if let Some((_, next)) = iter.peek() { let sp = match (&ts, &next) { - (TokenStream::Tree(TokenTree::Token(_, token::Token::Comma)), _) | - (_, TokenStream::Tree(TokenTree::Token(_, token::Token::Comma))) => { - continue; - } - (TokenStream::Tree(TokenTree::Token(sp, _)), _) => *sp, - (TokenStream::Tree(TokenTree::Delimited(sp, ..)), _) => sp.entire(), + (TokenStream::Tree(TokenTree::Token(_, token::Token::Comma), NonJoint), _) | + (_, TokenStream::Tree(TokenTree::Token(_, token::Token::Comma), NonJoint)) + => continue, + (TokenStream::Tree(TokenTree::Token(sp, _), NonJoint), _) => *sp, + (TokenStream::Tree(TokenTree::Delimited(sp, ..), NonJoint), _) => + sp.entire(), _ => continue, }; let sp = sp.shrink_to_hi(); - let comma = TokenStream::Tree(TokenTree::Token(sp, token::Comma)); + let comma = TokenStream::Tree(TokenTree::Token(sp, token::Comma), NonJoint); suggestion = Some((pos, comma, sp)); } } @@ -204,7 +211,7 @@ impl TokenStream { impl From for TokenStream { fn from(tt: TokenTree) -> TokenStream { - TokenStream::Tree(tt) + TokenStream::Tree(tt, NonJoint) } } @@ -232,7 +239,7 @@ impl Extend for TokenStream { vec.reserve(iter.size_hint().0); vec } - TokenStream::Tree(_) | TokenStream::JointTree(_) => { + TokenStream::Tree(..) => { let mut vec = Vec::new(); vec.reserve(1 + iter.size_hint().0); vec.push(this); @@ -369,8 +376,7 @@ impl TokenStream { /// Returns true if the token tree is a joint operation w.r.t. `proc_macro::TokenNode`. pub fn as_tree(self) -> (TokenTree, bool /* joint? */) { match self { - TokenStream::Tree(tree) => (tree, false), - TokenStream::JointTree(tree) => (tree, true), + TokenStream::Tree(tree, is_joint) => (tree, is_joint == Joint), _ => unreachable!(), } } @@ -381,8 +387,7 @@ impl TokenStream { let mut i = 0; while let Some(stream) = trees.next_as_stream() { result.push(match stream { - TokenStream::Tree(tree) => f(i, tree).into(), - TokenStream::JointTree(tree) => f(i, tree).joint(), + TokenStream::Tree(tree, is_joint) => TokenStream::Tree(f(i, tree), is_joint), _ => unreachable!() }); i += 1; @@ -395,27 +400,25 @@ impl TokenStream { let mut result = Vec::new(); while let Some(stream) = trees.next_as_stream() { result.push(match stream { - TokenStream::Tree(tree) => f(tree).into(), - TokenStream::JointTree(tree) => f(tree).joint(), + TokenStream::Tree(tree, is_joint) => TokenStream::Tree(f(tree), is_joint), _ => unreachable!() }); } TokenStream::new(result) } - fn first_tree_and_joint(&self) -> Option<(TokenTree, bool)> { + fn first_tree_and_joint(&self) -> Option<(TokenTree, IsJoint)> { match self { TokenStream::Empty => None, - TokenStream::Tree(ref tree) => Some((tree.clone(), false)), - TokenStream::JointTree(ref tree) => Some((tree.clone(), true)), + TokenStream::Tree(ref tree, is_joint) => Some((tree.clone(), *is_joint)), TokenStream::Stream(ref stream) => stream.first().unwrap().first_tree_and_joint(), } } fn last_tree_if_joint(&self) -> Option { match self { - TokenStream::Empty | TokenStream::Tree(..) => None, - TokenStream::JointTree(ref tree) => Some(tree.clone()), + TokenStream::Empty | TokenStream::Tree(_, NonJoint) => None, + TokenStream::Tree(ref tree, Joint) => Some(tree.clone()), TokenStream::Stream(ref stream) => stream.last().unwrap().last_tree_if_joint(), } } @@ -439,11 +442,7 @@ impl TokenStreamBuilder { self.push_all_but_last_tree(&last_stream); let glued_span = last_span.to(span); let glued_tt = TokenTree::Token(glued_span, glued_tok); - let glued_tokenstream = if is_joint { - glued_tt.joint() - } else { - glued_tt.into() - }; + let glued_tokenstream = TokenStream::Tree(glued_tt, is_joint); self.0.push(glued_tokenstream); self.push_all_but_first_tree(&stream); return @@ -493,8 +492,7 @@ pub struct Cursor(CursorKind); #[derive(Clone)] enum CursorKind { Empty, - Tree(TokenTree, bool /* consumed? */), - JointTree(TokenTree, bool /* consumed? */), + Tree(TokenTree, IsJoint, bool /* consumed? */), Stream(StreamCursor), } @@ -516,9 +514,9 @@ impl StreamCursor { self.index += 1; let next = self.stream[self.index - 1].clone(); match next { - TokenStream::Tree(..) | TokenStream::JointTree(..) => return Some(next), - TokenStream::Stream(stream) => self.insert(stream), TokenStream::Empty => {} + TokenStream::Tree(..) => return Some(next), + TokenStream::Stream(stream) => self.insert(stream), } } else if let Some((stream, index)) = self.stack.pop() { self.stream = stream; @@ -540,7 +538,7 @@ impl Iterator for Cursor { fn next(&mut self) -> Option { self.next_as_stream().map(|stream| match stream { - TokenStream::Tree(tree) | TokenStream::JointTree(tree) => tree, + TokenStream::Tree(tree, _) => tree, _ => unreachable!() }) } @@ -550,18 +548,15 @@ impl Cursor { fn new(stream: TokenStream) -> Self { Cursor(match stream { TokenStream::Empty => CursorKind::Empty, - TokenStream::Tree(tree) => CursorKind::Tree(tree, false), - TokenStream::JointTree(tree) => CursorKind::JointTree(tree, false), + TokenStream::Tree(tree, is_joint) => CursorKind::Tree(tree, is_joint, false), TokenStream::Stream(stream) => CursorKind::Stream(StreamCursor::new(stream)), }) } pub fn next_as_stream(&mut self) -> Option { let (stream, consumed) = match self.0 { - CursorKind::Tree(ref tree, ref mut consumed @ false) => - (tree.clone().into(), consumed), - CursorKind::JointTree(ref tree, ref mut consumed @ false) => - (tree.clone().joint(), consumed), + CursorKind::Tree(ref tree, ref is_joint, ref mut consumed @ false) => + (TokenStream::Tree(tree.clone(), *is_joint), consumed), CursorKind::Stream(ref mut cursor) => return cursor.next_as_stream(), _ => return None, }; @@ -574,7 +569,7 @@ impl Cursor { match self.0 { _ if stream.is_empty() => return, CursorKind::Empty => *self = stream.trees(), - CursorKind::Tree(_, consumed) | CursorKind::JointTree(_, consumed) => { + CursorKind::Tree(_, _, consumed) => { *self = TokenStream::new(vec![self.original_stream(), stream]).trees(); if consumed { self.next(); @@ -589,8 +584,8 @@ impl Cursor { pub fn original_stream(&self) -> TokenStream { match self.0 { CursorKind::Empty => TokenStream::empty(), - CursorKind::Tree(ref tree, _) => tree.clone().into(), - CursorKind::JointTree(ref tree, _) => tree.clone().joint(), + CursorKind::Tree(ref tree, ref is_joint, _) => + TokenStream::Tree(tree.clone(), *is_joint), CursorKind::Stream(ref cursor) => TokenStream::Stream( cursor.stack.get(0).cloned().map(|(stream, _)| stream) .unwrap_or_else(|| cursor.stream.clone()) @@ -602,9 +597,8 @@ impl Cursor { fn look_ahead(streams: &[TokenStream], mut n: usize) -> Result { for stream in streams { n = match stream { - TokenStream::Tree(ref tree) | TokenStream::JointTree(ref tree) - if n == 0 => return Ok(tree.clone()), - TokenStream::Tree(..) | TokenStream::JointTree(..) => n - 1, + TokenStream::Tree(ref tree, _) if n == 0 => return Ok(tree.clone()), + TokenStream::Tree(..) => n - 1, TokenStream::Stream(ref stream) => match look_ahead(stream, n) { Ok(tree) => return Ok(tree), Err(n) => n, @@ -617,10 +611,8 @@ impl Cursor { match self.0 { CursorKind::Empty | - CursorKind::Tree(_, true) | - CursorKind::JointTree(_, true) => Err(n), - CursorKind::Tree(ref tree, false) | - CursorKind::JointTree(ref tree, false) => look_ahead(&[tree.clone().into()], n), + CursorKind::Tree(_, _, true) => Err(n), + CursorKind::Tree(ref tree, _, false) => look_ahead(&[tree.clone().into()], n), CursorKind::Stream(ref cursor) => { look_ahead(&cursor.stream[cursor.index ..], n).or_else(|mut n| { for &(ref stream, index) in cursor.stack.iter().rev() { @@ -653,8 +645,7 @@ impl From for ThinTokenStream { fn from(stream: TokenStream) -> ThinTokenStream { ThinTokenStream(match stream { TokenStream::Empty => None, - TokenStream::Tree(tree) => Some(Lrc::new(vec![tree.into()])), - TokenStream::JointTree(tree) => Some(Lrc::new(vec![tree.joint()])), + TokenStream::Tree(..) => Some(Lrc::new(vec![stream])), TokenStream::Stream(stream) => Some(stream), }) } diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index b7cd2acf8a591..5a6a6f05fd756 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -276,6 +276,7 @@ pub enum ExprPrecedence { TryBlock, Struct, Async, + Err, } impl ExprPrecedence { @@ -334,7 +335,8 @@ impl ExprPrecedence { ExprPrecedence::Block | ExprPrecedence::TryBlock | ExprPrecedence::Async | - ExprPrecedence::Struct => PREC_PAREN, + ExprPrecedence::Struct | + ExprPrecedence::Err => PREC_PAREN, } } } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 6747598f3753f..e30fef6ba51fc 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -812,6 +812,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { ExprKind::TryBlock(ref body) => { visitor.visit_block(body) } + ExprKind::Err => {} } visitor.visit_expr_post(expression) diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 2ff9fb487c4f2..3e9a1a9228bed 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -59,7 +59,6 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_ASM); - return DummyResult::expr(sp); } // Split the tts before the first colon, to avoid `asm!("x": y)` being diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index c8cc11e43545a..aee969fd23122 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -30,7 +30,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_CONCAT_IDENTS); - return base::DummyResult::expr(sp); } if tts.is_empty() { diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs index adbc5828b8fb8..53a3ecda0d5c0 100644 --- a/src/libsyntax_ext/deriving/default.rs +++ b/src/libsyntax_ext/deriving/default.rs @@ -13,7 +13,7 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{Expr, MetaItem}; -use syntax::ext::base::{Annotatable, ExtCtxt}; +use syntax::ext::base::{Annotatable, DummyResult, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; use syntax::symbol::Symbol; @@ -79,7 +79,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur span_err!(cx, trait_span, E0665, "`Default` cannot be derived for enums, only structs"); // let compilation continue - cx.expr_usize(trait_span, 0) + DummyResult::raw_expr(trait_span, true) } _ => cx.span_bug(trait_span, "Non-static method in `derive(Default)`"), }; diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index ae47a028bc386..292743e0798a7 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -163,6 +163,5 @@ fn call_intrinsic(cx: &ExtCtxt, id: ast::DUMMY_NODE_ID, rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated), span, - recovered: false, })) } diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 41799eede9e86..0199ac4d1304e 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -676,7 +676,7 @@ impl<'a, 'b> Context<'a, 'b> { "X" => "UpperHex", _ => { ecx.span_err(sp, &format!("unknown format trait `{}`", *tyname)); - "Dummy" + return DummyResult::raw_expr(sp, true); } } } @@ -723,7 +723,6 @@ pub fn expand_format_args_nl<'cx>( sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_FORMAT_ARGS_NL); - return base::DummyResult::expr(sp); } sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { @@ -771,7 +770,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, Applicability::MaybeIncorrect, ); err.emit(); - return DummyResult::raw_expr(sp); + return DummyResult::raw_expr(sp, true); } }; @@ -806,7 +805,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, e.note(¬e); } e.emit(); - return DummyResult::raw_expr(sp); + return DummyResult::raw_expr(sp, true); } let arg_spans = parser.arg_places.iter() diff --git a/src/libsyntax_ext/global_asm.rs b/src/libsyntax_ext/global_asm.rs index 000bede7348a5..c7fa233c16334 100644 --- a/src/libsyntax_ext/global_asm.rs +++ b/src/libsyntax_ext/global_asm.rs @@ -39,7 +39,6 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_GLOBAL_ASM); - return DummyResult::any(sp); } let mut p = cx.new_parser_from_tts(tts); diff --git a/src/libsyntax_ext/log_syntax.rs b/src/libsyntax_ext/log_syntax.rs index 7b76b1e891468..6e5c4ebd2078a 100644 --- a/src/libsyntax_ext/log_syntax.rs +++ b/src/libsyntax_ext/log_syntax.rs @@ -24,11 +24,10 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_LOG_SYNTAX); - return base::DummyResult::any(sp); } println!("{}", print::pprust::tts_to_string(tts)); // any so that `log_syntax` can be invoked as an expression and item. - base::DummyResult::any(sp) + base::DummyResult::any_valid(sp) } diff --git a/src/libsyntax_ext/proc_macro_server.rs b/src/libsyntax_ext/proc_macro_server.rs index ca960cbe41b5d..507ceb53432d6 100644 --- a/src/libsyntax_ext/proc_macro_server.rs +++ b/src/libsyntax_ext/proc_macro_server.rs @@ -21,7 +21,7 @@ use syntax::ast; use syntax::ext::base::ExtCtxt; use syntax::parse::lexer::comments; use syntax::parse::{self, token, ParseSess}; -use syntax::tokenstream::{self, DelimSpan, TokenStream}; +use syntax::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream}; use syntax_pos::hygiene::{SyntaxContext, Transparency}; use syntax_pos::symbol::{keywords, Symbol}; use syntax_pos::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span}; @@ -278,11 +278,7 @@ impl ToInternal for TokenTree { }; let tree = tokenstream::TokenTree::Token(span, token); - if joint { - tree.joint() - } else { - tree.into() - } + TokenStream::Tree(tree, if joint { Joint } else { NonJoint }) } } diff --git a/src/libsyntax_ext/test_case.rs b/src/libsyntax_ext/test_case.rs index 0128db7dd78d7..51fee8e2e6e2a 100644 --- a/src/libsyntax_ext/test_case.rs +++ b/src/libsyntax_ext/test_case.rs @@ -39,8 +39,6 @@ pub fn expand( attr_sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_CUSTOM_TEST_FRAMEWORKS); - - return vec![anno_item]; } if !ecx.ecfg.should_test { return vec![]; } diff --git a/src/libsyntax_ext/trace_macros.rs b/src/libsyntax_ext/trace_macros.rs index 256b525b8bea6..4d30c41d9c9d6 100644 --- a/src/libsyntax_ext/trace_macros.rs +++ b/src/libsyntax_ext/trace_macros.rs @@ -25,7 +25,6 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_TRACE_MACROS); - return base::DummyResult::any(sp); } match (tt.len(), tt.first()) { @@ -38,5 +37,5 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt, _ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"), } - base::DummyResult::any(sp) + base::DummyResult::any_valid(sp) } diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 9aafb9fc549fc..ae2259d525898 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -334,6 +334,13 @@ impl Span { span.lo <= other.lo && other.hi <= span.hi } + /// Return `true` if `self` touches `other`. + pub fn overlaps(self, other: Span) -> bool { + let span = self.data(); + let other = other.data(); + span.lo < other.hi && other.lo < span.hi + } + /// Return true if the spans are equal with regards to the source text. /// /// Use this instead of `==` when either span could be generated code, diff --git a/src/test/codegen/issue-56927.rs b/src/test/codegen/issue-56927.rs new file mode 100644 index 0000000000000..0544ff86aacfa --- /dev/null +++ b/src/test/codegen/issue-56927.rs @@ -0,0 +1,44 @@ +// compile-flags: -C no-prepopulate-passes + +#![crate_type="rlib"] +use std::usize; + +#[repr(align(16))] +pub struct S { + arr: [u32; 4], +} + +// CHECK-LABEL: @test1 +// CHECK: store i32 0, i32* %{{.+}}, align 16 +// CHECK: store i32 1, i32* %{{.+}}, align 4 +// CHECK: store i32 2, i32* %{{.+}}, align 8 +// CHECK: store i32 3, i32* %{{.+}}, align 4 +#[no_mangle] +pub fn test1(s: &mut S) { + s.arr[0] = 0; + s.arr[1] = 1; + s.arr[2] = 2; + s.arr[3] = 3; +} + +// CHECK-LABEL: @test2 +// CHECK: store i32 4, i32* %{{.+}}, align 4 +#[allow(const_err)] +#[no_mangle] +pub fn test2(s: &mut S) { + s.arr[usize::MAX / 4 + 1] = 4; +} + +// CHECK-LABEL: @test3 +// CHECK: store i32 5, i32* %{{.+}}, align 4 +#[no_mangle] +pub fn test3(s: &mut S, i: usize) { + s.arr[i] = 5; +} + +// CHECK-LABEL: @test4 +// CHECK: store i32 6, i32* %{{.+}}, align 4 +#[no_mangle] +pub fn test4(s: &mut S) { + s.arr = [6; 4]; +} diff --git a/src/test/codegen/packed.rs b/src/test/codegen/packed.rs index fb6507fd22a4b..3b4e89f12e0ad 100644 --- a/src/test/codegen/packed.rs +++ b/src/test/codegen/packed.rs @@ -83,6 +83,42 @@ pub fn call_pkd2(f: fn() -> Array) -> BigPacked2 { BigPacked2 { dealign: 0, data: f() } } +// CHECK-LABEL: @write_packed_array1 +// CHECK: store i32 0, i32* %{{.+}}, align 1 +// CHECK: store i32 1, i32* %{{.+}}, align 1 +// CHECK: store i32 2, i32* %{{.+}}, align 1 +#[no_mangle] +pub fn write_packed_array1(p: &mut BigPacked1) { + p.data.0[0] = 0; + p.data.0[1] = 1; + p.data.0[2] = 2; +} + +// CHECK-LABEL: @write_packed_array2 +// CHECK: store i32 0, i32* %{{.+}}, align 2 +// CHECK: store i32 1, i32* %{{.+}}, align 2 +// CHECK: store i32 2, i32* %{{.+}}, align 2 +#[no_mangle] +pub fn write_packed_array2(p: &mut BigPacked2) { + p.data.0[0] = 0; + p.data.0[1] = 1; + p.data.0[2] = 2; +} + +// CHECK-LABEL: @repeat_packed_array1 +// CHECK: store i32 42, i32* %{{.+}}, align 1 +#[no_mangle] +pub fn repeat_packed_array1(p: &mut BigPacked1) { + p.data.0 = [42; 8]; +} + +// CHECK-LABEL: @repeat_packed_array2 +// CHECK: store i32 42, i32* %{{.+}}, align 2 +#[no_mangle] +pub fn repeat_packed_array2(p: &mut BigPacked2) { + p.data.0 = [42; 8]; +} + #[repr(packed)] #[derive(Copy, Clone)] pub struct Packed1Pair(u8, u32); diff --git a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs index 854063a2984b4..323c8f95e8c81 100644 --- a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs @@ -115,7 +115,6 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P)) { id: DUMMY_NODE_ID, rules: BlockCheckMode::Default, span: DUMMY_SP, - recovered: false, }); iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None))); }, diff --git a/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs b/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs index 09fe6cec49c2e..a16568f5ffabe 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs @@ -9,4 +9,6 @@ // except according to those terms. #[cfg(foo(bar))] //~ ERROR invalid predicate `foo` +fn check() {} + fn main() {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs b/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs index 83e162e08712f..c7e1b4435e49b 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs @@ -33,3 +33,5 @@ macro_rules! generate_s10 { } generate_s10!(concat!("nonexistent")); + +fn main() {} diff --git a/src/test/ui/consts/static_mut_containing_mut_ref.rs b/src/test/ui/consts/static_mut_containing_mut_ref.rs new file mode 100644 index 0000000000000..27e1a111163b1 --- /dev/null +++ b/src/test/ui/consts/static_mut_containing_mut_ref.rs @@ -0,0 +1,7 @@ +// compile-pass + +static mut STDERR_BUFFER_SPACE: [u8; 42] = [0u8; 42]; + +pub static mut STDERR_BUFFER: *mut [u8] = unsafe { &mut STDERR_BUFFER_SPACE }; + +fn main() {} diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.rs b/src/test/ui/consts/static_mut_containing_mut_ref2.rs new file mode 100644 index 0000000000000..4180b1e295ab0 --- /dev/null +++ b/src/test/ui/consts/static_mut_containing_mut_ref2.rs @@ -0,0 +1,9 @@ +#![feature(const_let)] + +static mut STDERR_BUFFER_SPACE: u8 = 0; + +pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; +//~^ ERROR references in statics may only refer to immutable values +//~| ERROR static contains unimplemented expression type + +fn main() {} diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.stderr b/src/test/ui/consts/static_mut_containing_mut_ref2.stderr new file mode 100644 index 0000000000000..f0ae1545056b7 --- /dev/null +++ b/src/test/ui/consts/static_mut_containing_mut_ref2.stderr @@ -0,0 +1,16 @@ +error[E0017]: references in statics may only refer to immutable values + --> $DIR/static_mut_containing_mut_ref2.rs:5:46 + | +LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values + +error[E0019]: static contains unimplemented expression type + --> $DIR/static_mut_containing_mut_ref2.rs:5:45 + | +LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0017, E0019. +For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/consts/static_mut_containing_mut_ref3.rs b/src/test/ui/consts/static_mut_containing_mut_ref3.rs new file mode 100644 index 0000000000000..0bc7faa9afdec --- /dev/null +++ b/src/test/ui/consts/static_mut_containing_mut_ref3.rs @@ -0,0 +1,8 @@ +#![feature(const_let)] + +static mut FOO: (u8, u8) = (42, 43); + +static mut BAR: () = unsafe { FOO.0 = 99; }; +//~^ ERROR could not evaluate static initializer + +fn main() {} diff --git a/src/test/ui/consts/static_mut_containing_mut_ref3.stderr b/src/test/ui/consts/static_mut_containing_mut_ref3.stderr new file mode 100644 index 0000000000000..cae53c6fee9dd --- /dev/null +++ b/src/test/ui/consts/static_mut_containing_mut_ref3.stderr @@ -0,0 +1,9 @@ +error[E0080]: could not evaluate static initializer + --> $DIR/static_mut_containing_mut_ref3.rs:5:31 + | +LL | static mut BAR: () = unsafe { FOO.0 = 99; }; + | ^^^^^^^^^^ tried to modify a static's initial value from another static's initializer + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs b/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs index 598e9f0f53aee..782e830eb4634 100644 --- a/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs +++ b/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs @@ -14,7 +14,7 @@ pub fn print(_args: std::fmt::Arguments) {} #[macro_export] macro_rules! myprint { - ($($arg:tt)*) => (print(format_args!($($arg)*))); + ($($arg:tt)*) => ($crate::print(format_args!($($arg)*))); } #[macro_export] diff --git a/src/test/ui/dead-code-tuple-struct-field.rs b/src/test/ui/dead-code-tuple-struct-field.rs new file mode 100644 index 0000000000000..496ce4fb378ae --- /dev/null +++ b/src/test/ui/dead-code-tuple-struct-field.rs @@ -0,0 +1,12 @@ +// compile-pass + +#![deny(dead_code)] + +const LEN: usize = 4; + +#[derive(Debug)] +struct Wrapper([u8; LEN]); + +fn main() { + println!("{:?}", Wrapper([0, 1, 2, 3])); +} diff --git a/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs b/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs index 9ff1c14f54c6e..f3a23f6888ab3 100644 --- a/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs +++ b/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs @@ -14,6 +14,8 @@ trait Foo { type Bar; } +struct Bar; + impl Bar { #[derive(Clone)] //~^ ERROR `derive` may only be applied to structs, enums and unions diff --git a/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr b/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr index 8246889b620be..29db68d94b076 100644 --- a/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr +++ b/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr @@ -5,7 +5,7 @@ LL | #[derive(Clone)] | ^^^^^^^^^^^^^^^^ error: `derive` may only be applied to structs, enums and unions - --> $DIR/derive-on-trait-item-or-impl-item.rs:18:5 + --> $DIR/derive-on-trait-item-or-impl-item.rs:20:5 | LL | #[derive(Clone)] | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/did_you_mean/issue-40396.rs b/src/test/ui/did_you_mean/issue-40396.rs index eb62dc5408494..6b4283c65ac28 100644 --- a/src/test/ui/did_you_mean/issue-40396.rs +++ b/src/test/ui/did_you_mean/issue-40396.rs @@ -9,16 +9,29 @@ // except according to those terms. fn foo() { - println!("{:?}", (0..13).collect>()); //~ ERROR chained comparison + (0..13).collect>(); + //~^ ERROR chained comparison + //~| ERROR expected value, found struct `Vec` + //~| ERROR expected value, found builtin type `i32` + //~| ERROR attempted to take value of method `collect` } fn bar() { - println!("{:?}", Vec::new()); //~ ERROR chained comparison + Vec::new(); + //~^ ERROR chained comparison + //~| ERROR expected value, found struct `Vec` + //~| ERROR expected value, found builtin type `i32` + //~| ERROR cannot find function `new` in the crate root } fn qux() { - println!("{:?}", (0..13).collect()); //~ ERROR chained comparison + (0..13).collect(); //~^ ERROR chained comparison + //~| ERROR chained comparison + //~| ERROR expected value, found struct `Vec` + //~| ERROR expected value, found builtin type `i32` + //~| ERROR attempted to take value of method `collect` + //~| ERROR mismatched types } fn main() {} diff --git a/src/test/ui/did_you_mean/issue-40396.stderr b/src/test/ui/did_you_mean/issue-40396.stderr index 219fd45665a94..22f1acbea6c97 100644 --- a/src/test/ui/did_you_mean/issue-40396.stderr +++ b/src/test/ui/did_you_mean/issue-40396.stderr @@ -1,38 +1,107 @@ error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:12:37 + --> $DIR/issue-40396.rs:12:20 | -LL | println!("{:?}", (0..13).collect>()); //~ ERROR chained comparison - | ^^^^^^^^ +LL | (0..13).collect>(); + | ^^^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:16:25 + --> $DIR/issue-40396.rs:20:8 | -LL | println!("{:?}", Vec::new()); //~ ERROR chained comparison - | ^^^^^^^ +LL | Vec::new(); + | ^^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:20:37 + --> $DIR/issue-40396.rs:28:20 | -LL | println!("{:?}", (0..13).collect()); //~ ERROR chained comparison - | ^^^^^^^^ +LL | (0..13).collect(); + | ^^^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:20:41 + --> $DIR/issue-40396.rs:28:24 | -LL | println!("{:?}", (0..13).collect()); //~ ERROR chained comparison - | ^^^^^^ +LL | (0..13).collect(); + | ^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments -error: aborting due to 4 previous errors +error[E0423]: expected value, found struct `Vec` + --> $DIR/issue-40396.rs:12:21 + | +LL | (0..13).collect>(); + | ^^^ did you mean `Vec { /* fields */ }`? + +error[E0423]: expected value, found builtin type `i32` + --> $DIR/issue-40396.rs:12:25 + | +LL | (0..13).collect>(); + | ^^^ not a value + +error[E0423]: expected value, found struct `Vec` + --> $DIR/issue-40396.rs:20:5 + | +LL | Vec::new(); + | ^^^ did you mean `Vec { /* fields */ }`? + +error[E0423]: expected value, found builtin type `i32` + --> $DIR/issue-40396.rs:20:9 + | +LL | Vec::new(); + | ^^^ not a value + +error[E0425]: cannot find function `new` in the crate root + --> $DIR/issue-40396.rs:20:15 + | +LL | Vec::new(); + | ^^^ not found in the crate root + +error[E0423]: expected value, found struct `Vec` + --> $DIR/issue-40396.rs:28:21 + | +LL | (0..13).collect(); + | ^^^ did you mean `Vec { /* fields */ }`? + +error[E0423]: expected value, found builtin type `i32` + --> $DIR/issue-40396.rs:28:25 + | +LL | (0..13).collect(); + | ^^^ not a value + +error[E0615]: attempted to take value of method `collect` on type `std::ops::Range<{integer}>` + --> $DIR/issue-40396.rs:12:13 + | +LL | (0..13).collect>(); + | ^^^^^^^ + | + = help: maybe a `()` to call it is missing? + +error[E0615]: attempted to take value of method `collect` on type `std::ops::Range<{integer}>` + --> $DIR/issue-40396.rs:28:13 + | +LL | (0..13).collect(); + | ^^^^^^^ + | + = help: maybe a `()` to call it is missing? + +error[E0308]: mismatched types + --> $DIR/issue-40396.rs:28:29 + | +LL | (0..13).collect(); + | ^^ expected bool, found () + | + = note: expected type `bool` + found type `()` + +error: aborting due to 14 previous errors +Some errors occurred: E0308, E0423, E0425, E0615. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.rs b/src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.rs new file mode 100644 index 0000000000000..264cfa449942c --- /dev/null +++ b/src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.rs @@ -0,0 +1,15 @@ +enum PutDown { Set } +enum AffixHeart { Set } +enum CauseToBe { Set } +enum Determine { Set } +enum TableDishesAction { Set } +enum Solidify { Set } +enum UnorderedCollection { Set } + +fn setup() -> Set { Set } +//~^ ERROR cannot find type `Set` in this scope +//~| ERROR cannot find value `Set` in this scope + +fn main() { + setup(); +} diff --git a/src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr b/src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr new file mode 100644 index 0000000000000..6107ca32a5d75 --- /dev/null +++ b/src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr @@ -0,0 +1,38 @@ +error[E0412]: cannot find type `Set` in this scope + --> $DIR/issue-56028-there-is-an-enum-variant.rs:9:15 + | +LL | fn setup() -> Set { Set } + | ^^^ not found in this scope +help: there is an enum variant `AffixHeart::Set` and 7 others; try using the variant's enum + | +LL | fn setup() -> AffixHeart { Set } + | ^^^^^^^^^^ +LL | fn setup() -> CauseToBe { Set } + | ^^^^^^^^^ +LL | fn setup() -> Determine { Set } + | ^^^^^^^^^ +LL | fn setup() -> PutDown { Set } + | ^^^^^^^ +and 3 other candidates + +error[E0425]: cannot find value `Set` in this scope + --> $DIR/issue-56028-there-is-an-enum-variant.rs:9:21 + | +LL | fn setup() -> Set { Set } + | ^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use AffixHeart::Set; + | +LL | use CauseToBe::Set; + | +LL | use Determine::Set; + | +LL | use PutDown::Set; + | +and 3 other candidates + +error: aborting due to 2 previous errors + +Some errors occurred: E0412, E0425. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs b/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs index bdb190c748ace..02bb1077b8661 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs +++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs @@ -14,6 +14,10 @@ #[macro_use] extern crate edition_kw_macro_2015; +mod module { + pub fn async() {} +} + pub fn check_async() { let mut async = 1; // OK let mut r#async = 1; // OK @@ -28,3 +32,5 @@ pub fn check_async() { module::async(); // OK module::r#async(); // OK } + +fn main() {} diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr index 8bf8c3c356030..f8f112941bb85 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr @@ -1,11 +1,11 @@ error: no rules expected the token `r#async` - --> $DIR/edition-keywords-2015-2015-parsing.rs:22:31 + --> $DIR/edition-keywords-2015-2015-parsing.rs:26:31 | LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` | ^^^^^^^ no rules expected this token in macro call error: no rules expected the token `async` - --> $DIR/edition-keywords-2015-2015-parsing.rs:23:35 + --> $DIR/edition-keywords-2015-2015-parsing.rs:27:35 | LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected this token in macro call diff --git a/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs b/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs index 291fd0285e57c..249519d55a75b 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs +++ b/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs @@ -20,3 +20,5 @@ mod one_async { mod two_async { produces_async_raw! {} // OK } + +fn main() {} diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs b/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs index 1b7bfb530596a..492dd62a6c3da 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs +++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs @@ -14,6 +14,10 @@ #[macro_use] extern crate edition_kw_macro_2018; +mod module { + pub fn async() {} +} + pub fn check_async() { let mut async = 1; // OK let mut r#async = 1; // OK @@ -28,3 +32,5 @@ pub fn check_async() { module::async(); // OK module::r#async(); // OK } + +fn main() {} diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr index 77622548bce93..5b71507430258 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr @@ -1,11 +1,11 @@ error: no rules expected the token `r#async` - --> $DIR/edition-keywords-2015-2018-parsing.rs:22:31 + --> $DIR/edition-keywords-2015-2018-parsing.rs:26:31 | LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` | ^^^^^^^ no rules expected this token in macro call error: no rules expected the token `async` - --> $DIR/edition-keywords-2015-2018-parsing.rs:23:35 + --> $DIR/edition-keywords-2015-2018-parsing.rs:27:35 | LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected this token in macro call diff --git a/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs b/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs index 81bef913ac6ca..ad9c7ca1e87a8 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs +++ b/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs @@ -20,3 +20,5 @@ mod one_async { mod two_async { produces_async_raw! {} // OK } + +fn main() {} diff --git a/src/test/ui/enum/enum-variant-type-2.stderr b/src/test/ui/enum/enum-variant-type-2.stderr index 7a786af71bb3f..eb869f5539f36 100644 --- a/src/test/ui/enum/enum-variant-type-2.stderr +++ b/src/test/ui/enum/enum-variant-type-2.stderr @@ -5,7 +5,7 @@ LL | fn foo(x: Foo::Bar) {} //~ ERROR expected type, found variant `Foo::Bar` | ^^^^^^^^ | | | not a type - | help: you can try using the variant's enum: `Foo` + | help: try using the variant's enum: `Foo` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0069.stderr b/src/test/ui/error-codes/E0069.stderr index 0ba1ed456635f..12b778f42e22c 100644 --- a/src/test/ui/error-codes/E0069.stderr +++ b/src/test/ui/error-codes/E0069.stderr @@ -1,8 +1,10 @@ error[E0069]: `return;` in a function whose return type is not `()` --> $DIR/E0069.rs:12:5 | +LL | fn foo() -> u8 { + | -- expected `u8` because of this return type LL | return; - | ^^^^^^ return type is not () + | ^^^^^^ return type is not `()` error: aborting due to previous error diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs b/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs index 2dbc6cb140db3..96c96b2010469 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs @@ -23,3 +23,5 @@ mod derive { //~^ ERROR cannot find derive macro `x3300` in this scope struct S; } + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs b/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs index e5293ebb94ddc..88cad6bc501f4 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs @@ -41,3 +41,5 @@ mod derive { //~^ ERROR `derive` may only be applied to structs, enums and unions impl S { } } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-asm2.rs b/src/test/ui/feature-gates/feature-gate-asm2.rs index 222190de9fe9c..5291b0e2fb63a 100644 --- a/src/test/ui/feature-gates/feature-gate-asm2.rs +++ b/src/test/ui/feature-gates/feature-gate-asm2.rs @@ -12,6 +12,6 @@ fn main() { unsafe { - println!("{}", asm!("")); //~ ERROR inline assembly is not stable + println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable } } diff --git a/src/test/ui/feature-gates/feature-gate-asm2.stderr b/src/test/ui/feature-gates/feature-gate-asm2.stderr index a0e881a3b99ae..36f0e71f72b5a 100644 --- a/src/test/ui/feature-gates/feature-gate-asm2.stderr +++ b/src/test/ui/feature-gates/feature-gate-asm2.stderr @@ -1,8 +1,8 @@ error[E0658]: inline assembly is not stable enough for use and is subject to change (see issue #29722) - --> $DIR/feature-gate-asm2.rs:15:24 + --> $DIR/feature-gate-asm2.rs:15:26 | -LL | println!("{}", asm!("")); //~ ERROR inline assembly is not stable - | ^^^^^^^^ +LL | println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable + | ^^^^^^^^ | = help: add #![feature(asm)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs index 6b70c1ea294c5..e4413f449ef13 100644 --- a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs +++ b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(intrinsics, lang_items, no_core)] + #![crate_type="rlib"] #![no_core] diff --git a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr index 81f20112a12ff..a042f2f6948f4 100644 --- a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr +++ b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr @@ -1,5 +1,5 @@ error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:23:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:25:7 | LL | #[cfg(target_has_atomic = "8")] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[cfg(target_has_atomic = "8")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:29:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:31:7 | LL | #[cfg(target_has_atomic = "8")] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[cfg(target_has_atomic = "8")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:34:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:36:7 | LL | #[cfg(target_has_atomic = "16")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[cfg(target_has_atomic = "16")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:39:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:41:7 | LL | #[cfg(target_has_atomic = "16")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | #[cfg(target_has_atomic = "16")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:44:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:46:7 | LL | #[cfg(target_has_atomic = "32")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | #[cfg(target_has_atomic = "32")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:49:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:51:7 | LL | #[cfg(target_has_atomic = "32")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | #[cfg(target_has_atomic = "32")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:54:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:56:7 | LL | #[cfg(target_has_atomic = "64")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | #[cfg(target_has_atomic = "64")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:59:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:61:7 | LL | #[cfg(target_has_atomic = "64")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ LL | #[cfg(target_has_atomic = "64")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:64:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:66:7 | LL | #[cfg(target_has_atomic = "128")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | #[cfg(target_has_atomic = "128")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:69:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:71:7 | LL | #[cfg(target_has_atomic = "128")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | #[cfg(target_has_atomic = "128")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:74:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:76:7 | LL | #[cfg(target_has_atomic = "ptr")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL | #[cfg(target_has_atomic = "ptr")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:79:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:81:7 | LL | #[cfg(target_has_atomic = "ptr")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | #[cfg(target_has_atomic = "ptr")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:86:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:88:10 | LL | cfg!(target_has_atomic = "8"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | cfg!(target_has_atomic = "8"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:88:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:90:10 | LL | cfg!(target_has_atomic = "16"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | cfg!(target_has_atomic = "16"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:90:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:92:10 | LL | cfg!(target_has_atomic = "32"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | cfg!(target_has_atomic = "32"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:92:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:94:10 | LL | cfg!(target_has_atomic = "64"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | cfg!(target_has_atomic = "64"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:94:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:96:10 | LL | cfg!(target_has_atomic = "128"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -135,7 +135,7 @@ LL | cfg!(target_has_atomic = "128"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:96:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:98:10 | LL | cfg!(target_has_atomic = "ptr"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents2.rs b/src/test/ui/feature-gates/feature-gate-concat_idents2.rs index af288a9790440..b8fe82057146c 100644 --- a/src/test/ui/feature-gates/feature-gate-concat_idents2.rs +++ b/src/test/ui/feature-gates/feature-gate-concat_idents2.rs @@ -12,4 +12,5 @@ fn main() { concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough + //~| ERROR cannot find value `ab` in this scope } diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr index 9312a6f5b3618..d7fcf0cc59158 100644 --- a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr +++ b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr @@ -6,6 +6,13 @@ LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough | = help: add #![feature(concat_idents)] to the crate attributes to enable -error: aborting due to previous error +error[E0425]: cannot find value `ab` in this scope + --> $DIR/feature-gate-concat_idents2.rs:14:5 + | +LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough + | ^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0425, E0658. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax.stdout b/src/test/ui/feature-gates/feature-gate-log_syntax.stdout new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-log_syntax.stdout @@ -0,0 +1 @@ + diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.rs b/src/test/ui/feature-gates/feature-gate-log_syntax2.rs index dcbe7eefee52c..d60e447322fd7 100644 --- a/src/test/ui/feature-gates/feature-gate-log_syntax2.rs +++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.rs @@ -11,5 +11,5 @@ // gate-test-log_syntax fn main() { - println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable + println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable } diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr index 19e7de1a824ff..90c7a66a5b6a2 100644 --- a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr +++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr @@ -1,8 +1,8 @@ error[E0658]: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/feature-gate-log_syntax2.rs:14:20 + --> $DIR/feature-gate-log_syntax2.rs:14:22 | -LL | println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable - | ^^^^^^^^^^^^^ +LL | println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable + | ^^^^^^^^^^^^^ | = help: add #![feature(log_syntax)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.stdout b/src/test/ui/feature-gates/feature-gate-log_syntax2.stdout new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.stdout @@ -0,0 +1 @@ + diff --git a/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs b/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs index 77080e3c348f9..8fe67c14e7f29 100644 --- a/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs +++ b/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs @@ -33,3 +33,5 @@ extern { emits_nothing!(); //~^ ERROR macro invocations in `extern {}` blocks are experimental } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs b/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs index 99bc51b69c6cb..7a2bfdf7f7584 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-linelength - // Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate. #[rustc_foo] -//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics +//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr index 882549c1eafba..40708baaaefbf 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr @@ -1,5 +1,5 @@ error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642) - --> $DIR/feature-gate-rustc-attrs.rs:15:3 + --> $DIR/feature-gate-rustc-attrs.rs:13:3 | LL | #[rustc_foo] | ^^^^^^^^^ diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index e277d4e28cb2b..f1d2071bbdb9e 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -1,6 +1,9 @@ error[E0308]: mismatched types --> $DIR/equality.rs:25:5 | +LL | return 1_i32; + | ----- expected because of this statement +LL | } LL | 0_u32 | ^^^^^ expected i32, found u32 | diff --git a/src/test/ui/issues/issue-10536.rs b/src/test/ui/issues/issue-10536.rs index 2b71fb5c67f7a..2bfc2e16334d7 100644 --- a/src/test/ui/issues/issue-10536.rs +++ b/src/test/ui/issues/issue-10536.rs @@ -11,8 +11,6 @@ // We only want to assert that this doesn't ICE, we don't particularly care // about whether it nor it fails to compile. -// error-pattern: - macro_rules! foo{ () => {{ macro_rules! bar{() => (())} @@ -25,9 +23,11 @@ pub fn main() { assert!({one! two()}); //~^ ERROR macros that expand to items must either be surrounded with braces or followed by a + //~| ERROR cannot find macro `one!` in this scope + //~| ERROR mismatched types // regardless of whether nested macro_rules works, the following should at // least throw a conventional error. assert!({one! two}); - //~^ ERROR expected + //~^ ERROR expected `(` or `{`, found `}` } diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/issues/issue-10536.stderr index ba404d0dd3f63..f80f024dcb23f 100644 --- a/src/test/ui/issues/issue-10536.stderr +++ b/src/test/ui/issues/issue-10536.stderr @@ -1,5 +1,5 @@ error: macros that expand to items must either be surrounded with braces or followed by a semicolon - --> $DIR/issue-10536.rs:26:22 + --> $DIR/issue-10536.rs:24:22 | LL | assert!({one! two()}); | ^^ @@ -10,5 +10,21 @@ error: expected `(` or `{`, found `}` LL | assert!({one! two}); | ^ expected `(` or `{` -error: aborting due to 2 previous errors +error: cannot find macro `one!` in this scope + --> $DIR/issue-10536.rs:24:14 + | +LL | assert!({one! two()}); + | ^^^ + +error[E0308]: mismatched types + --> $DIR/issue-10536.rs:24:13 + | +LL | assert!({one! two()}); + | ^^^^^^^^^^^^ expected bool, found () + | + = note: expected type `bool` + found type `()` + +error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-11004.stderr b/src/test/ui/issues/issue-11004.stderr index 215120c9c25ea..eb5b568b34738 100644 --- a/src/test/ui/issues/issue-11004.stderr +++ b/src/test/ui/issues/issue-11004.stderr @@ -2,13 +2,17 @@ error[E0609]: no field `x` on type `*mut A` --> $DIR/issue-11004.rs:17:21 | LL | let x : i32 = n.x; //~ no field `x` on type `*mut A` - | ^ help: `n` is a native pointer; try dereferencing it: `(*n).x` + | --^ + | | + | help: `n` is a raw pointer; try dereferencing it: `(*n).x` error[E0609]: no field `y` on type `*mut A` --> $DIR/issue-11004.rs:18:21 | LL | let y : f64 = n.y; //~ no field `y` on type `*mut A` - | ^ help: `n` is a native pointer; try dereferencing it: `(*n).y` + | --^ + | | + | help: `n` is a raw pointer; try dereferencing it: `(*n).y` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-11692-1.rs b/src/test/ui/issues/issue-11692-1.rs index ff6009da72fd9..da766d441b6b9 100644 --- a/src/test/ui/issues/issue-11692-1.rs +++ b/src/test/ui/issues/issue-11692-1.rs @@ -11,4 +11,5 @@ fn main() { print!(testo!()); //~^ ERROR: format argument must be a string literal + //~| ERROR: cannot find macro `testo!` in this scope } diff --git a/src/test/ui/issues/issue-11692-1.stderr b/src/test/ui/issues/issue-11692-1.stderr index 61ff455d16ca5..f068531485fa5 100644 --- a/src/test/ui/issues/issue-11692-1.stderr +++ b/src/test/ui/issues/issue-11692-1.stderr @@ -8,5 +8,11 @@ help: you might be missing a string literal to format with LL | print!("{}", testo!()); | ^^^^^ -error: aborting due to previous error +error: cannot find macro `testo!` in this scope + --> $DIR/issue-11692-1.rs:12:12 + | +LL | print!(testo!()); + | ^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-11692-2.rs b/src/test/ui/issues/issue-11692-2.rs index a4b8b48384d7a..34c14a66445dc 100644 --- a/src/test/ui/issues/issue-11692-2.rs +++ b/src/test/ui/issues/issue-11692-2.rs @@ -10,4 +10,5 @@ fn main() { concat!(test!()); //~ ERROR cannot find macro `test!` in this scope + //~| ERROR expected a literal } diff --git a/src/test/ui/issues/issue-11692-2.stderr b/src/test/ui/issues/issue-11692-2.stderr index 85f600dbff24e..4b4f95d2fb2e7 100644 --- a/src/test/ui/issues/issue-11692-2.stderr +++ b/src/test/ui/issues/issue-11692-2.stderr @@ -1,8 +1,16 @@ +error: expected a literal + --> $DIR/issue-11692-2.rs:12:13 + | +LL | concat!(test!()); //~ ERROR cannot find macro `test!` in this scope + | ^^^^^^^ + | + = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()` + error: cannot find macro `test!` in this scope --> $DIR/issue-11692-2.rs:12:13 | LL | concat!(test!()); //~ ERROR cannot find macro `test!` in this scope | ^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-17546.stderr b/src/test/ui/issues/issue-17546.stderr index 39f7d5fcc04bc..a8ab5e8eb7745 100644 --- a/src/test/ui/issues/issue-17546.stderr +++ b/src/test/ui/issues/issue-17546.stderr @@ -5,7 +5,7 @@ LL | fn new() -> NoResult { | --------^^^^^^^^^^^^^^^^ | | | did you mean `Result`? - | help: you can try using the variant's enum: `foo::MyEnum` + | help: try using the variant's enum: `foo::MyEnum` error[E0573]: expected type, found variant `Result` --> $DIR/issue-17546.rs:32:17 @@ -48,7 +48,7 @@ LL | fn newer() -> NoResult { | --------^^^^^^^^^^^^^^^^^^^^^ | | | did you mean `Result`? - | help: you can try using the variant's enum: `foo::MyEnum` + | help: try using the variant's enum: `foo::MyEnum` error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-30535.stderr b/src/test/ui/issues/issue-30535.stderr index c3838fdb9cf07..35ef227acfce6 100644 --- a/src/test/ui/issues/issue-30535.stderr +++ b/src/test/ui/issues/issue-30535.stderr @@ -2,9 +2,10 @@ error[E0573]: expected type, found variant `foo::Foo::FooV` --> $DIR/issue-30535.rs:16:8 | LL | _: foo::Foo::FooV //~ ERROR expected type, found variant `foo::Foo::FooV` - | ^^^^^^^^^^^^^^ not a type - | - = help: there is an enum variant `foo::Foo::FooV`, try using `foo::Foo`? + | ^^^^^^^^^^^^^^ + | | + | not a type + | help: try using the variant's enum: `foo::Foo` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-32950.rs b/src/test/ui/issues/issue-32950.rs index 4e5cdd50b2a95..622bb4ca989f9 100644 --- a/src/test/ui/issues/issue-32950.rs +++ b/src/test/ui/issues/issue-32950.rs @@ -13,6 +13,7 @@ #[derive(Debug)] struct Baz( concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros + //~^ ERROR cannot find type `FooBar` in this scope ); fn main() {} diff --git a/src/test/ui/issues/issue-32950.stderr b/src/test/ui/issues/issue-32950.stderr index 0363bf05f0080..b0e5deba21319 100644 --- a/src/test/ui/issues/issue-32950.stderr +++ b/src/test/ui/issues/issue-32950.stderr @@ -4,5 +4,12 @@ error: `derive` cannot be used on items with type macros LL | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0412]: cannot find type `FooBar` in this scope + --> $DIR/issue-32950.rs:15:5 + | +LL | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros + | ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/issues/issue-33571.rs b/src/test/ui/issues/issue-33571.rs index 5dfc41c8f4a48..f91cf407a6590 100644 --- a/src/test/ui/issues/issue-33571.rs +++ b/src/test/ui/issues/issue-33571.rs @@ -12,3 +12,5 @@ Sync, //~ ERROR this unsafe trait should be implemented explicitly Copy)] enum Foo {} + +fn main() {} diff --git a/src/test/ui/issues/issue-35075.stderr b/src/test/ui/issues/issue-35075.stderr index 9b2f17f038b8f..ead07a5f0c8fe 100644 --- a/src/test/ui/issues/issue-35075.stderr +++ b/src/test/ui/issues/issue-35075.stderr @@ -2,19 +2,21 @@ error[E0412]: cannot find type `Foo` in this scope --> $DIR/issue-35075.rs:12:12 | LL | inner: Foo //~ ERROR cannot find type `Foo` in this scope - | ^^^--- - | | - | not found in this scope - | help: you can try using the variant's enum: `Baz` + | ^^^ not found in this scope +help: there is an enum variant `Baz::Foo`; try using the variant's enum + | +LL | inner: Baz //~ ERROR cannot find type `Foo` in this scope + | ^^^ error[E0412]: cannot find type `Foo` in this scope --> $DIR/issue-35075.rs:16:9 | LL | Foo(Foo) //~ ERROR cannot find type `Foo` in this scope - | ^^^--- - | | - | not found in this scope - | help: you can try using the variant's enum: `Baz` + | ^^^ not found in this scope +help: there is an enum variant `Baz::Foo`; try using the variant's enum + | +LL | Foo(Baz) //~ ERROR cannot find type `Foo` in this scope + | ^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-35675.stderr b/src/test/ui/issues/issue-35675.stderr index fef8de3a28d9e..652e1695a85a6 100644 --- a/src/test/ui/issues/issue-35675.stderr +++ b/src/test/ui/issues/issue-35675.stderr @@ -2,10 +2,11 @@ error[E0412]: cannot find type `Apple` in this scope --> $DIR/issue-35675.rs:17:29 | LL | fn should_return_fruit() -> Apple { + | ^^^^^ not found in this scope +help: there is an enum variant `Fruit::Apple`; try using the variant's enum + | +LL | fn should_return_fruit() -> Fruit { | ^^^^^ - | | - | not found in this scope - | help: you can try using the variant's enum: `Fruit` error[E0425]: cannot find function `Apple` in this scope --> $DIR/issue-35675.rs:19:5 @@ -24,7 +25,7 @@ LL | fn should_return_fruit_too() -> Fruit::Apple { | ^^^^^^^^^^^^ | | | not a type - | help: you can try using the variant's enum: `Fruit` + | help: try using the variant's enum: `Fruit` error[E0425]: cannot find function `Apple` in this scope --> $DIR/issue-35675.rs:25:5 @@ -40,28 +41,29 @@ error[E0573]: expected type, found variant `Ok` --> $DIR/issue-35675.rs:29:13 | LL | fn foo() -> Ok { - | ^^ not a type - | - = help: there is an enum variant `std::prelude::v1::Ok`, try using `std::prelude::v1`? - = help: there is an enum variant `std::result::Result::Ok`, try using `std::result::Result`? + | ^^ + | | + | not a type + | help: try using the variant's enum: `std::result::Result` error[E0412]: cannot find type `Variant3` in this scope --> $DIR/issue-35675.rs:34:13 | LL | fn bar() -> Variant3 { - | ^^^^^^^^ - | | - | not found in this scope - | help: you can try using the variant's enum: `x::Enum` + | ^^^^^^^^ not found in this scope +help: there is an enum variant `x::Enum::Variant3`; try using the variant's enum + | +LL | fn bar() -> x::Enum { + | ^^^^^^^ error[E0573]: expected type, found variant `Some` --> $DIR/issue-35675.rs:38:13 | LL | fn qux() -> Some { - | ^^^^ not a type - | - = help: there is an enum variant `std::prelude::v1::Option::Some`, try using `std::prelude::v1::Option`? - = help: there is an enum variant `std::prelude::v1::Some`, try using `std::prelude::v1`? + | ^^^^ + | | + | not a type + | help: try using the variant's enum: `Option` error: aborting due to 7 previous errors diff --git a/src/test/ui/issues/issue-35677.rs b/src/test/ui/issues/issue-35677.rs index 46d3f7e4af00b..71e2125ffd2cc 100644 --- a/src/test/ui/issues/issue-35677.rs +++ b/src/test/ui/issues/issue-35677.rs @@ -3,3 +3,5 @@ fn intersect_map(this: &mut HashMap, other: HashMap) -> bool { this.drain() //~^ ERROR no method named } + +fn main() {} diff --git a/src/test/ui/issues/issue-35677.stderr b/src/test/ui/issues/issue-35677.stderr index dca096b93f5f3..61ddb75b3b52c 100644 --- a/src/test/ui/issues/issue-35677.stderr +++ b/src/test/ui/issues/issue-35677.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `issue_35677` - | - = note: consider adding a `main` function to `$DIR/issue-35677.rs` - error[E0599]: no method named `drain` found for type `&mut std::collections::HashMap` in the current scope --> $DIR/issue-35677.rs:3:10 | @@ -12,7 +8,6 @@ LL | this.drain() `K : std::cmp::Eq` `K : std::hash::Hash` -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0599, E0601. -For more information about an error, try `rustc --explain E0599`. +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/issues/issue-36617.rs b/src/test/ui/issues/issue-36617.rs index 9f5eeb1a45dc8..d3ae783a3dcd9 100644 --- a/src/test/ui/issues/issue-36617.rs +++ b/src/test/ui/issues/issue-36617.rs @@ -9,3 +9,5 @@ // except according to those terms. #![derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions + +fn main() {} diff --git a/src/test/ui/issues/issue-43023.rs b/src/test/ui/issues/issue-43023.rs index 6a5f7a1136aaa..0084ace803ccc 100644 --- a/src/test/ui/issues/issue-43023.rs +++ b/src/test/ui/issues/issue-43023.rs @@ -26,3 +26,5 @@ trait Tr2 { #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions type F; } + +fn main() {} diff --git a/src/test/ui/issues/issue-46438.rs b/src/test/ui/issues/issue-46438.rs index d84b58133853f..6676f2b808ccc 100644 --- a/src/test/ui/issues/issue-46438.rs +++ b/src/test/ui/issues/issue-46438.rs @@ -14,7 +14,7 @@ macro_rules! m { } } -trait Trait {} +trait Tr {} m!(Tr); diff --git a/src/test/ui/issues/issue-49074.rs b/src/test/ui/issues/issue-49074.rs index d255fac5427b6..9ff04c3b80b57 100644 --- a/src/test/ui/issues/issue-49074.rs +++ b/src/test/ui/issues/issue-49074.rs @@ -19,5 +19,5 @@ mod foo { } fn main() { - bar!(); + bar!(); //~ ERROR cannot find macro `bar!` in this scope } diff --git a/src/test/ui/issues/issue-49074.stderr b/src/test/ui/issues/issue-49074.stderr index 6c9d1eac35684..e32cb23f66527 100644 --- a/src/test/ui/issues/issue-49074.stderr +++ b/src/test/ui/issues/issue-49074.stderr @@ -6,6 +6,14 @@ LL | #[marco_use] // typo | = help: add #![feature(custom_attribute)] to the crate attributes to enable -error: aborting due to previous error +error: cannot find macro `bar!` in this scope + --> $DIR/issue-49074.rs:22:4 + | +LL | bar!(); //~ ERROR cannot find macro `bar!` in this scope + | ^^^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-51279.rs b/src/test/ui/issues/issue-51279.rs index 4639d73e44d3d..7088c1a8bb8fa 100644 --- a/src/test/ui/issues/issue-51279.rs +++ b/src/test/ui/issues/issue-51279.rs @@ -32,3 +32,4 @@ unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; //~^ ERROR #[cfg] cannot be applied on a generic parameter +//~| ERROR attribute `ignored` is currently unknown to the compiler diff --git a/src/test/ui/issues/issue-51279.stderr b/src/test/ui/issues/issue-51279.stderr index 38d5a5acc50fe..3485d8f27f25d 100644 --- a/src/test/ui/issues/issue-51279.stderr +++ b/src/test/ui/issues/issue-51279.stderr @@ -46,5 +46,14 @@ error: #[cfg] cannot be applied on a generic parameter LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; | ^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error[E0658]: The attribute `ignored` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/issue-51279.rs:33:8 + | +LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; + | ^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to 9 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-55796.rs b/src/test/ui/issues/issue-55796.rs index a172f6a7bfad1..efdea5c9b1e16 100644 --- a/src/test/ui/issues/issue-55796.rs +++ b/src/test/ui/issues/issue-55796.rs @@ -22,3 +22,5 @@ pub trait Graph<'a> { //~^ ERROR cannot infer } } + +fn main() {} diff --git a/src/test/ui/issues/issue-55796.stderr b/src/test/ui/issues/issue-55796.stderr index f8ca0727efb7e..c05f8b85d0e98 100644 --- a/src/test/ui/issues/issue-55796.stderr +++ b/src/test/ui/issues/issue-55796.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `issue_55796` - | - = note: consider adding a `main` function to `$DIR/issue-55796.rs` - error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> $DIR/issue-55796.rs:16:9 | @@ -44,7 +40,6 @@ LL | Box::new(self.in_edges(u).map(|e| e.target())) expected std::boxed::Box<(dyn std::iter::Iterator>::Node> + 'static)> found std::boxed::Box>::Node>> -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors occurred: E0495, E0601. -For more information about an error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/issues/issue-6596-2.rs b/src/test/ui/issues/issue-6596-2.rs index 3e18de6178a63..5eaa187756eda 100644 --- a/src/test/ui/issues/issue-6596-2.rs +++ b/src/test/ui/issues/issue-6596-2.rs @@ -14,10 +14,10 @@ macro_rules! g { ($inp:ident) => ( { $inp $nonexistent } //~^ ERROR unknown macro variable `nonexistent` - //~| ERROR expected one of ); } fn main() { + let foo = 0; g!(foo); } diff --git a/src/test/ui/issues/issue-6596-2.stderr b/src/test/ui/issues/issue-6596-2.stderr index f2ed17f35e697..273654f2ae224 100644 --- a/src/test/ui/issues/issue-6596-2.stderr +++ b/src/test/ui/issues/issue-6596-2.stderr @@ -7,14 +7,5 @@ LL | { $inp $nonexistent } LL | g!(foo); | -------- in this macro invocation -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `nonexistent` - --> $DIR/issue-6596-2.rs:15:16 - | -LL | { $inp $nonexistent } - | ^^^^^^^^^^^^ expected one of 8 possible tokens here -... -LL | g!(foo); - | -------- in this macro invocation - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/macro_backtrace/main.rs b/src/test/ui/macro_backtrace/main.rs index 72a5c0d5e3728..ba8de550e5492 100644 --- a/src/test/ui/macro_backtrace/main.rs +++ b/src/test/ui/macro_backtrace/main.rs @@ -22,6 +22,8 @@ macro_rules! pong { //~| ERROR expected one of //~| ERROR expected one of +struct syntax; + fn main() { pong!(); ping!(); diff --git a/src/test/ui/macros/macro-comma-behavior.core.stderr b/src/test/ui/macros/macro-comma-behavior.core.stderr index 5ff31f050790e..b7c8c6f394504 100644 --- a/src/test/ui/macros/macro-comma-behavior.core.stderr +++ b/src/test/ui/macros/macro-comma-behavior.core.stderr @@ -1,44 +1,48 @@ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:27:23 + --> $DIR/macro-comma-behavior.rs:29:23 | LL | assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:30:23 + --> $DIR/macro-comma-behavior.rs:32:23 | LL | assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:36:29 + --> $DIR/macro-comma-behavior.rs:38:29 | LL | debug_assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:39:29 + --> $DIR/macro-comma-behavior.rs:41:29 | LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:60:19 + --> $DIR/macro-comma-behavior.rs:62:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:78:21 + --> $DIR/macro-comma-behavior.rs:80:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:87:24 + --> $DIR/macro-comma-behavior.rs:89:24 | LL | write!(f, "{}",)?; | ^^ -error: aborting due to 7 previous errors +error: `#[panic_handler]` function required, but not found + +error: language item required, but not found: `eh_personality` + +error: aborting due to 9 previous errors diff --git a/src/test/ui/macros/macro-comma-behavior.rs b/src/test/ui/macros/macro-comma-behavior.rs index 620e57b463d1a..e130b4b349aaa 100644 --- a/src/test/ui/macros/macro-comma-behavior.rs +++ b/src/test/ui/macros/macro-comma-behavior.rs @@ -13,10 +13,12 @@ // compile-flags: -C debug_assertions=yes // revisions: std core +#![feature(lang_items)] #![cfg_attr(core, no_std)] #[cfg(std)] use std::fmt; #[cfg(core)] use core::fmt; +#[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {} // (see documentation of the similarly-named test in run-pass) fn to_format_or_not_to_format() { diff --git a/src/test/ui/macros/macro-comma-behavior.std.stderr b/src/test/ui/macros/macro-comma-behavior.std.stderr index a87271ed026f9..6c508c6af03c4 100644 --- a/src/test/ui/macros/macro-comma-behavior.std.stderr +++ b/src/test/ui/macros/macro-comma-behavior.std.stderr @@ -1,59 +1,59 @@ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:27:23 + --> $DIR/macro-comma-behavior.rs:29:23 | LL | assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:30:23 + --> $DIR/macro-comma-behavior.rs:32:23 | LL | assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:36:29 + --> $DIR/macro-comma-behavior.rs:38:29 | LL | debug_assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:39:29 + --> $DIR/macro-comma-behavior.rs:41:29 | LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:44:18 + --> $DIR/macro-comma-behavior.rs:46:18 | LL | eprint!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:56:18 + --> $DIR/macro-comma-behavior.rs:58:18 | LL | format!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:60:19 + --> $DIR/macro-comma-behavior.rs:62:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:67:17 + --> $DIR/macro-comma-behavior.rs:69:17 | LL | print!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:78:21 + --> $DIR/macro-comma-behavior.rs:80:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:87:24 + --> $DIR/macro-comma-behavior.rs:89:24 | LL | write!(f, "{}",)?; | ^^ diff --git a/src/test/ui/malformed/malformed-derive-entry.rs b/src/test/ui/malformed/malformed-derive-entry.rs index ac000628f2b04..80e49fe7eeb91 100644 --- a/src/test/ui/malformed/malformed-derive-entry.rs +++ b/src/test/ui/malformed/malformed-derive-entry.rs @@ -23,3 +23,5 @@ struct Test3; #[derive] //~^ WARNING empty trait list struct Test4; + +fn main() {} diff --git a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs index 7cfdacbd983c1..db932a45b455d 100644 --- a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs +++ b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs @@ -13,3 +13,5 @@ // error-pattern:cannot depend on a crate that needs a panic runtime extern crate depends; + +fn main() {} diff --git a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr index 0e68c9b806d1d..27e27dda5effe 100644 --- a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr +++ b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr @@ -1,9 +1,4 @@ error: the crate `depends` cannot depend on a crate that needs a panic runtime, but it depends on `needs_panic_runtime` -error[E0601]: `main` function not found in crate `runtime_depend_on_needs_runtime` - | - = note: consider adding a `main` function to `$DIR/runtime-depend-on-needs-runtime.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/parenthesised-deref-suggestion.rs b/src/test/ui/parenthesised-deref-suggestion.rs new file mode 100644 index 0000000000000..0b4ccdd5a56d4 --- /dev/null +++ b/src/test/ui/parenthesised-deref-suggestion.rs @@ -0,0 +1,11 @@ +struct Session { + opts: u8, +} + +fn main() { + let sess: &Session = &Session { opts: 0 }; + (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` + + let x = [0u32]; + (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` +} diff --git a/src/test/ui/parenthesised-deref-suggestion.stderr b/src/test/ui/parenthesised-deref-suggestion.stderr new file mode 100644 index 0000000000000..71a2bf67f06ae --- /dev/null +++ b/src/test/ui/parenthesised-deref-suggestion.stderr @@ -0,0 +1,21 @@ +error[E0609]: no field `opts` on type `*const Session` + --> $DIR/parenthesised-deref-suggestion.rs:7:30 + | +LL | (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session` + | ^^^^ +help: `(sess as *const Session)` is a raw pointer; try dereferencing it + | +LL | (*(sess as *const Session)).opts; //~ ERROR no field `opts` on type `*const Session` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0609]: no field `0` on type `[u32; 1]` + --> $DIR/parenthesised-deref-suggestion.rs:10:21 + | +LL | (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]` + | ----------------^ + | | + | help: instead of using tuple indexing, use array indexing: `(x as [u32; 1])[0]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/parser/macro/pub-item-macro.rs b/src/test/ui/parser/macro/pub-item-macro.rs index 8809e9a257ddb..1bc7d7b255c88 100644 --- a/src/test/ui/parser/macro/pub-item-macro.rs +++ b/src/test/ui/parser/macro/pub-item-macro.rs @@ -24,5 +24,5 @@ mod foo { } fn main() { - let y: u32 = foo::x; + let y: u32 = foo::x; //~ ERROR static `x` is private } diff --git a/src/test/ui/parser/macro/pub-item-macro.stderr b/src/test/ui/parser/macro/pub-item-macro.stderr index f55ba469ab435..99e29a08581f6 100644 --- a/src/test/ui/parser/macro/pub-item-macro.stderr +++ b/src/test/ui/parser/macro/pub-item-macro.stderr @@ -9,5 +9,12 @@ LL | pub_x!(); | = help: try adjusting the macro to put `pub` inside the invocation -error: aborting due to previous error +error[E0603]: static `x` is private + --> $DIR/pub-item-macro.rs:27:23 + | +LL | let y: u32 = foo::x; //~ ERROR static `x` is private + | ^ + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/proc-macro/issue-41211.rs b/src/test/ui/proc-macro/issue-41211.rs index e0922c452b5fb..6c7e2efef6889 100644 --- a/src/test/ui/proc-macro/issue-41211.rs +++ b/src/test/ui/proc-macro/issue-41211.rs @@ -17,6 +17,7 @@ #![emit_unchanged] //~^ ERROR attribute `emit_unchanged` is currently unknown to the compiler +//~| ERROR inconsistent resolution for a macro: first custom attribute, then attribute macro extern crate issue_41211; use issue_41211::emit_unchanged; diff --git a/src/test/ui/proc-macro/issue-41211.stderr b/src/test/ui/proc-macro/issue-41211.stderr index ba5fad432b7ab..b2893edeccd1a 100644 --- a/src/test/ui/proc-macro/issue-41211.stderr +++ b/src/test/ui/proc-macro/issue-41211.stderr @@ -6,6 +6,12 @@ LL | #![emit_unchanged] | = help: add #![feature(custom_attribute)] to the crate attributes to enable -error: aborting due to previous error +error: inconsistent resolution for a macro: first custom attribute, then attribute macro + --> $DIR/issue-41211.rs:18:4 + | +LL | #![emit_unchanged] + | ^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/proc-macro/lifetimes.rs b/src/test/ui/proc-macro/lifetimes.rs index ff6464a7a3a70..c375d134b804c 100644 --- a/src/test/ui/proc-macro/lifetimes.rs +++ b/src/test/ui/proc-macro/lifetimes.rs @@ -17,3 +17,5 @@ extern crate lifetimes; use lifetimes::*; type A = single_quote_alone!(); //~ ERROR expected type, found `'` + +fn main() {} diff --git a/src/test/ui/proc-macro/more-gates.rs b/src/test/ui/proc-macro/more-gates.rs index 4c038179544ff..096fc871eec5c 100644 --- a/src/test/ui/proc-macro/more-gates.rs +++ b/src/test/ui/proc-macro/more-gates.rs @@ -10,6 +10,8 @@ // aux-build:more-gates.rs +#![feature(decl_macro)] + extern crate more_gates as foo; use foo::*; diff --git a/src/test/ui/proc-macro/more-gates.stderr b/src/test/ui/proc-macro/more-gates.stderr index d5f30d5817c93..a0db4143018cc 100644 --- a/src/test/ui/proc-macro/more-gates.stderr +++ b/src/test/ui/proc-macro/more-gates.stderr @@ -1,5 +1,5 @@ error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:17:1 + --> $DIR/more-gates.rs:19:1 | LL | #[attr2mac1] | ^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[attr2mac1] = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:20:1 + --> $DIR/more-gates.rs:22:1 | LL | #[attr2mac2] | ^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[attr2mac2] = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:24:1 + --> $DIR/more-gates.rs:26:1 | LL | mac2mac1!(); //~ ERROR: cannot expand to macro definitions | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | mac2mac1!(); //~ ERROR: cannot expand to macro definitions = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:25:1 + --> $DIR/more-gates.rs:27:1 | LL | mac2mac2!(); //~ ERROR: cannot expand to macro definitions | ^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | mac2mac2!(); //~ ERROR: cannot expand to macro definitions = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:27:1 + --> $DIR/more-gates.rs:29:1 | LL | tricky!(); | ^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/parent-source-spans.rs b/src/test/ui/proc-macro/parent-source-spans.rs index 8f8e22ba1c34d..1989e726dea02 100644 --- a/src/test/ui/proc-macro/parent-source-spans.rs +++ b/src/test/ui/proc-macro/parent-source-spans.rs @@ -38,6 +38,9 @@ macro three($($tokens:tt)*) { macro four($($tokens:tt)*) { parent_source_spans!($($tokens)*); + //~^ ERROR cannot find value `ok` in this scope + //~| ERROR cannot find value `ok` in this scope + //~| ERROR cannot find value `ok` in this scope } fn main() { diff --git a/src/test/ui/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr index 0442c4f6ce71f..1d7ae0780356b 100644 --- a/src/test/ui/proc-macro/parent-source-spans.stderr +++ b/src/test/ui/proc-macro/parent-source-spans.stderr @@ -35,25 +35,25 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error: first grandparent: "hello" - --> $DIR/parent-source-spans.rs:44:5 + --> $DIR/parent-source-spans.rs:47:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: second grandparent: "world" - --> $DIR/parent-source-spans.rs:44:5 + --> $DIR/parent-source-spans.rs:47:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: first source: "hello" - --> $DIR/parent-source-spans.rs:44:5 + --> $DIR/parent-source-spans.rs:47:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: second source: "world" - --> $DIR/parent-source-spans.rs:44:5 + --> $DIR/parent-source-spans.rs:47:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -77,52 +77,80 @@ LL | two!("yay", "rust"); | -------------------- in this macro invocation error: first parent: "yay" - --> $DIR/parent-source-spans.rs:50:5 + --> $DIR/parent-source-spans.rs:53:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: second parent: "rust" - --> $DIR/parent-source-spans.rs:50:5 + --> $DIR/parent-source-spans.rs:53:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: first source: "yay" - --> $DIR/parent-source-spans.rs:50:5 + --> $DIR/parent-source-spans.rs:53:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: second source: "rust" - --> $DIR/parent-source-spans.rs:50:5 + --> $DIR/parent-source-spans.rs:53:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: first final: "hip" - --> $DIR/parent-source-spans.rs:56:12 + --> $DIR/parent-source-spans.rs:59:12 | LL | three!("hip", "hop"); | ^^^^^ error: second final: "hop" - --> $DIR/parent-source-spans.rs:56:19 + --> $DIR/parent-source-spans.rs:59:19 | LL | three!("hip", "hop"); | ^^^^^ error: first source: "hip" - --> $DIR/parent-source-spans.rs:56:12 + --> $DIR/parent-source-spans.rs:59:12 | LL | three!("hip", "hop"); | ^^^^^ error: second source: "hop" - --> $DIR/parent-source-spans.rs:56:19 + --> $DIR/parent-source-spans.rs:59:19 | LL | three!("hip", "hop"); | ^^^^^ -error: aborting due to 18 previous errors +error[E0425]: cannot find value `ok` in this scope + --> $DIR/parent-source-spans.rs:40:5 + | +LL | parent_source_spans!($($tokens)*); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? +... +LL | one!("hello", "world"); + | ----------------------- in this macro invocation + +error[E0425]: cannot find value `ok` in this scope + --> $DIR/parent-source-spans.rs:40:5 + | +LL | parent_source_spans!($($tokens)*); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? +... +LL | two!("yay", "rust"); + | -------------------- in this macro invocation + +error[E0425]: cannot find value `ok` in this scope + --> $DIR/parent-source-spans.rs:40:5 + | +LL | parent_source_spans!($($tokens)*); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? +... +LL | three!("hip", "hop"); + | --------------------- in this macro invocation + +error: aborting due to 21 previous errors +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/proc-macro/proc-macro-attributes.rs b/src/test/ui/proc-macro/proc-macro-attributes.rs index 6e52411500e22..1814752ac1779 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.rs +++ b/src/test/ui/proc-macro/proc-macro-attributes.rs @@ -13,11 +13,12 @@ #[macro_use] extern crate derive_b; -#[B] +#[B] //~ ERROR `B` is ambiguous #[C] //~ ERROR attribute `C` is currently unknown to the compiler -#[B(D)] -#[B(E = "foo")] -#[B(arbitrary tokens)] +#[B(D)] //~ ERROR `B` is ambiguous +#[B(E = "foo")] //~ ERROR `B` is ambiguous +#[B(arbitrary tokens)] //~ ERROR `B` is ambiguous + //~^ ERROR expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens` #[derive(B)] struct B; diff --git a/src/test/ui/proc-macro/proc-macro-attributes.stderr b/src/test/ui/proc-macro/proc-macro-attributes.stderr index a1289c6356ae6..57f3a5f5ca66c 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.stderr +++ b/src/test/ui/proc-macro/proc-macro-attributes.stderr @@ -6,6 +6,81 @@ LL | #[C] //~ ERROR attribute `C` is currently unknown to the compiler | = help: add #![feature(custom_attribute)] to the crate attributes to enable -error: aborting due to previous error +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:16:3 + | +LL | #[B] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:18:3 + | +LL | #[B(D)] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:19:3 + | +LL | #[B(E = "foo")] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:20:3 + | +LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error: expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens` + --> $DIR/proc-macro-attributes.rs:20:15 + | +LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous + | ^^^^^^ expected one of `(`, `)`, `,`, `::`, or `=` here + +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0658, E0659. +For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/quote-with-interpolated.rs b/src/test/ui/quote-with-interpolated.rs index 1fafb1c7a1b94..0def0b1d7a99e 100644 --- a/src/test/ui/quote-with-interpolated.rs +++ b/src/test/ui/quote-with-interpolated.rs @@ -12,7 +12,12 @@ fn main() { macro_rules! foo { ($bar:expr) => { - quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token + quote_expr!(cx, $bar) + //~^ ERROR quote! with interpolated token + //~| ERROR failed to resolve: maybe a missing `extern crate syntax;`? + //~| ERROR failed to resolve: maybe a missing `extern crate syntax;`? + //~| ERROR cannot find value `cx` in this scope + //~| ERROR cannot find function `new_parser_from_tts` in this scope } } foo!(bar); diff --git a/src/test/ui/quote-with-interpolated.stderr b/src/test/ui/quote-with-interpolated.stderr index 10b3fc0a9ae80..f96c3c56e5383 100644 --- a/src/test/ui/quote-with-interpolated.stderr +++ b/src/test/ui/quote-with-interpolated.stderr @@ -1,11 +1,40 @@ error: quote! with interpolated token --> $DIR/quote-with-interpolated.rs:15:29 | -LL | quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token +LL | quote_expr!(cx, $bar) | ^^^^ ... LL | foo!(bar); | ---------- in this macro invocation -error: aborting due to previous error +error[E0433]: failed to resolve: maybe a missing `extern crate syntax;`? + --> $DIR/quote-with-interpolated.rs:15:13 + | +LL | quote_expr!(cx, $bar) + | ^^^^^^^^^^^^^^^^^^^^^ maybe a missing `extern crate syntax;`? + +error[E0433]: failed to resolve: maybe a missing `extern crate syntax;`? + --> $DIR/quote-with-interpolated.rs:15:29 + | +LL | quote_expr!(cx, $bar) + | ^^^^ maybe a missing `extern crate syntax;`? + +error[E0425]: cannot find value `cx` in this scope + --> $DIR/quote-with-interpolated.rs:15:25 + | +LL | quote_expr!(cx, $bar) + | ^^ not found in this scope +... +LL | foo!(bar); + | ---------- in this macro invocation + +error[E0425]: cannot find function `new_parser_from_tts` in this scope + --> $DIR/quote-with-interpolated.rs:15:13 + | +LL | quote_expr!(cx, $bar) + | ^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 5 previous errors +Some errors occurred: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/reserved/reserved-attr-on-macro.rs b/src/test/ui/reserved/reserved-attr-on-macro.rs index db8f82a70e103..a267daaefef8a 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.rs +++ b/src/test/ui/reserved/reserved-attr-on-macro.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved +#[rustc_attribute_should_be_reserved] +//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved macro_rules! foo { () => (()); } fn main() { - foo!(); + foo!(); //~ ERROR cannot determine resolution for the macro `foo` } diff --git a/src/test/ui/reserved/reserved-attr-on-macro.stderr b/src/test/ui/reserved/reserved-attr-on-macro.stderr index efcd1ec67d7e9..9766dcb2e8f86 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.stderr +++ b/src/test/ui/reserved/reserved-attr-on-macro.stderr @@ -1,11 +1,19 @@ error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642) --> $DIR/reserved-attr-on-macro.rs:11:3 | -LL | #[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved +LL | #[rustc_attribute_should_be_reserved] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(rustc_attrs)] to the crate attributes to enable -error: aborting due to previous error +error: cannot determine resolution for the macro `foo` + --> $DIR/reserved-attr-on-macro.rs:18:5 + | +LL | foo!(); //~ ERROR cannot determine resolution for the macro `foo` + | ^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/ret-non-nil.stderr b/src/test/ui/ret-non-nil.stderr index 01f126bd11ea2..e0fdc8c67edf7 100644 --- a/src/test/ui/ret-non-nil.stderr +++ b/src/test/ui/ret-non-nil.stderr @@ -2,7 +2,9 @@ error[E0069]: `return;` in a function whose return type is not `()` --> $DIR/ret-non-nil.rs:15:19 | LL | fn g() -> isize { return; } - | ^^^^^^ return type is not () + | ----- ^^^^^^ return type is not `()` + | | + | expected `isize` because of this return type error: aborting due to previous error diff --git a/src/test/ui/return/return-unit-from-diverging.stderr b/src/test/ui/return/return-unit-from-diverging.stderr index 38d4ca37366ff..5a9f0877cc6b6 100644 --- a/src/test/ui/return/return-unit-from-diverging.stderr +++ b/src/test/ui/return/return-unit-from-diverging.stderr @@ -1,8 +1,10 @@ error[E0069]: `return;` in a function whose return type is not `()` --> $DIR/return-unit-from-diverging.rs:15:5 | +LL | fn fail() -> ! { + | - expected `!` because of this return type LL | return; //~ ERROR in a function whose return type is not - | ^^^^^^ return type is not () + | ^^^^^^ return type is not `()` error: aborting due to previous error diff --git a/src/test/ui/self/self_type_keyword.rs b/src/test/ui/self/self_type_keyword.rs index 20d2e2ca9cfa1..783179334aae8 100644 --- a/src/test/ui/self/self_type_keyword.rs +++ b/src/test/ui/self/self_type_keyword.rs @@ -17,6 +17,7 @@ mod foo { struct Bar<'Self>; //~^ ERROR lifetimes cannot use keyword names +//~| ERROR parameter `'Self` is never used struct Foo; diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr index 4a7b9a6ce2cee..d4d986902a938 100644 --- a/src/test/ui/self/self_type_keyword.stderr +++ b/src/test/ui/self/self_type_keyword.stderr @@ -5,43 +5,43 @@ LL | struct Self; | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:25:13 + --> $DIR/self_type_keyword.rs:26:13 | LL | ref Self => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:27:13 + --> $DIR/self_type_keyword.rs:28:13 | LL | mut Self => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:29:17 + --> $DIR/self_type_keyword.rs:30:17 | LL | ref mut Self => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:33:15 + --> $DIR/self_type_keyword.rs:34:15 | LL | Foo { Self } => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:39:26 + --> $DIR/self_type_keyword.rs:40:26 | LL | extern crate core as Self; | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:44:32 + --> $DIR/self_type_keyword.rs:45:32 | LL | use std::option::Option as Self; | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:49:11 + --> $DIR/self_type_keyword.rs:50:11 | LL | trait Self {} | ^^^^ expected identifier, found keyword @@ -53,10 +53,19 @@ LL | struct Bar<'Self>; | ^^^^^ error: cannot find macro `Self!` in this scope - --> $DIR/self_type_keyword.rs:31:9 + --> $DIR/self_type_keyword.rs:32:9 | LL | Self!() => (), | ^^^^ -error: aborting due to 10 previous errors +error[E0392]: parameter `'Self` is never used + --> $DIR/self_type_keyword.rs:18:12 + | +LL | struct Bar<'Self>; + | ^^^^^ unused type parameter + | + = help: consider removing `'Self` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 11 previous errors +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/span/issue-36530.rs b/src/test/ui/span/issue-36530.rs index fbe1535caaed2..01d89c0f86870 100644 --- a/src/test/ui/span/issue-36530.rs +++ b/src/test/ui/span/issue-36530.rs @@ -15,3 +15,5 @@ mod foo { #![foo] //~ ERROR is currently unknown to the compiler //~| ERROR non-builtin inner attributes are unstable } + +fn main() {} diff --git a/src/test/ui/span/macro-ty-params.rs b/src/test/ui/span/macro-ty-params.rs index 5d93b1266a4ae..b18de6fba9da8 100644 --- a/src/test/ui/span/macro-ty-params.rs +++ b/src/test/ui/span/macro-ty-params.rs @@ -14,9 +14,11 @@ macro_rules! m { } } +macro_rules! foo { () => () } + fn main() { foo::!(); //~ ERROR generic arguments in macro path foo::<>!(); //~ ERROR generic arguments in macro path - m!(MyTrait<>); //~ ERROR generic arguments in macro path + m!(Default<>); //~ ERROR generic arguments in macro path //~^ ERROR unexpected generic arguments in path } diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 8a40556a6cd0e..3aa619a031280 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -1,26 +1,26 @@ -error: unexpected generic arguments in path +error: generic arguments in macro path --> $DIR/macro-ty-params.rs:20:8 | -LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path - | ^^^^^^^^^ +LL | foo::!(); //~ ERROR generic arguments in macro path + | ^^^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:20:15 + --> $DIR/macro-ty-params.rs:21:8 | -LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path - | ^^ +LL | foo::<>!(); //~ ERROR generic arguments in macro path + | ^^^^ -error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:18:8 +error: unexpected generic arguments in path + --> $DIR/macro-ty-params.rs:22:8 | -LL | foo::!(); //~ ERROR generic arguments in macro path - | ^^^^^ +LL | m!(Default<>); //~ ERROR generic arguments in macro path + | ^^^^^^^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:19:8 + --> $DIR/macro-ty-params.rs:22:15 | -LL | foo::<>!(); //~ ERROR generic arguments in macro path - | ^^^^ +LL | m!(Default<>); //~ ERROR generic arguments in macro path + | ^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/span/visibility-ty-params.rs b/src/test/ui/span/visibility-ty-params.rs index 5df28971e9942..932b4a4c6ec42 100644 --- a/src/test/ui/span/visibility-ty-params.rs +++ b/src/test/ui/span/visibility-ty-params.rs @@ -14,6 +14,7 @@ macro_rules! m { struct S(T); m!{ S } //~ ERROR unexpected generic arguments in path + //~| ERROR expected module, found struct `S` mod m { m!{ m<> } //~ ERROR unexpected generic arguments in path diff --git a/src/test/ui/span/visibility-ty-params.stderr b/src/test/ui/span/visibility-ty-params.stderr index 7719bd48c85bb..8f861e02aa509 100644 --- a/src/test/ui/span/visibility-ty-params.stderr +++ b/src/test/ui/span/visibility-ty-params.stderr @@ -5,10 +5,19 @@ LL | m!{ S } //~ ERROR unexpected generic arguments in path | ^^^^^ error: unexpected generic arguments in path - --> $DIR/visibility-ty-params.rs:19:9 + --> $DIR/visibility-ty-params.rs:20:9 | LL | m!{ m<> } //~ ERROR unexpected generic arguments in path | ^^^ -error: aborting due to 2 previous errors +error[E0577]: expected module, found struct `S` + --> $DIR/visibility-ty-params.rs:16:5 + | +LL | m!{ S } //~ ERROR unexpected generic arguments in path + | -^^^^ + | | + | did you mean `m`? + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0577`. diff --git a/src/test/ui/trace_macros-gate.rs b/src/test/ui/trace_macros-gate.rs index d4a7c4ed0e0f9..c358ac0d48580 100644 --- a/src/test/ui/trace_macros-gate.rs +++ b/src/test/ui/trace_macros-gate.rs @@ -12,15 +12,9 @@ fn main() { trace_macros!(); //~ ERROR `trace_macros` is not stable - trace_macros!(1); //~ ERROR `trace_macros` is not stable - trace_macros!(ident); //~ ERROR `trace_macros` is not stable - trace_macros!(for); //~ ERROR `trace_macros` is not stable - trace_macros!(true,); //~ ERROR `trace_macros` is not stable - trace_macros!(false 1); //~ ERROR `trace_macros` is not stable - - // Errors are signalled early for the above, before expansion. - // See trace_macros-gate2 and trace_macros-gate3. for examples - // of the below being caught. + //~| ERROR trace_macros! accepts only `true` or `false` + trace_macros!(true); //~ ERROR `trace_macros` is not stable + trace_macros!(false); //~ ERROR `trace_macros` is not stable macro_rules! expando { ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable diff --git a/src/test/ui/trace_macros-gate.stderr b/src/test/ui/trace_macros-gate.stderr index ed92e1227baf5..a6960f47a266d 100644 --- a/src/test/ui/trace_macros-gate.stderr +++ b/src/test/ui/trace_macros-gate.stderr @@ -6,48 +6,30 @@ LL | trace_macros!(); //~ ERROR `trace_macros` is not stable | = help: add #![feature(trace_macros)] to the crate attributes to enable -error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:15:5 - | -LL | trace_macros!(1); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^ +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-gate.rs:14:5 | - = help: add #![feature(trace_macros)] to the crate attributes to enable +LL | trace_macros!(); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^ error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) --> $DIR/trace_macros-gate.rs:16:5 | -LL | trace_macros!(ident); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^^^^^ +LL | trace_macros!(true); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(trace_macros)] to the crate attributes to enable error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) --> $DIR/trace_macros-gate.rs:17:5 | -LL | trace_macros!(for); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(trace_macros)] to the crate attributes to enable - -error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:18:5 - | -LL | trace_macros!(true,); //~ ERROR `trace_macros` is not stable +LL | trace_macros!(false); //~ ERROR `trace_macros` is not stable | ^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(trace_macros)] to the crate attributes to enable error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:19:5 - | -LL | trace_macros!(false 1); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(trace_macros)] to the crate attributes to enable - -error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:26:26 + --> $DIR/trace_macros-gate.rs:20:26 | LL | ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable | ^^^^^^^^^^^^^^^^^ @@ -57,6 +39,6 @@ LL | expando!(true); | = help: add #![feature(trace_macros)] to the crate attributes to enable -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.rs b/src/test/ui/tuple/tuple-struct-fields/test2.rs index eead027cb1351..db4d2fa59cc0f 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test2.rs +++ b/src/test/ui/tuple/tuple-struct-fields/test2.rs @@ -18,5 +18,7 @@ macro_rules! define_struct { } mod foo { - define_struct! { (foo) } + define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope } + +fn main() {} diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.stderr b/src/test/ui/tuple/tuple-struct-fields/test2.stderr index 983e74772ac69..cb79a51b6d8c6 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test2.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test2.stderr @@ -4,8 +4,15 @@ error: expected one of `)` or `,`, found `(` LL | struct S3(pub $t ()); | ^ expected one of `)` or `,` here ... -LL | define_struct! { (foo) } +LL | define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope | ------------------------ in this macro invocation -error: aborting due to previous error +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test2.rs:21:23 + | +LL | define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope + | ^^^ not found in this scope + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.rs b/src/test/ui/tuple/tuple-struct-fields/test3.rs index d666c8abd3c95..c5702866fe41e 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test3.rs +++ b/src/test/ui/tuple/tuple-struct-fields/test3.rs @@ -18,5 +18,7 @@ macro_rules! define_struct { } mod foo { - define_struct! { foo } + define_struct! { foo } //~ ERROR cannot find type `foo` in this scope } + +fn main() {} diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.stderr b/src/test/ui/tuple/tuple-struct-fields/test3.stderr index 6738595b99798..a0ac82917f153 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test3.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test3.stderr @@ -4,8 +4,15 @@ error: expected one of `)` or `,`, found `(` LL | struct S3(pub($t) ()); | ^ expected one of `)` or `,` here ... -LL | define_struct! { foo } +LL | define_struct! { foo } //~ ERROR cannot find type `foo` in this scope | ---------------------- in this macro invocation -error: aborting due to previous error +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test3.rs:21:22 + | +LL | define_struct! { foo } //~ ERROR cannot find type `foo` in this scope + | ^^^ not found in this scope + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/unsafe/unsafe-fn-autoderef.stderr b/src/test/ui/unsafe/unsafe-fn-autoderef.stderr index 13fcbb347c94b..7525f67051567 100644 --- a/src/test/ui/unsafe/unsafe-fn-autoderef.stderr +++ b/src/test/ui/unsafe/unsafe-fn-autoderef.stderr @@ -2,7 +2,9 @@ error[E0609]: no field `f` on type `*const Rec` --> $DIR/unsafe-fn-autoderef.rs:29:14 | LL | return p.f; //~ ERROR no field `f` on type `*const Rec` - | ^ help: `p` is a native pointer; try dereferencing it: `(*p).f` + | --^ + | | + | help: `p` is a raw pointer; try dereferencing it: `(*p).f` error: aborting due to previous error diff --git a/src/test/ui/variants/variant-used-as-type.stderr b/src/test/ui/variants/variant-used-as-type.stderr index 972fe8a8a616b..c72729923ef6d 100644 --- a/src/test/ui/variants/variant-used-as-type.stderr +++ b/src/test/ui/variants/variant-used-as-type.stderr @@ -3,28 +3,24 @@ error[E0573]: expected type, found variant `Ty::A` | LL | B(Ty::A), | ^^^^^ not a type -help: you can try using the variant's enum - | -LL | B(Ty), - | ^^ -help: you can try using the variant's enum +help: try using the variant's enum | LL | B(E), | ^ +LL | B(Ty), + | ^^ error[E0573]: expected type, found variant `E::A` --> $DIR/variant-used-as-type.rs:27:6 | LL | impl E::A {} | ^^^^ not a type -help: you can try using the variant's enum - | -LL | impl Ty {} - | ^^ -help: you can try using the variant's enum +help: try using the variant's enum | LL | impl E {} | ^ +LL | impl Ty {} + | ^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/write-to-static-mut-in-static.rs b/src/test/ui/write-to-static-mut-in-static.rs index 191f09b54ee73..983b5d48e60fc 100644 --- a/src/test/ui/write-to-static-mut-in-static.rs +++ b/src/test/ui/write-to-static-mut-in-static.rs @@ -12,10 +12,10 @@ pub static mut A: u32 = 0; pub static mut B: () = unsafe { A = 1; }; -//~^ ERROR cannot mutate statics in the initializer of another static +//~^ ERROR could not evaluate static initializer pub static mut C: u32 = unsafe { C = 1; 0 }; -//~^ ERROR cannot mutate statics in the initializer of another static +//~^ ERROR cycle detected pub static D: u32 = D; diff --git a/src/test/ui/write-to-static-mut-in-static.stderr b/src/test/ui/write-to-static-mut-in-static.stderr index 673a71b4642f3..335f849fb2472 100644 --- a/src/test/ui/write-to-static-mut-in-static.stderr +++ b/src/test/ui/write-to-static-mut-in-static.stderr @@ -1,14 +1,28 @@ -error: cannot mutate statics in the initializer of another static +error[E0080]: could not evaluate static initializer --> $DIR/write-to-static-mut-in-static.rs:14:33 | LL | pub static mut B: () = unsafe { A = 1; }; - | ^^^^^ + | ^^^^^ tried to modify a static's initial value from another static's initializer -error: cannot mutate statics in the initializer of another static +error[E0391]: cycle detected when const-evaluating `C` --> $DIR/write-to-static-mut-in-static.rs:17:34 | LL | pub static mut C: u32 = unsafe { C = 1; 0 }; | ^^^^^ + | +note: ...which requires const-evaluating `C`... + --> $DIR/write-to-static-mut-in-static.rs:17:1 + | +LL | pub static mut C: u32 = unsafe { C = 1; 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires const-evaluating `C`, completing the cycle +note: cycle used when const-evaluating + checking `C` + --> $DIR/write-to-static-mut-in-static.rs:17:1 + | +LL | pub static mut C: u32 = unsafe { C = 1; 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors +Some errors occurred: E0080, E0391. +For more information about an error, try `rustc --explain E0080`.