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 #62635

Merged
merged 35 commits into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
145385e
Add messages to Option and Result must_use for is_*
czipperz Jul 6, 2019
9b0623d
Wrap line
czipperz Jul 6, 2019
e12d682
path-type examples for single-use lifetime in fn argument UI test
zackmdavis Jul 6, 2019
acc4e56
in which we suggest anonymizing single-use lifetimes in paths
zackmdavis Jul 6, 2019
1948140
Added a test for coherence when a generic type param has a default va…
ohadravid Jun 4, 2019
37942c4
Add test for #49919
JohnTitor Jul 11, 2019
baa9efb
rustc_mir: follow FalseUnwind's real_target edge in qualify_consts.
eddyb Jul 1, 2019
ab3adf3
Replace unsafe_destructor_blind_to_params with may_dangle
tesuji Jul 10, 2019
d4fcbb4
document that crate refers to the project root
ngoldbaum Jul 11, 2019
8347917
Remove feature gate `dropck_parametricity` completely
tesuji Jul 11, 2019
6082497
move mem::uninitialized deprecation back by 1 release, to 1.39
RalfJung Jul 11, 2019
c9f7a3d
Emit dropped unemitted errors to aid in ICE debugging
estebank Jul 11, 2019
cc481a4
Correctly break out of recovery loop
estebank Jul 12, 2019
1574c2d
align async-await.rs and await-macro.rs with one another
delan Jul 12, 2019
0f66ce6
test E0133 when calling free/impl `async unsafe fn` in safe code
delan Jul 12, 2019
beb2435
test `unsafe fn` and `async unsafe fn` calls in `async` in `unsafe`
delan Jul 12, 2019
e65c1c4
remove unused #![feature(async_closure)]
delan Jul 12, 2019
60f480d
test E0133 when calling free/impl `async unsafe fn` in `async fn`
delan Jul 12, 2019
d023e47
remove redundant async_closure test in async-await.rs
delan Jul 12, 2019
5f8d0a1
test `unsafe fn` and `async unsafe fn` calls in `unsafe { async || }`
delan Jul 12, 2019
00e0d87
Turn `indirect_structural_match` lint on explicitly in ui tests.
pnkfelix Jul 12, 2019
44d27ba
Change `indirect_structural_match` lint to allow-by-default.
pnkfelix Jul 12, 2019
8c5f690
add test case
estebank Jul 12, 2019
74ac956
Rollup merge of #61535 - ohadravid:test-generic-with-default-assiocia…
Centril Jul 12, 2019
9ffeb26
Rollup merge of #62274 - eddyb:const-false-unwind, r=pnkfelix
Centril Jul 12, 2019
f169b15
Rollup merge of #62431 - czipperz:add-messages-to-must-use-is_-method…
Centril Jul 12, 2019
e706438
Rollup merge of #62453 - zackmdavis:single_path, r=estebank
Centril Jul 12, 2019
d70ea7c
Rollup merge of #62568 - lzutao:replace_may_dangle, r=matthewjasper
Centril Jul 12, 2019
992bcd0
Rollup merge of #62578 - JohnTitor:add-test-for-49919, r=alexcrichton
Centril Jul 12, 2019
a4252fe
Rollup merge of #62595 - ngoldbaum:path-clarity-doc, r=Centril
Centril Jul 12, 2019
d69e958
Rollup merge of #62599 - RalfJung:uninit, r=cramertj
Centril Jul 12, 2019
d709e8d
Rollup merge of #62605 - estebank:emit-dropped-err, r=pnkfelix
Centril Jul 12, 2019
a7f1649
Rollup merge of #62607 - estebank:this-mem-is-out-of-control, r=petro…
Centril Jul 12, 2019
b1d6163
Rollup merge of #62608 - delan:async-unsafe-fn-tests, r=Centril
Centril Jul 12, 2019
fe4e32a
Rollup merge of #62623 - pnkfelix:issue-62614-downgrade-indirect-stru…
Centril Jul 12, 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
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Misc
Compatibility Notes
-------------------
- With the stabilisation of `mem::MaybeUninit`, `mem::uninitialized` use is no
longer recommended, and will be deprecated in 1.38.0.
longer recommended, and will be deprecated in 1.39.0.

