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 14 pull requests #33354

Merged
merged 60 commits into from
May 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3eef083
libsyntax/pp: minor modernizations
birkenfeld May 1, 2016
4186169
libsyntax/pp: replace manual ring buffer with a VecDeque
birkenfeld May 1, 2016
b51698a
match check: note "catchall" patterns in unreachable error
birkenfeld May 1, 2016
ffba7b7
typeck: remove confusing suggestion for calling a fn type
birkenfeld May 1, 2016
0e89f55
E0269: add suggestion to check for trailing semicolons
birkenfeld May 1, 2016
d20b406
diagnostics for E0432: imports are relative to crate root
birkenfeld May 1, 2016
9e23000
lexer: do not display char confusingly in error message
birkenfeld May 2, 2016
38c8836
docs: Changed docs for `size_of` to describe size as a stride offset
cramertj May 2, 2016
9fe3c06
libstd: correct the link to functions in io module documentation
Ryman May 2, 2016
a20ee76
revamp MultiSpan and introduce new snippet code
nikomatsakis Apr 20, 2016
e7c7a18
adapt JSON to new model
nikomatsakis Apr 20, 2016
5b150cf
add borrowck info inline in main snippet
nikomatsakis Apr 20, 2016
11dc974
refactor to use new snippet code and model
nikomatsakis Apr 20, 2016
d9a947c
use new `note_expected_found` API
nikomatsakis Apr 20, 2016
e416518
update test cases to reflect new messages
nikomatsakis Apr 20, 2016
1ff1887
thread tighter span for closures around
nikomatsakis Apr 20, 2016
489a6c9
replace fileline_{help,note} with {help,note}
nikomatsakis Apr 20, 2016
41a652e
WIP factor out RudimentaryEmitter
nikomatsakis Apr 20, 2016
71c6f81
change errors from Yellow to Magenta
nikomatsakis Apr 20, 2016
4714394
delete the json-errors test
nikomatsakis Apr 20, 2016
9d022f2
rewrite span-length to include strings
nikomatsakis Apr 20, 2016
1067850
refactor the Emitter trait
nikomatsakis Apr 21, 2016
8013eeb
fix error message in librustc_driver tests
nikomatsakis Apr 21, 2016
5adfe5b
Nit: comments should be uppercase letter
nikomatsakis Apr 26, 2016
9a9c9af
Fix whitespace
nikomatsakis Apr 26, 2016
e56121c
Do not import variants from RenderedLineKind
nikomatsakis Apr 26, 2016
d58a4be
Nit: do not import variants from Style
nikomatsakis Apr 26, 2016
d5529f0
Nit: do not use RLK
nikomatsakis Apr 26, 2016
f6496cd
Nit: address various style nits
nikomatsakis Apr 26, 2016
94841be
Nit: in emitter.rs
nikomatsakis Apr 26, 2016
24f4b15
Nit: use last_mut better
nikomatsakis Apr 26, 2016
1fdbfcd
only emit `^` at the start of a multi-line error
nikomatsakis Apr 26, 2016
883b969
Nit: add comment
nikomatsakis Apr 27, 2016
5db4d62
Nit: remove push_primary_span, which was never called
nikomatsakis Apr 27, 2016
ba12ed0
fix tests better
nikomatsakis Apr 27, 2016
8a9ad72
Nit: use Range::contains
nikomatsakis Apr 27, 2016
790043b
fix snippet tests MORE!
nikomatsakis Apr 27, 2016
89d086b
change color of warning to YELLOW
nikomatsakis Apr 27, 2016
49dfac4
move "lint level defined here" into secondary note
nikomatsakis Apr 27, 2016
84cb56f
Add back in a 'old school' error format
Apr 28, 2016
79f61a4
Finish up with 'old school' error mode
Apr 29, 2016
5974e5b
Fix up error-pattern style test
Apr 29, 2016
2ba5fac
fix rebase flaws
nikomatsakis Apr 29, 2016
95576b8
update unit tests
nikomatsakis Apr 30, 2016
64e0819
patch travis failure
nikomatsakis Apr 30, 2016
f359aa2
Fix unicode test to use original error format
sophiajt Apr 30, 2016
9d151a7
do not fail if len(rendered_lines) is == 1
nikomatsakis May 2, 2016
db8a9a9
avoid double panic
nikomatsakis May 2, 2016
71e6329
rustc: Handle concurrent `create_dir` requests
alexcrichton May 2, 2016
9355a91
assert we get at least two rendered lines back
nikomatsakis May 2, 2016
40199f6
Rollup merge of #32756 - nikomatsakis:borrowck-snippet, r=nrc
Manishearth May 2, 2016
308f10c
Rollup merge of #33309 - birkenfeld:pp, r=nrc
Manishearth May 2, 2016
1d6cc19
Rollup merge of #33320 - birkenfeld:issue31573, r=arielb1
Manishearth May 2, 2016
c4d950d
Rollup merge of #33323 - birkenfeld:issue-31221, r=Manishearth
Manishearth May 2, 2016
68c29e0
Rollup merge of #33324 - birkenfeld:issue-30497, r=GuillaumeGomez
Manishearth May 2, 2016
0ee84c7
Rollup merge of #33325 - birkenfeld:issue-31341, r=jseyfried
Manishearth May 2, 2016
7e88dc7
Rollup merge of #33332 - alexcrichton:handle-more-races, r=michaelwoe…
Manishearth May 2, 2016
ac19fdc
Rollup merge of #33334 - birkenfeld:issue29088, r=Manishearth
Manishearth May 2, 2016
d6c6bbf
Rollup merge of #33335 - cramertj:master, r=alexcrichton
Manishearth May 2, 2016
638cf9f
Rollup merge of #33346 - Ryman:patch-4, r=alexcrichton
Manishearth May 2, 2016
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
7 changes: 2 additions & 5 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,8 @@ extern "rust-intrinsic" {

/// The size of a type in bytes.
///
/// This is the exact number of bytes in memory taken up by a
/// value of the given type. In other words, a memset of this size
/// would *exactly* overwrite a value. When laid out in vectors
/// and structures there may be additional padding between
/// elements.
/// More specifically, this is the offset in bytes between successive
/// items of the same type, including alignment padding.
pub fn size_of<T>() -> usize;

/// Moves a value to an uninitialized memory location.
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ pub fn forget<T>(t: T) {

/// Returns the size of a type in bytes.
///
/// More specifically, this is the offset in bytes between successive
/// items of the same type, including alignment padding.
///
/// # Examples
///
/// ```
Expand Down
14 changes: 12 additions & 2 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,17 @@ fn foo(x: u8) -> u8 {
```

It is advisable to find out what the unhandled cases are and check for them,
returning an appropriate value or panicking if necessary.
returning an appropriate value or panicking if necessary. Check if you need
to remove a semicolon from the last expression, like in this case:

```ignore
fn foo(x: u8) -> u8 {
inner(2*x + 1);
}
```

The semicolon discards the return value of `inner`, instead of returning
it from `foo`.
"##,

E0270: r##"
Expand Down Expand Up @@ -1569,5 +1579,5 @@ register_diagnostics! {
E0490, // a value of type `..` is borrowed for too long
E0491, // in type `..`, reference has a longer lifetime than the data it...
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
E0524, // expected a closure that implements `..` but this closure only implements `..`
E0525, // expected a closure that implements `..` but this closure only implements `..`
}
57 changes: 26 additions & 31 deletions src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ pub trait ErrorReporting<'tcx> {
terr: &TypeError<'tcx>)
-> DiagnosticBuilder<'tcx>;

fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String>;
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<(String, String)>;

fn expected_found_str<T: fmt::Display + Resolvable<'tcx> + TypeFoldable<'tcx>>(
&self,
exp_found: &ty::error::ExpectedFound<T>)
-> Option<String>;
-> Option<(String, String)>;

fn report_concrete_failure(&self,
origin: SubregionOrigin<'tcx>,
Expand Down Expand Up @@ -535,7 +535,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
trace: TypeTrace<'tcx>,
terr: &TypeError<'tcx>)
-> DiagnosticBuilder<'tcx> {
let expected_found_str = match self.values_str(&trace.values) {
let (expected, found) = match self.values_str(&trace.values) {
Some(v) => v,
None => {
return self.tcx.sess.diagnostic().struct_dummy(); /* derived error */
Expand All @@ -548,18 +548,17 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
false
};

let expected_found_str = if is_simple_error {
expected_found_str
} else {
format!("{} ({})", expected_found_str, terr)
};

let mut err = struct_span_err!(self.tcx.sess,
trace.origin.span(),
E0308,
"{}: {}",
trace.origin,
expected_found_str);
"{}",
trace.origin);

if !is_simple_error {
err = err.note_expected_found(&"type", &expected, &found);
}

err = err.span_label(trace.origin.span(), &terr);

self.check_and_note_conflicting_crates(&mut err, terr, trace.origin.span());

Expand All @@ -574,6 +573,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
},
_ => ()
}

err
}

Expand Down Expand Up @@ -631,7 +631,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {

/// Returns a string of the form "expected `{}`, found `{}`", or None if this is a derived
/// error.
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<String> {
fn values_str(&self, values: &ValuePairs<'tcx>) -> Option<(String, String)> {
match *values {
infer::Types(ref exp_found) => self.expected_found_str(exp_found),
infer::TraitRefs(ref exp_found) => self.expected_found_str(exp_found),
Expand All @@ -642,7 +642,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
fn expected_found_str<T: fmt::Display + Resolvable<'tcx> + TypeFoldable<'tcx>>(
&self,
exp_found: &ty::error::ExpectedFound<T>)
-> Option<String>
-> Option<(String, String)>
{
let expected = exp_found.expected.resolve(self);
if expected.references_error() {
Expand All @@ -654,9 +654,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
return None;
}

Some(format!("expected `{}`, found `{}`",
expected,
found))
Some((format!("{}", expected), format!("{}", found)))
}

fn report_generic_bound_failure(&self,
Expand Down Expand Up @@ -684,10 +682,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
E0309,
"{} may not live long enough",
labeled_user_string);
err.fileline_help(origin.span(),
&format!("consider adding an explicit lifetime bound `{}: {}`...",
bound_kind,
sub));
err.help(&format!("consider adding an explicit lifetime bound `{}: {}`...",
bound_kind,
sub));
err
}

Expand All @@ -698,10 +695,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
E0310,
"{} may not live long enough",
labeled_user_string);
err.fileline_help(origin.span(),
&format!("consider adding an explicit lifetime \
bound `{}: 'static`...",
bound_kind));
err.help(&format!("consider adding an explicit lifetime \
bound `{}: 'static`...",
bound_kind));
err
}

