From 7e70a63e615d399072c8b8c2054d8d61844240d6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jul 2017 01:37:47 +0200 Subject: [PATCH 1/6] Throw errors when doc comments are added where they're unused --- src/librustc/hir/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 41 ++++++++++++++++++++--- src/test/compile-fail/issue-34222.rs | 2 +- src/test/compile-fail/useless_comment.rs | 26 ++++++++++++++ src/test/compile-fail/useless_comment2.rs | 25 ++++++++++++++ src/test/compile-fail/useless_comment3.rs | 22 ++++++++++++ 6 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 src/test/compile-fail/useless_comment.rs create mode 100644 src/test/compile-fail/useless_comment2.rs create mode 100644 src/test/compile-fail/useless_comment3.rs diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index fd79ec3b6b9..1b14caad3c8 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1679,7 +1679,7 @@ pub struct Item { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum Item_ { - /// An`extern crate` item, with optional original crate name, + /// An `extern crate` item, with optional original crate name, /// /// e.g. `extern crate foo` or `extern crate foo_bar as foo` ItemExternCrate(Option), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index af9a198b983..047f4b979d9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2131,14 +2131,14 @@ impl<'a> Parser<'a> { } else { Ok(self.mk_expr(span, ExprKind::Tup(es), attrs)) } - }, + } token::OpenDelim(token::Brace) => { return self.parse_block_expr(lo, BlockCheckMode::Default, attrs); - }, - token::BinOp(token::Or) | token::OrOr => { + } + token::BinOp(token::Or) | token::OrOr => { let lo = self.span; return self.parse_lambda_expr(lo, CaptureBy::Ref, attrs); - }, + } token::OpenDelim(token::Bracket) => { self.bump(); @@ -2387,7 +2387,6 @@ impl<'a> Parser<'a> { pub fn parse_block_expr(&mut self, lo: Span, blk_mode: BlockCheckMode, outer_attrs: ThinVec) -> PResult<'a, P> { - self.expect(&token::OpenDelim(token::Brace))?; let mut attrs = outer_attrs; @@ -2421,6 +2420,12 @@ impl<'a> Parser<'a> { expr.map(|mut expr| { attrs.extend::>(expr.attrs.into()); expr.attrs = attrs; + if if let Some(ref doc) = expr.attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + true + } else { false } { + return expr; + } match expr.node { ExprKind::If(..) | ExprKind::IfLet(..) => { if !expr.attrs.is_empty() { @@ -3105,6 +3110,9 @@ impl<'a> Parser<'a> { // `else` token already eaten pub fn parse_else_expr(&mut self) -> PResult<'a, P> { + if self.prev_token_kind == PrevTokenKind::DocComment { + return Err(self.span_fatal_err(self.span, Error::UselessDocComment)); + } if self.eat_keyword(keywords::If) { return self.parse_if_expr(ThinVec::new()); } else { @@ -3118,6 +3126,9 @@ impl<'a> Parser<'a> { span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { // Parse: `for in ` + if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + } let pat = self.parse_pat()?; self.expect_keyword(keywords::In)?; @@ -3133,6 +3144,9 @@ impl<'a> Parser<'a> { pub fn parse_while_expr(&mut self, opt_ident: Option, span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { + if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + } if self.token.is_keyword(keywords::Let) { return self.parse_while_let_expr(opt_ident, span_lo, attrs); } @@ -3161,6 +3175,9 @@ impl<'a> Parser<'a> { pub fn parse_loop_expr(&mut self, opt_ident: Option, span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { + if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + } let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); let span = span_lo.to(body.span); @@ -3171,6 +3188,9 @@ impl<'a> Parser<'a> { pub fn parse_catch_expr(&mut self, span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { + if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + } let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); Ok(self.mk_expr(span_lo.to(body.span), ExprKind::Catch(body), attrs)) @@ -3178,6 +3198,9 @@ impl<'a> Parser<'a> { // `match` token already eaten fn parse_match_expr(&mut self, mut attrs: ThinVec) -> PResult<'a, P> { + if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + } let match_span = self.prev_span; let lo = self.prev_span; let discriminant = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, @@ -3215,6 +3238,9 @@ impl<'a> Parser<'a> { maybe_whole!(self, NtArm, |x| x); let attrs = self.parse_outer_attributes()?; + if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + } let pats = self.parse_pats()?; let guard = if self.eat_keyword(keywords::If) { Some(self.parse_expr()?) @@ -3669,6 +3695,9 @@ impl<'a> Parser<'a> { /// Parse a local variable declaration fn parse_local(&mut self, attrs: ThinVec) -> PResult<'a, P> { + if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { + self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); + } let lo = self.span; let pat = self.parse_pat()?; @@ -4158,6 +4187,8 @@ impl<'a> Parser<'a> { stmts.push(stmt); } else if self.token == token::Eof { break; + } else if let token::DocComment(_) = self.token { + return Err(self.span_fatal_err(self.span, Error::UselessDocComment)); } else { // Found only `;` or `}`. continue; diff --git a/src/test/compile-fail/issue-34222.rs b/src/test/compile-fail/issue-34222.rs index 4609c0ccb1c..d406f59d0a2 100644 --- a/src/test/compile-fail/issue-34222.rs +++ b/src/test/compile-fail/issue-34222.rs @@ -13,6 +13,6 @@ #[rustc_error] fn main() { //~ ERROR compilation successful - /// crash + // crash let x = 0; } diff --git a/src/test/compile-fail/useless_comment.rs b/src/test/compile-fail/useless_comment.rs new file mode 100644 index 00000000000..a32988aff12 --- /dev/null +++ b/src/test/compile-fail/useless_comment.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo3() -> i32 { + let mut x = 12; + /// z //~ ERROR E0585 + while x < 1 { + /// x //~ ERROR E0585 + //~^ ERROR attributes on non-item statements and expressions are experimental + x += 1; + } + /// d //~ ERROR E0585 + return x; +} + +fn main() { + /// e //~ ERROR E0585 + foo3(); +} diff --git a/src/test/compile-fail/useless_comment2.rs b/src/test/compile-fail/useless_comment2.rs new file mode 100644 index 00000000000..52ac7b6a769 --- /dev/null +++ b/src/test/compile-fail/useless_comment2.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() { + /// a //~ ERROR E0585 + let x = 12; + + /// b //~ ERROR E0585 + match x { + /// c //~ ERROR E0585 + 1 => {}, + _ => {} + } +} + +fn main() { + foo(); +} \ No newline at end of file diff --git a/src/test/compile-fail/useless_comment3.rs b/src/test/compile-fail/useless_comment3.rs new file mode 100644 index 00000000000..c26031b5eb6 --- /dev/null +++ b/src/test/compile-fail/useless_comment3.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() { + let x = 13; + /// x //~ ERROR E0585 + if x == 12 { + /// y + println!("hello"); + } +} + +fn main() { + foo(); +} From b68a03bded5380278ae162bacc79d926e41fd76c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 3 Jul 2017 00:27:36 +0200 Subject: [PATCH 2/6] Change doc comment to code comment --- src/librustc/middle/region.rs | 8 +++---- src/librustc_typeck/check/wfcheck.rs | 34 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 6455d7ecf85..39cb5d1b8c8 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -458,10 +458,10 @@ impl<'tcx> RegionMaps { -> CodeExtent { if scope_a == scope_b { return scope_a; } - /// [1] The initial values for `a_buf` and `b_buf` are not used. - /// The `ancestors_of` function will return some prefix that - /// is re-initialized with new values (or else fallback to a - /// heap-allocated vector). + // [1] The initial values for `a_buf` and `b_buf` are not used. + // The `ancestors_of` function will return some prefix that + // is re-initialized with new values (or else fallback to a + // heap-allocated vector). let mut a_buf: [CodeExtent; 32] = [scope_a /* [1] */; 32]; let mut a_vec: Vec = vec![]; let mut b_buf: [CodeExtent; 32] = [scope_b /* [1] */; 32]; diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 69cd1414628..cf5882bb9bd 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -89,23 +89,23 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { tcx.item_path_str(tcx.hir.local_def_id(item.id))); match item.node { - /// Right now we check that every default trait implementation - /// has an implementation of itself. Basically, a case like: - /// - /// `impl Trait for T {}` - /// - /// has a requirement of `T: Trait` which was required for default - /// method implementations. Although this could be improved now that - /// there's a better infrastructure in place for this, it's being left - /// for a follow-up work. - /// - /// Since there's such a requirement, we need to check *just* positive - /// implementations, otherwise things like: - /// - /// impl !Send for T {} - /// - /// won't be allowed unless there's an *explicit* implementation of `Send` - /// for `T` + // Right now we check that every default trait implementation + // has an implementation of itself. Basically, a case like: + // + // `impl Trait for T {}` + // + // has a requirement of `T: Trait` which was required for default + // method implementations. Although this could be improved now that + // there's a better infrastructure in place for this, it's being left + // for a follow-up work. + // + // Since there's such a requirement, we need to check *just* positive + // implementations, otherwise things like: + // + // impl !Send for T {} + // + // won't be allowed unless there's an *explicit* implementation of `Send` + // for `T` hir::ItemImpl(_, hir::ImplPolarity::Positive, _, _, ref trait_ref, ref self_ty, _) => { self.check_impl(item, self_ty, trait_ref); From 1cebf98e4c2654548e764e937e0b712220ffb600 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 16 Jul 2017 00:17:35 +0200 Subject: [PATCH 3/6] Make a lint instead --- src/librustc/hir/mod.rs | 7 ++++ src/librustc_lint/builtin.rs | 40 +++++++++++++++++++++++ src/librustc_lint/lib.rs | 1 + src/libsyntax/ast.rs | 7 ++++ src/libsyntax/parse/parser.rs | 32 ------------------ src/test/compile-fail/useless_comment.rs | 28 +++++++++------- src/test/compile-fail/useless_comment2.rs | 25 -------------- src/test/compile-fail/useless_comment3.rs | 22 ------------- 8 files changed, 71 insertions(+), 91 deletions(-) delete mode 100644 src/test/compile-fail/useless_comment2.rs delete mode 100644 src/test/compile-fail/useless_comment3.rs diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 1b14caad3c8..a3a133daa09 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -892,6 +892,13 @@ impl Decl_ { DeclItem(_) => &[] } } + + pub fn is_local(&self) -> bool { + match *self { + Decl_::DeclLocal(_) => true, + _ => false, + } + } } /// represents one arm of a 'match' diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 02d68a41b4c..ca30ed4a536 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -722,6 +722,46 @@ impl EarlyLintPass for IllegalFloatLiteralPattern { } } +declare_lint! { + pub UNUSED_DOC_COMMENT, + Warn, + "detects doc comments that aren't used by rustdoc" +} + +#[derive(Copy, Clone)] +pub struct UnusedDocComment; + +impl LintPass for UnusedDocComment { + fn get_lints(&self) -> LintArray { + lint_array![UNUSED_DOC_COMMENT] + } +} + +impl UnusedDocComment { + fn warn_if_doc<'a, 'tcx, + I: Iterator, + C: LintContext<'tcx>>(&self, mut attrs: I, cx: &C) { + if let Some(attr) = attrs.find(|a| a.is_value_str() && a.check_name("doc")) { + cx.struct_span_lint(UNUSED_DOC_COMMENT, attr.span, "doc comment not used by rustdoc") + .emit(); + } + } +} + +impl EarlyLintPass for UnusedDocComment { + fn check_local(&mut self, cx: &EarlyContext, decl: &ast::Local) { + self.warn_if_doc(decl.attrs.iter(), cx); + } + + fn check_arm(&mut self, cx: &EarlyContext, arm: &ast::Arm) { + self.warn_if_doc(arm.attrs.iter(), cx); + } + + fn check_expr(&mut self, cx: &EarlyContext, expr: &ast::Expr) { + self.warn_if_doc(expr.attrs.iter(), cx); + } +} + declare_lint! { pub UNCONDITIONAL_RECURSION, Warn, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 21dca7f6c61..83c00c178a0 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -111,6 +111,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { UnusedImportBraces, AnonymousParameters, IllegalFloatLiteralPattern, + UnusedDocComment, ); add_early_builtin_with_new!(sess, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f7d9d532062..df3f68fd1c6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -718,6 +718,13 @@ impl Stmt { }; self } + + pub fn is_item(&self) -> bool { + match self.node { + StmtKind::Local(_) => true, + _ => false, + } + } } impl fmt::Debug for Stmt { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 047f4b979d9..582f72e398d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2420,12 +2420,6 @@ impl<'a> Parser<'a> { expr.map(|mut expr| { attrs.extend::>(expr.attrs.into()); expr.attrs = attrs; - if if let Some(ref doc) = expr.attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - true - } else { false } { - return expr; - } match expr.node { ExprKind::If(..) | ExprKind::IfLet(..) => { if !expr.attrs.is_empty() { @@ -3110,9 +3104,6 @@ impl<'a> Parser<'a> { // `else` token already eaten pub fn parse_else_expr(&mut self) -> PResult<'a, P> { - if self.prev_token_kind == PrevTokenKind::DocComment { - return Err(self.span_fatal_err(self.span, Error::UselessDocComment)); - } if self.eat_keyword(keywords::If) { return self.parse_if_expr(ThinVec::new()); } else { @@ -3126,9 +3117,6 @@ impl<'a> Parser<'a> { span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { // Parse: `for in ` - if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - } let pat = self.parse_pat()?; self.expect_keyword(keywords::In)?; @@ -3144,9 +3132,6 @@ impl<'a> Parser<'a> { pub fn parse_while_expr(&mut self, opt_ident: Option, span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { - if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - } if self.token.is_keyword(keywords::Let) { return self.parse_while_let_expr(opt_ident, span_lo, attrs); } @@ -3175,9 +3160,6 @@ impl<'a> Parser<'a> { pub fn parse_loop_expr(&mut self, opt_ident: Option, span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { - if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - } let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); let span = span_lo.to(body.span); @@ -3188,9 +3170,6 @@ impl<'a> Parser<'a> { pub fn parse_catch_expr(&mut self, span_lo: Span, mut attrs: ThinVec) -> PResult<'a, P> { - if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - } let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); Ok(self.mk_expr(span_lo.to(body.span), ExprKind::Catch(body), attrs)) @@ -3198,9 +3177,6 @@ impl<'a> Parser<'a> { // `match` token already eaten fn parse_match_expr(&mut self, mut attrs: ThinVec) -> PResult<'a, P> { - if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - } let match_span = self.prev_span; let lo = self.prev_span; let discriminant = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, @@ -3238,9 +3214,6 @@ impl<'a> Parser<'a> { maybe_whole!(self, NtArm, |x| x); let attrs = self.parse_outer_attributes()?; - if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - } let pats = self.parse_pats()?; let guard = if self.eat_keyword(keywords::If) { Some(self.parse_expr()?) @@ -3695,9 +3668,6 @@ impl<'a> Parser<'a> { /// Parse a local variable declaration fn parse_local(&mut self, attrs: ThinVec) -> PResult<'a, P> { - if let Some(doc) = attrs.iter().find(|x| x.is_sugared_doc) { - self.span_fatal_err(doc.span, Error::UselessDocComment).emit(); - } let lo = self.span; let pat = self.parse_pat()?; @@ -4187,8 +4157,6 @@ impl<'a> Parser<'a> { stmts.push(stmt); } else if self.token == token::Eof { break; - } else if let token::DocComment(_) = self.token { - return Err(self.span_fatal_err(self.span, Error::UselessDocComment)); } else { // Found only `;` or `}`. continue; diff --git a/src/test/compile-fail/useless_comment.rs b/src/test/compile-fail/useless_comment.rs index a32988aff12..bceec186120 100644 --- a/src/test/compile-fail/useless_comment.rs +++ b/src/test/compile-fail/useless_comment.rs @@ -8,19 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo3() -> i32 { - let mut x = 12; - /// z //~ ERROR E0585 - while x < 1 { - /// x //~ ERROR E0585 - //~^ ERROR attributes on non-item statements and expressions are experimental - x += 1; +#![deny(unused_doc_comment)] + +fn foo() { + /// a //~ ERROR unused doc comment + let x = 12; + + /// b //~ ERROR unused doc comment + match x { + /// c //~ ERROR unused doc comment + 1 => {}, + _ => {} } - /// d //~ ERROR E0585 - return x; + + /// foo //~ ERROR unused doc comment + unsafe {} } fn main() { - /// e //~ ERROR E0585 - foo3(); -} + foo(); +} \ No newline at end of file diff --git a/src/test/compile-fail/useless_comment2.rs b/src/test/compile-fail/useless_comment2.rs deleted file mode 100644 index 52ac7b6a769..00000000000 --- a/src/test/compile-fail/useless_comment2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() { - /// a //~ ERROR E0585 - let x = 12; - - /// b //~ ERROR E0585 - match x { - /// c //~ ERROR E0585 - 1 => {}, - _ => {} - } -} - -fn main() { - foo(); -} \ No newline at end of file diff --git a/src/test/compile-fail/useless_comment3.rs b/src/test/compile-fail/useless_comment3.rs deleted file mode 100644 index c26031b5eb6..00000000000 --- a/src/test/compile-fail/useless_comment3.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() { - let x = 13; - /// x //~ ERROR E0585 - if x == 12 { - /// y - println!("hello"); - } -} - -fn main() { - foo(); -} From 2f2623b79db33fc3bcb8bd165c549b5bba1ee240 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 27 Jul 2017 20:40:20 +0200 Subject: [PATCH 4/6] Update tests --- src/test/compile-fail/issue-34222.rs | 18 ------------------ src/test/compile-fail/useless_comment.rs | 8 ++++---- 2 files changed, 4 insertions(+), 22 deletions(-) delete mode 100644 src/test/compile-fail/issue-34222.rs diff --git a/src/test/compile-fail/issue-34222.rs b/src/test/compile-fail/issue-34222.rs deleted file mode 100644 index d406f59d0a2..00000000000 --- a/src/test/compile-fail/issue-34222.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -#[rustc_error] -fn main() { //~ ERROR compilation successful - // crash - let x = 0; -} diff --git a/src/test/compile-fail/useless_comment.rs b/src/test/compile-fail/useless_comment.rs index bceec186120..a1172bb214d 100644 --- a/src/test/compile-fail/useless_comment.rs +++ b/src/test/compile-fail/useless_comment.rs @@ -11,17 +11,17 @@ #![deny(unused_doc_comment)] fn foo() { - /// a //~ ERROR unused doc comment + /// a //~ ERROR doc comment not used by rustdoc let x = 12; - /// b //~ ERROR unused doc comment + /// b //~ doc comment not used by rustdoc match x { - /// c //~ ERROR unused doc comment + /// c //~ ERROR doc comment not used by rustdoc 1 => {}, _ => {} } - /// foo //~ ERROR unused doc comment + /// foo //~ ERROR doc comment not used by rustdoc unsafe {} } From 5636d325ed50d859091b93abfed1c6d6fd8cff56 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 29 Jul 2017 14:35:09 +0200 Subject: [PATCH 5/6] Update cargo version --- src/Cargo.lock | 13 +++++++++++-- src/tools/cargo | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 1df8bcf74cd..c4ab56a9576 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0-rc.2 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -323,7 +323,7 @@ name = "crates-io" version = "0.11.0" dependencies = [ "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.11.0-rc.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -436,6 +436,14 @@ dependencies = [ "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "error-chain" +version = "0.11.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error_index_generator" version = "0.0.0" @@ -2150,6 +2158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" +"checksum error-chain 0.11.0-rc.2 (registry+https://github.com/rust-lang/crates.io-index)" = "38d3a55d9a7a456748f2a3912c0941a5d9a68006eb15b3c3c9836b8420dc102d" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" "checksum flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "36df0166e856739905cd3d7e0b210fe818592211a008862599845e012d8d304c" "checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" diff --git a/src/tools/cargo b/src/tools/cargo index 88aa6423a16..305bc25d5e1 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 88aa6423a164774d09abc78a24e74e8e665f651b +Subproject commit 305bc25d5e105e84ffe261655b46cf74570f6e5b From 3142ca0a6562ecf4653e2f1b1da19de6270322ec Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 29 Jul 2017 20:29:50 +0200 Subject: [PATCH 6/6] Update rls submodule --- src/tools/rls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rls b/src/tools/rls index 79d659e5699..06b48d1c97d 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 79d659e5699fbf7db5b4819e9a442fb3f550472a +Subproject commit 06b48d1c97dd69968a24b4f506e85e3a3efb7dea