[60318]: https://github.com/rust-lang/rust/pull/60318/
[60364]: https://github.com/rust-lang/rust/pull/60364/
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pub unsafe fn zeroed<T>() -> T {
/// [`MaybeUninit<T>`]: union.MaybeUninit.html
/// [inv]: union.MaybeUninit.html#initialization-invariant
#[inline]
#[rustc_deprecated(since = "1.38.0", reason = "use `mem::MaybeUninit` instead")]
#[rustc_deprecated(since = "1.39.0", reason = "use `mem::MaybeUninit` instead")]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn uninitialized<T>() -> T {
MaybeUninit::uninit().assume_init()
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<T> Option<T> {
/// ```
///
/// [`Some`]: #variant.Some
#[must_use]
#[must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_some(&self) -> bool {
Expand All @@ -201,7 +201,8 @@ impl<T> Option<T> {
/// ```
///
/// [`None`]: #variant.None
#[must_use]
#[must_use = "if you intended to assert that this doesn't have a value, consider \
`.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_none(&self) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl<T, E> Result<T, E> {
/// let x: Result<i32, &str> = Err("Some error message");
/// assert_eq!(x.is_ok(), false);
/// ```
#[must_use]
#[must_use = "if you intended to assert that this is ok, consider `.unwrap()` instead"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_ok(&self) -> bool {
Expand All @@ -302,7 +302,7 @@ impl<T, E> Result<T, E> {
/// let x: Result<i32, &str> = Err("Some error message");
/// assert_eq!(x.is_err(), true);
/// ```
#[must_use]
#[must_use = "if you intended to assert that this is err, consider `.unwrap_err()` instead"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_err(&self) -> bool {
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ declare_lint! {

declare_lint! {
pub INDIRECT_STRUCTURAL_MATCH,
Warn,
// defaulting to allow until rust-lang/rust#62614 is fixed.
Allow,
"pattern with const indirectly referencing non-`#[structural_match]` type"
}

Expand Down Expand Up @@ -451,6 +452,7 @@ declare_lint_pass! {
AMBIGUOUS_ASSOCIATED_ITEMS,
NESTED_IMPL_TRAIT,
MUTABLE_BORROW_RESERVATION_CONFLICT,
INDIRECT_STRUCTURAL_MATCH,
]
}

Expand Down
81 changes: 56 additions & 25 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::hir::def::{Res, DefKind};
use crate::hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
use crate::hir::map::Map;
use crate::hir::ptr::P;
use crate::hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, Node, ParamName};
use crate::hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, Node, ParamName, QPath};
use crate::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt};

use crate::rustc::lint;
Expand Down Expand Up @@ -1458,10 +1458,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}

