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 8 pull requests #58445

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9e934e2
Reweork incompatible match arms error
estebank Feb 7, 2019
7eb6a2a
Add test for type mismatch on first match arm
estebank Feb 8, 2019
802c897
review comments: (marginally) reduce memory consumtion
estebank Feb 8, 2019
05b4e7c
Add way to hide suggestion snippet window from cli output
estebank Feb 8, 2019
6ea159e
Expose hidden snippet suggestions
estebank Feb 8, 2019
7cfba1c
Never inline HideCodeAlways suggestions
estebank Feb 8, 2019
235523c
Add way to completely hide suggestion from cli output
estebank Feb 9, 2019
87dd2e1
Use hidden suggestions for unused imports lint
estebank Feb 11, 2019
86f2d22
Introduce rustc_interface and move some methods there
Zoxc Dec 8, 2018
db17b31
Address comments
Zoxc Feb 7, 2019
e73f96a
make OpTy.op private, and ImmTy.imm public instead
RalfJung Feb 8, 2019
b376ae6
make bin_op and unary_op APIs consistently work on ImmTy
RalfJung Feb 8, 2019
1a5304a
fix whitespace
RalfJung Feb 8, 2019
22d5e6a
fix rebase fallout
RalfJung Feb 13, 2019
e7f8e63
Convert old doc links to current edition
tesuji Jan 23, 2019
285d4a7
suggestion-diagnostics: as_ref improve snippet
dlrobertson Feb 13, 2019
168c14a
Avoid propagating redundant outlives constraints from closures
matthewjasper Feb 10, 2019
ea613f3
Buffer and migrate nice region errors
matthewjasper Feb 6, 2019
79e8c31
Propagate region constraints more precisely from closures
matthewjasper Feb 6, 2019
5d65e8c
Reduce the size of `hir::Expr`.
nnethercote Feb 7, 2019
b1c59bc
Rollup merge of #57451 - dlrobertson:can_use_as_ref_nit, r=estebank
Centril Feb 14, 2019
51ebe8c
Rollup merge of #57856 - lzutao:fix-old-first-edition, r=steveklabnik
Centril Feb 14, 2019
f9e56ad
Rollup merge of #58250 - Zoxc:rustc-interface-1, r=oli-obk
Centril Feb 14, 2019
f7b35be
Rollup merge of #58258 - nnethercote:shrink-hir-Expr, r=michaelwoerister
Centril Feb 14, 2019
63be94a
Rollup merge of #58267 - estebank:match-arms, r=matthewjasper
Centril Feb 14, 2019
8bfd709
Rollup merge of #58296 - estebank:hidden-suggestion, r=oli-obk
Centril Feb 14, 2019
44060a0
Rollup merge of #58301 - RalfJung:fat-ptr-eq, r=oli-obk
Centril Feb 14, 2019
13fd658
Rollup merge of #58347 - matthewjasper:closure-bounds-fixes, r=pnkfelix
Centril Feb 14, 2019
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
31 changes: 31 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2716,6 +2716,7 @@ dependencies = [
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_incremental 0.0.0",
"rustc_interface 0.0.0",
"rustc_lint 0.0.0",
"rustc_metadata 0.0.0",
"rustc_mir 0.0.0",
Expand Down Expand Up @@ -2768,6 +2769,36 @@ dependencies = [
"syntax_pos 0.0.0",
]

[[package]]
name = "rustc_interface"
version = "0.0.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_allocator 0.0.0",
"rustc_borrowck 0.0.0",
"rustc_codegen_utils 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_incremental 0.0.0",
"rustc_lint 0.0.0",
"rustc_metadata 0.0.0",
"rustc_mir 0.0.0",
"rustc_passes 0.0.0",
"rustc_plugin 0.0.0",
"rustc_privacy 0.0.0",
"rustc_resolve 0.0.0",
"rustc_traits 0.0.0",
"rustc_typeck 0.0.0",
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serialize 0.0.0",
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
"syntax 0.0.0",
"syntax_ext 0.0.0",
"syntax_pos 0.0.0",
]

