Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #42964

Merged
merged 30 commits into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b9a44fc
Update docs for fmt::write.
rthomas Jun 22, 2017
c5d078f
Update docs for std::fmt::format #29355.
rthomas Jun 22, 2017
60dd83e
add `allow_fail` test attribute
May 24, 2017
76d6052
Shorten some lines so this can pass the tidy checks
May 25, 2017
7ad9537
fix some tests i missed
May 25, 2017
45af6ee
Move global vars changing tests into run-pass
stepancheg Jun 24, 2017
8e5a302
Add a feature gate for the `#[allow_fail]` attribute
Jun 23, 2017
8edc3ca
Add compile-fail test for the new feature gate
Jun 23, 2017
4154f89
only show allowed failure count if there are allowed failures
Jun 25, 2017
d24d408
std: Fix implementation of `Alloc::alloc_one`
alexcrichton Jun 25, 2017
32b8579
make lint on-by-default/implied-by messages appear only once
zackmdavis Jun 26, 2017
330dab8
[libcore/cmp] Expand Ord/PartialOrd Derivable doc for enum types
behnam Jun 27, 2017
0dfd9c3
syntax: allow negative integer literal expression to be interpolated …
durka Jun 24, 2017
4fb67dc
Fix link reference
AndiDog Jun 28, 2017
40dec09
Document that `/` works as separator on Windows
matklad Jun 28, 2017
b689e46
Stamp the whole build script
aidanhs Jun 28, 2017
5ed3894
Move type parameter shadowing test to `ui`
estebank Jun 28, 2017
984e764
Record some details to help with possible bad clocks
aidanhs Jun 28, 2017
bea4e60
Rollup merge of #42219 - pwoolcoc:add-allow-fail-to-libtest, r=Guilla…
Jun 29, 2017
8b32c51
Rollup merge of #42831 - rthomas:master, r=QuietMisdreavus
Jun 29, 2017
5682494
Rollup merge of #42832 - rthomas:doc-fmt, r=steveklabnik
Jun 29, 2017
4bae0d8
Rollup merge of #42884 - stepancheg:set-env-run-pass, r=alexcrichton
Jun 29, 2017
effd1e0
Rollup merge of #42886 - durka:pplmm-mwe, r=petrochenkov
Jun 29, 2017
ea762f2
Rollup merge of #42901 - alexcrichton:alloc-one, r=sfackler
Jun 29, 2017
bfe0098
Rollup merge of #42919 - zackmdavis:once_again_we_heard_you_the_first…
Jun 29, 2017
647a36d
Rollup merge of #42920 - behnam:cmp, r=BurntSushi
Jun 29, 2017
486aca7
Rollup merge of #42946 - AndiDog:patch-1, r=GuillaumeGomez
Jun 29, 2017
4f12154
Rollup merge of #42953 - estebank:fix-20729, r=petrochenkov
Jun 29, 2017
b0ed6d1
Rollup merge of #42955 - matklad:doc-path, r=steveklabnik
Jun 29, 2017
d3329d7
Rollup merge of #42958 - aidanhs:aphs-better-stamping, r=Mark-Simulacrum
Jun 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,22 @@ before_script:
if [[ "$SKIP_BUILD" == true ]]; then
export RUN_SCRIPT="echo 'skipping, not a full build'";
else
RUN_SCRIPT="stamp src/ci/init_repo.sh . $HOME/rustsrc";
RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc";
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
export RUN_SCRIPT="$RUN_SCRIPT && stamp src/ci/run.sh";
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh";
else
export RUN_SCRIPT="$RUN_SCRIPT && stamp src/ci/docker/run.sh $IMAGE";
export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE";
fi
fi

# Log time information from this machine and an external machine for insight into possible
# clock drift. Timezones don't matter since relative deltas give all the necessary info.
script:
- sh -x -c "$RUN_SCRIPT"
- >
date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g'
- stamp sh -x -c "$RUN_SCRIPT"
- >
date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g'