// helper method to issue suggestions from `fn rah<'a>(&'a T)` to `fn rah(&T)`
// or from `fn rah<'a>(T<'a>)` to `fn rah(T<'_>)`
fn suggest_eliding_single_use_lifetime(
&self, err: &mut DiagnosticBuilder<'_>, def_id: DefId, lifetime: &hir::Lifetime
) {
// FIXME: future work: also suggest `impl Foo<'_>` for `impl<'a> Foo<'a>`
let name = lifetime.name.ident();
let mut remove_decl = None;
if let Some(parent_def_id) = self.tcx.parent(def_id) {
Expand All @@ -1471,18 +1471,38 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}

let mut remove_use = None;
let mut elide_use = None;
let mut find_arg_use_span = |inputs: &hir::HirVec<hir::Ty>| {
for input in inputs {
if let hir::TyKind::Rptr(lt, _) = input.node {
if lt.name.ident() == name {
// include the trailing whitespace between the ampersand and the type name
let lt_through_ty_span = lifetime.span.to(input.span.shrink_to_hi());
remove_use = Some(
self.tcx.sess.source_map()
.span_until_non_whitespace(lt_through_ty_span)
);
break;
match input.node {
hir::TyKind::Rptr(lt, _) => {
if lt.name.ident() == name {
// include the trailing whitespace between the lifetime and type names
let lt_through_ty_span = lifetime.span.to(input.span.shrink_to_hi());
remove_use = Some(
self.tcx.sess.source_map()
.span_until_non_whitespace(lt_through_ty_span)
);
break;
}
}
hir::TyKind::Path(ref qpath) => {
if let QPath::Resolved(_, path) = qpath {

let last_segment = &path.segments[path.segments.len()-1];
let generics = last_segment.generic_args();
for arg in generics.args.iter() {
if let GenericArg::Lifetime(lt) = arg {
if lt.name.ident() == name {
elide_use = Some(lt.span);
break;
}
}
}
break;
}
},
_ => {}
}
}
};
Expand All @@ -1506,24 +1526,35 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
}

if let (Some(decl_span), Some(use_span)) = (remove_decl, remove_use) {
// if both declaration and use deletion spans start at the same
// place ("start at" because the latter includes trailing
// whitespace), then this is an in-band lifetime
if decl_span.shrink_to_lo() == use_span.shrink_to_lo() {
err.span_suggestion(
use_span,
"elide the single-use lifetime",
String::new(),
Applicability::MachineApplicable,
);
} else {
let msg = "elide the single-use lifetime";
match (remove_decl, remove_use, elide_use) {
(Some(decl_span), Some(use_span), None) => {
// if both declaration and use deletion spans start at the same
// place ("start at" because the latter includes trailing
// whitespace), then this is an in-band lifetime
if decl_span.shrink_to_lo() == use_span.shrink_to_lo() {
err.span_suggestion(
use_span,
msg,
String::new(),
Applicability::MachineApplicable,
);
} else {
err.multipart_suggestion(
msg,
vec![(decl_span, String::new()), (use_span, String::new())],
Applicability::MachineApplicable,
);
}
}
(Some(decl_span), None, Some(use_span)) => {
err.multipart_suggestion(
"elide the single-use lifetime",
vec![(decl_span, String::new()), (use_span, String::new())],
msg,
vec![(decl_span, String::new()), (use_span, "'_".to_owned())],
Applicability::MachineApplicable,
);
}
_ => {}
}
}

Expand Down
15 changes: 0 additions & 15 deletions src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use rustc_macros::HashStable;
use std::{cmp, fmt};
use syntax::ast;
use syntax::attr::{self, SignedInt, UnsignedInt};
use syntax::symbol::sym;
use syntax_pos::{Span, DUMMY_SP};

#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -435,20 +434,6 @@ impl<'tcx> TyCtxt<'tcx> {
Some(dtor) => dtor.did
};

// RFC 1238: if the destructor method is tagged with the
// attribute `unsafe_destructor_blind_to_params`, then the
// compiler is being instructed to *assume* that the
// destructor will not access borrowed data,
// even if such data is otherwise reachable.
//
// Such access can be in plain sight (e.g., dereferencing
// `*foo.0` of `Foo<'a>(&'a u32)`) or indirectly hidden
// (e.g., calling `foo.0.clone()` of `Foo<T:Clone>`).
if self.has_attr(dtor, sym::unsafe_destructor_blind_to_params) {
debug!("destructor_constraint({:?}) - blind", def.did);
return vec![];
}

let impl_def_id = self.associated_item(dtor).container.id();
let impl_generics = self.generics_of(impl_def_id);

Expand Down
9 changes: 6 additions & 3 deletions src/librustc_errors/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,13 @@ impl<'a> Debug for DiagnosticBuilder<'a> {
impl<'a> Drop for DiagnosticBuilder<'a> {
fn drop(&mut self) {
if !panicking() && !self.cancelled() {
let mut db = DiagnosticBuilder::new(self.handler,
Level::Bug,
"Error constructed but not emitted");
let mut db = DiagnosticBuilder::new(
self.handler,
Level::Bug,
"the following error was constructed but not emitted",
);
db.emit();
self.emit();
panic!();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {

let target = match body[bb].terminator().kind {
TerminatorKind::Goto { target } |
TerminatorKind::FalseUnwind { real_target: target, .. } |
TerminatorKind::Drop { target, .. } |
TerminatorKind::DropAndReplace { target, .. } |
TerminatorKind::Assert { target, .. } |
Expand All @@ -908,8 +909,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
TerminatorKind::GeneratorDrop |
TerminatorKind::Yield { .. } |
TerminatorKind::Unreachable |
TerminatorKind::FalseEdges { .. } |
TerminatorKind::FalseUnwind { .. } => None,
TerminatorKind::FalseEdges { .. } => None,

TerminatorKind::Return => {
break;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
///
/// * (1.) `D` has a lifetime- or type-parametric Drop implementation,
/// (where that `Drop` implementation does not opt-out of
/// this check via the `unsafe_destructor_blind_to_params`
/// this check via the `may_dangle`
/// attribute), and
/// * (2.) the structure of `D` can reach a reference of type `&'a _`,
///
Expand Down Expand Up @@ -279,7 +279,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
/// instead Drop-Check now simply assumes that if a destructor has
/// access (direct or indirect) to a lifetime parameter, then that
/// lifetime must be forced to outlive that destructor's dynamic
/// extent. We then provide the `unsafe_destructor_blind_to_params`
/// extent. We then provide the `may_dangle`
/// attribute as a way for destructor implementations to opt-out of
/// this conservative assumption (and thus assume the obligation of
/// ensuring that they do not access data nor invoke methods of
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3809,7 +3809,6 @@ const ATTRIBUTE_WHITELIST: &'static [Symbol] = &[
sym::must_use,
sym::no_mangle,
sym::repr,
sym::unsafe_destructor_blind_to_params,
sym::non_exhaustive
];

Expand Down
6 changes: 5 additions & 1 deletion src/libstd/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod continue_keyword { }
/// The `as` keyword can be used to change what the crate is referred to as in your project. If a
/// crate name includes a dash, it is implicitly imported with the dashes replaced by underscores.
///
/// `crate` is also used as in conjunction with `pub` to signify that the item it's attached to
/// `crate` can also be used as in conjunction with `pub` to signify that the item it's attached to
/// is public only to other members of the same crate it's in.
///
/// ```rust
Expand All @@ -131,6 +131,10 @@ mod continue_keyword { }
/// }
/// ```
///
/// `crate` is also used to represent the absolute path of a module, where `crate` refers to the
/// root of the current crate. For instance, `crate::foo::bar` refers to the name `bar` inside the
/// module `foo`, from anywhere else in the same crate.
///
/// [Reference]: ../reference/items/extern-crates.html
mod crate_keyword { }

Expand Down
14 changes: 2 additions & 12 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ declare_features! (

// no-tracking-issue-end

// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
(active, dropck_parametricity, "1.3.0", Some(28498), None),

// no-tracking-issue-start

// Allows using `#[omit_gdb_pretty_printer_section]`.
Expand Down Expand Up @@ -641,6 +638,8 @@ declare_features! (
(removed, extern_in_paths, "1.33.0", Some(55600), None,
Some("subsumed by `::foo::bar` paths")),
(removed, quote, "1.33.0", Some(29601), None, None),
// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
(removed, dropck_parametricity, "1.38.0", Some(28498), None, None),

// -------------------------------------------------------------------------
// feature-group-end: removed features
Expand Down Expand Up @@ -1447,15 +1446,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
cfg_fn!(omit_gdb_pretty_printer_section)
)
),
(sym::unsafe_destructor_blind_to_params,
Normal,
template!(Word),
Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/34761",
Some("replace this attribute with `#[may_dangle]`")),
sym::dropck_parametricity,
"unsafe_destructor_blind_to_params has been replaced by \
may_dangle and will be removed in the future",
cfg_fn!(dropck_parametricity))),
(sym::may_dangle,
Normal,
template!(Word),
Expand Down
18 changes: 10 additions & 8 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4629,6 +4629,9 @@ impl<'a> Parser<'a> {
fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P<Block>> {
let mut stmts = vec![];
while !self.eat(&token::CloseDelim(token::Brace)) {
if self.token == token::Eof {
break;
}
let stmt = match self.parse_full_stmt(false) {
Err(mut err) => {
err.emit();
Expand All @@ -4643,8 +4646,6 @@ impl<'a> Parser<'a> {
};
if let Some(stmt) = stmt {
stmts.push(stmt);
} else if self.token == token::Eof {
break;
} else {
// Found only `;` or `}`.
continue;
Expand Down Expand Up @@ -6666,12 +6667,13 @@ impl<'a> Parser<'a> {
}

/// Reads a module from a source file.
fn eval_src_mod(&mut self,
path: PathBuf,
directory_ownership: DirectoryOwnership,
name: String,
id_sp: Span)
-> PResult<'a, (ast::Mod, Vec<Attribute> )> {
fn eval_src_mod(
&mut self,
path: PathBuf,
directory_ownership: DirectoryOwnership,
name: String,
id_sp: Span,
) -> PResult<'a, (ast::Mod, Vec<Attribute>)> {
let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
if let Some(i) = included_mod_stack.iter().position(|p| *p == path) {
let mut err = String::from("circular modules: ");
Expand Down
Loading