[[package]]
name = "rustc_lint"
version = "0.0.0"
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ fn main() {
// actually downloaded, so we just always pass the `--sysroot` option.
cmd.arg("--sysroot").arg(&sysroot);

cmd.arg("-Zexternal-macro-backtrace");

// When we build Rust dylibs they're all intended for intermediate
// usage, so make sure we pass the -Cprefer-dynamic flag instead of
// linking all deps statically into the dylib.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/guide-error-handling.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Error Handling in Rust

This content has moved into
[the Rust Programming Language book](book/error-handling.html).
[the Rust Programming Language book](book/ch09-00-error-handling.html).
2 changes: 1 addition & 1 deletion src/doc/guide-ownership.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% The (old) Rust Ownership Guide

This content has moved into
[the Rust Programming Language book](book/ownership.html).
[the Rust Programming Language book](book/ch04-00-understanding-ownership.html).
2 changes: 1 addition & 1 deletion src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

This content has been removed, with no direct replacement. Rust only
has two built-in pointer types now,
[references](book/references-and-borrowing.html) and [raw
[references](book/ch04-02-references-and-borrowing.html) and [raw
pointers](book/raw-pointers.html). Older Rusts had many more pointer
types, they’re gone now.
2 changes: 1 addition & 1 deletion src/doc/guide-testing.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% The (old) Rust Testing Guide

This content has moved into
[the Rust Programming Language book](book/testing.html).
[the Rust Programming Language book](book/ch11-00-testing.html).
5 changes: 1 addition & 4 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ pub const fn identity<T>(x: T) -> T { x }
/// - Use `Borrow` when the goal is related to writing code that is agnostic to
/// the type of borrow and whether it is a reference or value
///
/// See [the book][book] for a more detailed comparison.
///
/// [book]: ../../book/first-edition/borrow-and-asref.html
/// [`Borrow`]: ../../std/borrow/trait.Borrow.html
///
/// **Note: this trait must not fail**. If the conversion can fail, use a
Expand Down Expand Up @@ -351,7 +348,7 @@ pub trait Into<T>: Sized {
/// [`String`]: ../../std/string/struct.String.html
/// [`Into<U>`]: trait.Into.html
/// [`from`]: trait.From.html#tymethod.from
/// [book]: ../../book/first-edition/error-handling.html
/// [book]: ../../book/ch09-00-error-handling.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait From<T>: Sized {
/// Performs the conversion.
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<T: ?Sized> !Send for *mut T { }
/// // be made into an object
/// ```
///
/// [trait object]: ../../book/first-edition/trait-objects.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
#[stable(feature = "rust1", since = "1.0.0")]
#[lang = "sized"]
#[rustc_on_unimplemented(
Expand Down Expand Up @@ -518,7 +518,7 @@ macro_rules! impls{
/// types. We track the Rust type using a phantom type parameter on
/// the struct `ExternalResource` which wraps a handle.
///
/// [FFI]: ../../book/first-edition/ffi.html
/// [FFI]: ../../book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code
///
/// ```
/// # #![allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pub const fn size_of<T>() -> usize {
/// then `size_of_val` can be used to get the dynamically-known size.
///
/// [slice]: ../../std/primitive.slice.html
/// [trait object]: ../../book/first-edition/trait-objects.html
/// [trait object]: ../../book/ch17-02-trait-objects.html
///
/// # Examples
///
Expand Down
4 changes: 3 additions & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
//! function-like macros `#[proc_macro]`, macro attributes `#[proc_macro_attribute]` and
//! custom derive attributes`#[proc_macro_derive]`.
//!
//! See [the book](../book/first-edition/procedural-macros.html) for more.
//! See [the book] for more.
//!
//! [the book]: ../book/ch19-06-macros.html#procedural-macros-for-generating-code-from-attributes

#![stable(feature = "proc_macro_lib", since = "1.15.0")]
#![deny(missing_docs)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ define_dep_nodes!( <'tcx>
[eval_always] CoherenceInherentImplOverlapCheck,
[] CoherenceCheckTrait(DefId),
[eval_always] PrivacyAccessLevels(CrateNum),
[eval_always] Analysis(CrateNum),

// Represents the MIR for a fn; also used as the task node for
// things read/modify that MIR.
Expand Down
9 changes: 6 additions & 3 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-tidy-linelength
#![allow(non_snake_case)]

// Error messages for EXXXX errors.
Expand Down Expand Up @@ -410,7 +411,7 @@ fn baz<'a>(x: &'a str, y: &str) -> &str { }
Lifetime elision in implementation headers was part of the lifetime elision
RFC. It is, however, [currently unimplemented][iss15872].

[book-le]: https://doc.rust-lang.org/nightly/book/first-edition/lifetimes.html#lifetime-elision
[book-le]: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html#lifetime-elision
[iss15872]: https://github.com/rust-lang/rust/issues/15872
"##,

Expand Down Expand Up @@ -646,7 +647,9 @@ attributes:
#![no_std]
```

See also https://doc.rust-lang.org/book/first-edition/no-stdlib.html
See also the [unstable book][1].

[1]: https://doc.rust-lang.org/unstable-book/language-features/lang-items.html#writing-an-executable-without-stdlib
"##,

E0214: r##"
Expand Down Expand Up @@ -1713,7 +1716,7 @@ fn main() {
```

To understand better how closures work in Rust, read:
https://doc.rust-lang.org/book/first-edition/closures.html
https://doc.rust-lang.org/book/ch13-01-closures.html
"##,

E0580: r##"
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3859,15 +3859,15 @@ impl<'a> LoweringContext<'a> {
hir::ExprKind::Call(f, args.iter().map(|x| self.lower_expr(x)).collect())
}
ExprKind::MethodCall(ref seg, ref args) => {
let hir_seg = self.lower_path_segment(
let hir_seg = P(self.lower_path_segment(
e.span,
seg,
ParamMode::Optional,
0,
ParenthesizedGenericArgs::Err,
ImplTraitContext::disallowed(),
None,
);
));
let args = args.iter().map(|x| self.lower_expr(x)).collect();
hir::ExprKind::MethodCall(hir_seg, seg.ident.span, args)
}
Expand Down Expand Up @@ -4148,7 +4148,7 @@ impl<'a> LoweringContext<'a> {
node: if is_unit {
hir::ExprKind::Path(struct_path)
} else {
hir::ExprKind::Struct(struct_path, fields, None)
hir::ExprKind::Struct(P(struct_path), fields, None)
},
span: e.span,
attrs: e.attrs.clone(),
Expand Down Expand Up @@ -4220,13 +4220,13 @@ impl<'a> LoweringContext<'a> {
hir::ExprKind::InlineAsm(P(hir_asm), outputs, inputs)
}
ExprKind::Struct(ref path, ref fields, ref maybe_expr) => hir::ExprKind::Struct(
self.lower_qpath(
P(self.lower_qpath(
e.id,
&None,
path,
ParamMode::Optional,
ImplTraitContext::disallowed(),
),
)),
fields.iter().map(|x| self.lower_field(x)).collect(),
maybe_expr.as_ref().map(|x| P(self.lower_expr(x))),
),
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,10 @@ pub struct Expr {
pub hir_id: HirId,
}

// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert!(MEM_SIZE_OF_EXPR: std::mem::size_of::<Expr>() == 72);

impl Expr {
pub fn precedence(&self) -> ExprPrecedence {
match self.node {
Expand Down Expand Up @@ -1438,7 +1442,7 @@ pub enum ExprKind {
/// and the remaining elements are the rest of the arguments.
/// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
/// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d])`.
MethodCall(PathSegment, Span, HirVec<Expr>),
MethodCall(P<PathSegment>, Span, HirVec<Expr>),
/// A tuple (e.g., `(a, b, c ,d)`).
Tup(HirVec<Expr>),
/// A binary operation (e.g., `a + b`, `a * b`).
Expand Down Expand Up @@ -1506,7 +1510,7 @@ pub enum ExprKind {
///
/// For example, `Foo {x: 1, y: 2}`, or
/// `Foo {x: 1, .. base}`, where `base` is the `Option<Expr>`.
Struct(QPath, HirVec<Field>, Option<P<Expr>>),
Struct(P<QPath>, HirVec<Field>, Option<P<Expr>>),

/// An array literal constructed from one repeated element.
///
Expand Down
33 changes: 21 additions & 12 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,22 +508,31 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}
}
}
ObligationCauseCode::MatchExpressionArm { arm_span, source } => match source {
ObligationCauseCode::MatchExpressionArm {
source,
ref prior_arms,
last_ty,
..
} => match source {
hir::MatchSource::IfLetDesugar { .. } => {
let msg = "`if let` arm with an incompatible type";
if self.tcx.sess.source_map().is_multiline(arm_span) {
err.span_note(arm_span, msg);
} else {
err.span_label(arm_span, msg);
}
let msg = "`if let` arms have incompatible types";
err.span_label(cause.span, msg);
}
hir::MatchSource::TryDesugar => {}
_ => {
let msg = "match arm with an incompatible type";
if self.tcx.sess.source_map().is_multiline(arm_span) {
err.span_note(arm_span, msg);
} else {
err.span_label(arm_span, msg);
let msg = "`match` arms have incompatible types";
err.span_label(cause.span, msg);
if prior_arms.len() <= 4 {
for sp in prior_arms {
err.span_label(*sp, format!(
"this is found to be of type `{}`",
last_ty,
));
}
} else if let Some(sp) = prior_arms.last() {
err.span_label(*sp, format!(
"this and all prior arms are found to be of type `{}`", last_ty,
));
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions src/librustc/infer/error_reporting/nice_region_error/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::infer::InferCtxt;
use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::lexical_region_resolve::RegionResolutionError::*;
use syntax::source_map::Span;
use crate::ty::{self, TyCtxt};
use crate::util::common::ErrorReported;
use errors::DiagnosticBuilder;
use syntax::source_map::Span;

mod different_lifetimes;
mod find_anon_type;
Expand Down Expand Up @@ -59,7 +60,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> {
self.infcx.tcx
}

pub fn try_report_from_nll(&self) -> Option<ErrorReported> {
pub fn try_report_from_nll(&self) -> Option<DiagnosticBuilder<'cx>> {
// Due to the improved diagnostics returned by the MIR borrow checker, only a subset of
// the nice region errors are required when running under the MIR borrow checker.
self.try_report_named_anon_conflict()
Expand All @@ -68,6 +69,7 @@ impl<'cx, 'gcx, 'tcx> NiceRegionError<'cx, 'gcx, 'tcx> {

pub fn try_report(&self) -> Option<ErrorReported> {
self.try_report_from_nll()
.map(|mut diag| { diag.emit(); ErrorReported })
.or_else(|| self.try_report_anon_anon_conflict())
.or_else(|| self.try_report_outlives_closure())
.or_else(|| self.try_report_static_impl_trait())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
//! where one region is named and the other is anonymous.
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::ty;
use crate::util::common::ErrorReported;
use errors::Applicability;
use errors::{Applicability, DiagnosticBuilder};

impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
/// When given a `ConcreteFailure` for a function with arguments containing a named region and
/// an anonymous region, emit an descriptive diagnostic error.
pub(super) fn try_report_named_anon_conflict(&self) -> Option<ErrorReported> {
pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'a>> {
let (span, sub, sup) = self.get_regions();

debug!(
Expand Down Expand Up @@ -96,21 +95,23 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
("parameter type".to_owned(), "type".to_owned())
};

struct_span_err!(
let mut diag = struct_span_err!(
self.tcx().sess,
span,
E0621,
"explicit lifetime required in {}",
error_var
).span_suggestion(
new_ty_span,
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
new_ty.to_string(),
Applicability::Unspecified,
)
.span_label(span, format!("lifetime `{}` required", named))
.emit();
return Some(ErrorReported);
);

diag.span_suggestion(
new_ty_span,
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
new_ty.to_string(),
Applicability::Unspecified,
)
.span_label(span, format!("lifetime `{}` required", named));

Some(diag)
}

// This method returns whether the given Region is Named
Expand Down
Loading