after_success:
- >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The tracking issue for this feature is: [#40872]

[#29599]: https://github.com/rust-lang/rust/issues/40872
[#40872]: https://github.com/rust-lang/rust/issues/40872

------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ pub unsafe trait Alloc {
{
let k = Layout::new::<T>();
if k.size() > 0 {
unsafe { self.alloc(k).map(|p|Unique::new(*p as *mut T)) }
unsafe { self.alloc(k).map(|p| Unique::new(p as *mut T)) }
} else {
Err(AllocErr::invalid_input("zero-sized type invalid for alloc_one"))
}
Expand Down
8 changes: 3 additions & 5 deletions src/liballoc/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,10 @@ pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};

use string;

/// The format function takes a precompiled format string and a list of
/// arguments, to return the resulting formatted string.
/// The `format` function takes an `Arguments` struct and returns the resulting
/// formatted string.
///
/// # Arguments
///
/// * args - a structure of arguments generated via the `format_args!` macro.
/// The `Arguments` instance can be created with the `format_args!` macro.
///
/// # Examples
///
Expand Down
10 changes: 6 additions & 4 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ impl<T: Ord> Ord for Reverse<T> {
///
/// ## Derivable
///
/// This trait can be used with `#[derive]`. When `derive`d, it will produce a lexicographic
/// ordering based on the top-to-bottom declaration order of the struct's members.
/// This trait can be used with `#[derive]`. When `derive`d on structs, it will produce a
/// lexicographic ordering based on the top-to-bottom declaration order of the struct's members.
/// When `derive`d on enums, variants are ordered by their top-to-bottom declaration order.
///
/// ## How can I implement `Ord`?
///
Expand Down Expand Up @@ -512,8 +513,9 @@ impl PartialOrd for Ordering {
///
/// ## Derivable
///
/// This trait can be used with `#[derive]`. When `derive`d, it will produce a lexicographic
/// ordering based on the top-to-bottom declaration order of the struct's members.
/// This trait can be used with `#[derive]`. When `derive`d on structs, it will produce a
/// lexicographic ordering based on the top-to-bottom declaration order of the struct's members.
/// When `derive`d on enums, variants are ordered by their top-to-bottom declaration order.
///
/// ## How can I implement `PartialOrd`?
///
Expand Down
11 changes: 4 additions & 7 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,14 +897,11 @@ pub trait UpperExp {
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// The `write` function takes an output stream, a precompiled format string,
/// and a list of arguments. The arguments will be formatted according to the
/// specified format string into the output stream provided.
/// The `write` function takes an output stream, and an `Arguments` struct
/// that can be precompiled with the `format_args!` macro.
///
/// # Arguments
///
/// * output - the buffer to write output to
/// * args - the precompiled arguments generated by `format_args!`
/// The arguments will be formatted according to the specified format string
/// into the output stream provided.
///
/// # Examples
///
Expand Down
26 changes: 13 additions & 13 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ pub fn raw_struct_lint<'a, S>(sess: &'a Session,
}

let name = lint.name_lower();
let mut def = None;

// Except for possible note details, forbid behaves like deny.
let effective_level = if level == Forbid { Deny } else { level };
Expand All @@ -525,7 +524,8 @@ pub fn raw_struct_lint<'a, S>(sess: &'a Session,

match source {
Default => {
err.note(&format!("#[{}({})] on by default", level.as_str(), name));
sess.diag_note_once(&mut err, lint,
&format!("#[{}({})] on by default", level.as_str(), name));
},
CommandLine(lint_flag_val) => {
let flag = match level {
Expand All @@ -534,20 +534,24 @@ pub fn raw_struct_lint<'a, S>(sess: &'a Session,
};
let hyphen_case_lint_name = name.replace("_", "-");
if lint_flag_val.as_str() == name {
err.note(&format!("requested on the command line with `{} {}`",
flag, hyphen_case_lint_name));
sess.diag_note_once(&mut err, lint,
&format!("requested on the command line with `{} {}`",
flag, hyphen_case_lint_name));
} else {
let hyphen_case_flag_val = lint_flag_val.as_str().replace("_", "-");
err.note(&format!("`{} {}` implied by `{} {}`",
flag, hyphen_case_lint_name, flag, hyphen_case_flag_val));
sess.diag_note_once(&mut err, lint,
&format!("`{} {}` implied by `{} {}`",
flag, hyphen_case_lint_name, flag,
hyphen_case_flag_val));
}
},
Node(lint_attr_name, src) => {
def = Some(src);
sess.diag_span_note_once(&mut err, lint, src, "lint level defined here");
if lint_attr_name.as_str() != name {
let level_str = level.as_str();
err.note(&format!("#[{}({})] implied by #[{}({})]",
level_str, name, level_str, lint_attr_name));
sess.diag_note_once(&mut err, lint,
&format!("#[{}({})] implied by #[{}({})]",
level_str, name, level_str, lint_attr_name));
}
}
}
Expand All @@ -563,10 +567,6 @@ pub fn raw_struct_lint<'a, S>(sess: &'a Session,
err.note(&citation);
}

if let Some(span) = def {
sess.diag_span_note_once(&mut err, lint, span, "lint level defined here");
}

err
}

Expand Down
60 changes: 43 additions & 17 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ pub struct Session {
pub working_dir: (String, bool),
pub lint_store: RefCell<lint::LintStore>,
pub lints: RefCell<lint::LintTable>,
/// Set of (LintId, span, message) tuples tracking lint (sub)diagnostics
/// that have been set once, but should not be set again, in order to avoid
/// redundantly verbose output (Issue #24690).
pub one_time_diagnostics: RefCell<FxHashSet<(lint::LintId, Span, String)>>,
/// Set of (LintId, Option<Span>, message) tuples tracking lint
/// (sub)diagnostics that have been set once, but should not be set again,
/// in order to avoid redundantly verbose output (Issue #24690).
pub one_time_diagnostics: RefCell<FxHashSet<(lint::LintId, Option<Span>, String)>>,
pub plugin_llvm_passes: RefCell<Vec<String>>,
pub plugin_attributes: RefCell<Vec<(String, AttributeType)>>,
pub crate_types: RefCell<Vec<config::CrateType>>,
Expand Down Expand Up @@ -157,6 +157,13 @@ pub struct PerfStats {
pub decode_def_path_tables_time: Cell<Duration>,
}

/// Enum to support dispatch of one-time diagnostics (in Session.diag_once)
enum DiagnosticBuilderMethod {
Note,
SpanNote,
// add more variants as needed to support one-time diagnostics
}

impl Session {
pub fn local_crate_disambiguator(&self) -> Symbol {
*self.crate_disambiguator.borrow()
Expand Down Expand Up @@ -329,34 +336,53 @@ impl Session {
&self.parse_sess.span_diagnostic
}

/// Analogous to calling `.span_note` on the given DiagnosticBuilder, but
/// deduplicates on lint ID, span, and message for this `Session` if we're
/// not outputting in JSON mode.
//
// FIXME: if the need arises for one-time diagnostics other than
// `span_note`, we almost certainly want to generalize this
// "check/insert-into the one-time diagnostics map, then set message if
// it's not already there" code to accomodate all of them
pub fn diag_span_note_once<'a, 'b>(&'a self,
diag_builder: &'b mut DiagnosticBuilder<'a>,
lint: &'static lint::Lint, span: Span, message: &str) {
/// Analogous to calling methods on the given `DiagnosticBuilder`, but
/// deduplicates on lint ID, span (if any), and message for this `Session`
/// if we're not outputting in JSON mode.
fn diag_once<'a, 'b>(&'a self,
diag_builder: &'b mut DiagnosticBuilder<'a>,
method: DiagnosticBuilderMethod,
lint: &'static lint::Lint, message: &str, span: Option<Span>) {
let mut do_method = || {
match method {
DiagnosticBuilderMethod::Note => {
diag_builder.note(message);
},
DiagnosticBuilderMethod::SpanNote => {
diag_builder.span_note(span.expect("span_note expects a span"), message);
}
}
};

match self.opts.error_format {
// when outputting JSON for tool consumption, the tool might want
// the duplicates
config::ErrorOutputType::Json => {
diag_builder.span_note(span, &message);
do_method()
},
_ => {
let lint_id = lint::LintId::of(lint);
let id_span_message = (lint_id, span, message.to_owned());
let fresh = self.one_time_diagnostics.borrow_mut().insert(id_span_message);
if fresh {
diag_builder.span_note(span, &message);
do_method()
}
}
}
}

pub fn diag_span_note_once<'a, 'b>(&'a self,
diag_builder: &'b mut DiagnosticBuilder<'a>,
lint: &'static lint::Lint, span: Span, message: &str) {
self.diag_once(diag_builder, DiagnosticBuilderMethod::SpanNote, lint, message, Some(span));
}

pub fn diag_note_once<'a, 'b>(&'a self,
diag_builder: &'b mut DiagnosticBuilder<'a>,
lint: &'static lint::Lint, message: &str) {
self.diag_once(diag_builder, DiagnosticBuilderMethod::Note, lint, message, None);
}

pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
self.parse_sess.codemap()
}
Expand Down
10 changes: 3 additions & 7 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,13 +684,9 @@ fn fl_lit_check_expr(cx: &EarlyContext, expr: &ast::Expr) {
// These may occur in patterns
// and can maybe contain float literals
ExprKind::Unary(_, ref f) => fl_lit_check_expr(cx, f),
// These may occur in patterns
// and can't contain float literals
ExprKind::Path(..) => (),
// If something unhandled is encountered, we need to expand the
// search or ignore more ExprKinds.
_ => span_bug!(expr.span, "Unhandled expression {:?} in float lit pattern lint",
expr.node),
// Other kinds of exprs can't occur in patterns so we don't have to check them
// (ast_validation will emit an error if they occur)
_ => (),
}
}

Expand Down
26 changes: 26 additions & 0 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ impl<'a> AstValidator<'a> {
}
}
}

/// matches '-' lit | lit (cf. parser::Parser::parse_pat_literal_maybe_minus)
fn check_expr_within_pat(&self, expr: &Expr) {
match expr.node {
ExprKind::Lit(..) | ExprKind::Path(..) => {}
ExprKind::Unary(UnOp::Neg, ref inner)
if match inner.node { ExprKind::Lit(_) => true, _ => false } => {}
_ => self.err_handler().span_err(expr.span, "arbitrary expressions aren't allowed \
in patterns")
}
}
}

impl<'a> Visitor<'a> for AstValidator<'a> {
Expand Down Expand Up @@ -308,6 +319,21 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}
visit::walk_generics(self, g)
}

fn visit_pat(&mut self, pat: &'a Pat) {
match pat.node {
PatKind::Lit(ref expr) => {
self.check_expr_within_pat(expr);
}
PatKind::Range(ref start, ref end, _) => {
self.check_expr_within_pat(start);
self.check_expr_within_pat(end);
}
_ => {}
}

visit::walk_pat(self, pat)
}
}

pub fn check_crate(session: &Session, krate: &Crate) {
Expand Down
Loading