Expand All @@ -712,9 +708,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
E0311,
"{} may not live long enough",
labeled_user_string);
err.fileline_help(origin.span(),
&format!("consider adding an explicit lifetime bound for `{}`",
bound_kind));
err.help(&format!("consider adding an explicit lifetime bound for `{}`",
bound_kind));
self.tcx.note_and_explain_region(
&mut err,
&format!("{} must be valid for ", labeled_user_string),
Expand Down Expand Up @@ -1751,11 +1746,11 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
};

match self.values_str(&trace.values) {
Some(values_str) => {
Some((expected, found)) => {
err.span_note(
trace.origin.span(),
&format!("...so that {} ({})",
desc, values_str));
&format!("...so that {} (expected {}, found {})",
desc, expected, found));
}
None => {
// Really should avoid printing this error at
Expand Down
14 changes: 5 additions & 9 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,17 +456,13 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
it will become a hard error in a future release!");
let citation = format!("for more information, see {}",
future_incompatible.reference);
if let Some(sp) = span {
err.fileline_warn(sp, &explanation);
err.fileline_note(sp, &citation);
} else {
err.warn(&explanation);
err.note(&citation);
}
err.warn(&explanation);
err.note(&citation);
}

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

err
Expand Down Expand Up @@ -542,7 +538,7 @@ pub trait LintContext: Sized {
let mut err = self.lookup(lint, Some(span), msg);
if self.current_level(lint) != Level::Allow {
if note_span == span {
err.fileline_note(note_span, note);
err.note(note);
} else {
err.span_note(note_span, note);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
}
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
};
emitter.emit(None, msg, None, errors::Level::Fatal);
emitter.emit(&MultiSpan::new(), msg, None, errors::Level::Fatal);
panic!(errors::FatalError);
}

Expand All @@ -578,7 +578,7 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
}
config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()),
};
emitter.emit(None, msg, None, errors::Level::Warning);
emitter.emit(&MultiSpan::new(), msg, None, errors::Level::Warning);
}

// Err(0) means compilation was stopped, but no errors were found.
Expand Down
Loading