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

Merged
merged 35 commits into from
Jul 7, 2020
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
7d7221c
typeck: adding type information to projection
Azhng Jun 24, 2020
8dc1e42
libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]
ryr3 Jul 2, 2020
ec31b4e
Audit uses of `span_suggestion_short`
JohnTitor Jul 2, 2020
84282fd
Audit uses of `tool_only_span_suggestion`
JohnTitor Jul 2, 2020
d5141e6
No need to call getPageId a second time
GuillaumeGomez Mar 30, 2020
0fcb7da
Improve page hash handling
GuillaumeGomez Mar 30, 2020
fc61cca
Expand sub code blocks block content when hidden when the page hash r…
GuillaumeGomez Mar 30, 2020
cdabdfa
Simplify DOM by removing IDs for code tags
GuillaumeGomez Jun 27, 2020
2453946
Update rustdoc tests
GuillaumeGomez Jun 27, 2020
af29620
Fix links
GuillaumeGomez Jun 27, 2020
e955beb
Remove render-redirect-pages option in rustdoc
GuillaumeGomez Jul 2, 2020
1b747a0
mir: mark mir construction temporaries as internal
davidtwco Jul 2, 2020
7391bf8
Move A|Rc::as_ptr from feature(weak_into_raw)
CAD97 Jul 2, 2020
ee8dd4e
Fix const prop ICE
oli-obk Jul 4, 2020
2f31426
rustdoc: Restore underline text decoration on hover for FQN in header
rye Jul 5, 2020
5fa19ad
Remove unused RUSTC_DEBUG_ASSERTIONS
tmiasko Jul 6, 2020
6196eaa
Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.
sunfishcode Jul 3, 2020
e46c187
Always resolve type@primitive as a primitive, not a module
jyn514 Jul 6, 2020
fdd39a3
Add rust-analyzer to the build manifest
matklad Jul 6, 2020
7610ab3
Expand abbreviation in core::ffi description
pierwill Jul 6, 2020
36e50a0
Edit librustc_lexer top-level docs
pierwill Jun 28, 2020
218d96e
Rollup merge of #70563 - GuillaumeGomez:page-hash-handling, r=ollie27…
Manishearth Jul 7, 2020
3f90287
Rollup merge of #73856 - pierwill:pierwill-lexer-doc, r=jonas-schievink
Manishearth Jul 7, 2020
7942d9a
Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
Manishearth Jul 7, 2020
e74ab50
Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebank
Manishearth Jul 7, 2020
ca5b64d
Rollup merge of #73962 - ryr3:unsafe_tcp, r=LukasKalbertodt
Manishearth Jul 7, 2020
62ba1bf
Rollup merge of #73969 - davidtwco:issue-73914-checkedadd-temp-genera…
Manishearth Jul 7, 2020
7d7b3e6
Rollup merge of #73974 - CAD97:rc-no-weak, r=dtolnay
Manishearth Jul 7, 2020
3199aeb
Rollup merge of #74067 - rye:rustdoc-fqn-hover-underline, r=Guillaume…
Manishearth Jul 7, 2020
86f8c53
Rollup merge of #74074 - sunfishcode:windows-openoptionsext-return-ty…
Manishearth Jul 7, 2020
ecc6f56
Rollup merge of #74078 - jyn514:lut, r=Manishearth
Manishearth Jul 7, 2020
caa858b
Rollup merge of #74089 - matklad:ship-rust-analyzer-some-more, r=piet…
Manishearth Jul 7, 2020
50e22bd
Rollup merge of #74090 - tmiasko:rustc-debug-assertions, r=RalfJung
Manishearth Jul 7, 2020
38f5151
Rollup merge of #74102 - oli-obk:const_prop_icde, r=wesleywiser
Manishearth Jul 7, 2020
73f2069
Rollup merge of #74112 - pierwill:patch-2, r=sfackler
Manishearth Jul 7, 2020
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
15 changes: 1 addition & 14 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ fn main() {
let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
let mut has_unstable = false;

use std::str::FromStr;

Expand Down Expand Up @@ -55,22 +54,10 @@ fn main() {
cmd.arg("--crate-version").arg(version);
}

// Needed to be able to run all rustdoc tests.
if env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES").is_some() {
// This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
if !has_unstable {
cmd.arg("-Z").arg("unstable-options");
}
cmd.arg("--generate-redirect-pages");
has_unstable = true;
}

// Needed to be able to run all rustdoc tests.
if let Some(ref x) = env::var_os("RUSTDOC_RESOURCE_SUFFIX") {
// This "unstable-options" can be removed when `--resource-suffix` is stabilized
if !has_unstable {
cmd.arg("-Z").arg("unstable-options");
}
cmd.arg("-Z").arg("unstable-options");
cmd.arg("--resource-suffix").arg(x);
}

Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ impl Step for Std {
.arg("--markdown-css")
.arg("rust.css")
.arg("--markdown-no-toc")
.arg("--generate-redirect-pages")
.arg("-Z")
.arg("unstable-options")
.arg("--resource-suffix")
Expand Down
2 changes: 0 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@ impl Step for Miri {
cargo.env("MIRI", &miri);
// Debug things.
cargo.env("RUST_BACKTRACE", "1");
// Overwrite bootstrap's `rustc` wrapper overwriting our flags.
cargo.env("RUSTC_DEBUG_ASSERTIONS", "true");
// Let cargo-miri know where xargo ended up.
cargo.env("XARGO_CHECK", builder.out.join("bin").join("xargo-check"));

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ impl<T> Weak<T> {
/// ```
///
/// [`null`]: ../../std/ptr/fn.null.html
#[stable(feature = "weak_into_raw", since = "1.45.0")]
#[stable(feature = "rc_as_ptr", since = "1.45.0")]
pub fn as_ptr(&self) -> *const T {
let ptr: *mut RcBox<T> = NonNull::as_ptr(self.ptr);

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ impl<T: ?Sized> Arc<T> {
/// assert_eq!(x_ptr, Arc::as_ptr(&y));
/// assert_eq!(unsafe { &*x_ptr }, "hello");
/// ```
#[stable(feature = "weak_into_raw", since = "1.45.0")]
#[stable(feature = "rc_as_ptr", since = "1.45.0")]
pub fn as_ptr(this: &Self) -> *const T {
let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![stable(feature = "", since = "1.30.0")]
#![allow(non_camel_case_types)]

//! Utilities related to FFI bindings.
//! Utilities related to foreign function interface (FFI) bindings.

use crate::fmt;
use crate::marker::PhantomData;
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_builtin_macros/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ impl<'a, 'b> Context<'a, 'b> {
("x", "LowerHex"),
("X", "UpperHex"),
] {
// FIXME: rustfix (`run-rustfix`) fails to apply suggestions.
// > "Cannot replace slice of data that was already replaced"
err.tool_only_span_suggestion(
sp,
&format!("use the `{}` trait", name),
Expand Down
9 changes: 5 additions & 4 deletions src/librustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
//! produces simple tokens which are a pair of type-tag and a bit of original text,
//! and does not report errors, instead storing them as flags on the token.
//!
//! Tokens produced by this lexer are not yet ready for parsing the Rust syntax,
//! for that see `librustc_parse::lexer`, which converts this basic token stream
//! Tokens produced by this lexer are not yet ready for parsing the Rust syntax.
//! For that see [`librustc_parse::lexer`], which converts this basic token stream
//! into wide tokens used by actual parser.
//!
//! The purpose of this crate is to convert raw sources into a labeled sequence
//! of well-known token types, so building an actual Rust token stream will
//! be easier.
//!
//! Main entity of this crate is [`TokenKind`] enum which represents common
//! The main entity of this crate is the [`TokenKind`] enum which represents common
//! lexeme types.

//!
//! [`librustc_parse::lexer`]: ../rustc_parse/lexer/index.html
// We want to be able to build this crate with a stable compiler, so no
// `#![feature]` attributes should be added.

Expand Down
40 changes: 21 additions & 19 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,14 +1004,6 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
let expected = ScalarMaybeUninit::from(Scalar::from_bool(*expected));
let value_const = self.ecx.read_scalar(value).unwrap();
if expected != value_const {
// Poison all places this operand references so that further code
// doesn't use the invalid value
match cond {
Operand::Move(ref place) | Operand::Copy(ref place) => {
Self::remove_const(&mut self.ecx, place.local);
}
Operand::Constant(_) => {}
}
let mut eval_to_int = |op| {
let op = self
.eval_operand(op, source_info)
Expand All @@ -1020,27 +1012,37 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
};
let msg = match msg {
AssertKind::DivisionByZero(op) => {
AssertKind::DivisionByZero(eval_to_int(op))
Some(AssertKind::DivisionByZero(eval_to_int(op)))
}
AssertKind::RemainderByZero(op) => {
AssertKind::RemainderByZero(eval_to_int(op))
Some(AssertKind::RemainderByZero(eval_to_int(op)))
}
AssertKind::BoundsCheck { ref len, ref index } => {
let len = eval_to_int(len);
let index = eval_to_int(index);
AssertKind::BoundsCheck { len, index }
Some(AssertKind::BoundsCheck { len, index })
}
// Overflow is are already covered by checks on the binary operators.
AssertKind::Overflow(..) | AssertKind::OverflowNeg(_) => return,
AssertKind::Overflow(..) | AssertKind::OverflowNeg(_) => None,
// Need proper const propagator for these.
_ => return,
_ => None,
};
self.report_assert_as_lint(
lint::builtin::UNCONDITIONAL_PANIC,
source_info,
"this operation will panic at runtime",
msg,
);
// Poison all places this operand references so that further code
// doesn't use the invalid value
match cond {
Operand::Move(ref place) | Operand::Copy(ref place) => {
Self::remove_const(&mut self.ecx, place.local);
}
Operand::Constant(_) => {}
}
if let Some(msg) = msg {
self.report_assert_as_lint(
lint::builtin::UNCONDITIONAL_PANIC,
source_info,
"this operation will panic at runtime",
msg,
);
}
} else {
if self.should_const_prop(value) {
if let ScalarMaybeUninit::Scalar(scalar) = value_const {
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir_build/build/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// N.B., **No cleanup is scheduled for this temporary.** You should
/// call `schedule_drop` once the temporary is initialized.
crate fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
let temp = self.local_decls.push(LocalDecl::new(ty, span));
// Mark this local as internal to avoid temporaries with types not present in the
// user's code resulting in ICEs from the generator transform.
let temp = self.local_decls.push(LocalDecl::new(ty, span).internal());
let place = Place::from(temp);
debug!("temp: created temp {:?} with type {:?}", place, self.local_decls[temp].ty);
place
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_parse/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,10 +1228,13 @@ impl<'a> Parser<'a> {
if let Some(sp) = unmatched.unclosed_span {
err.span_label(sp, "unclosed delimiter");
}
// Backticks should be removed to apply suggestions.
let mut delim = delim.to_string();
delim.retain(|c| c != '`');
err.span_suggestion_short(
self.prev_token.span.shrink_to_hi(),
&format!("{} may belong here", delim.to_string()),
delim.to_string(),
&format!("`{}` may belong here", delim),
delim,
Applicability::MaybeIncorrect,
);
if unmatched.found_delim.is_none() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ impl<'a> Parser<'a> {
// misses a separator.
expect_err
.span_suggestion_short(
sp,
self.sess.source_map().next_point(sp),
&format!("missing `{}`", token_str),
token_str,
Applicability::MaybeIncorrect,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
) {
if let mc::PlaceBase::Rvalue = place_with_id.place.base {
if place_with_id.place.projections.is_empty() {
let typ = self.resolve_type(place_with_id.place.ty);
let typ = self.resolve_type(place_with_id.place.ty());
let body_id = self.body_id;
let _ = dropck::check_drop_obligations(self, typ, span, body_id);
}
Expand Down Expand Up @@ -640,8 +640,8 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
borrow_kind: ty::BorrowKind,
borrow_place: &mc::PlaceWithHirId<'tcx>,
) {
let origin = infer::DataBorrowed(borrow_place.place.ty, span);
self.type_must_outlive(origin, borrow_place.place.ty, borrow_region);
let origin = infer::DataBorrowed(borrow_place.place.ty(), span);
self.type_must_outlive(origin, borrow_place.place.ty(), borrow_region);

for pointer_ty in borrow_place.place.deref_tys() {
debug!(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {

// Select just those fields of the `with`
// expression that will actually be used
match with_place.place.ty.kind {
match with_place.place.ty().kind {
ty::Adt(adt, substs) if adt.is_struct() => {
// Consume those fields of the with expression that are needed.
for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
Expand Down Expand Up @@ -583,7 +583,7 @@ fn copy_or_move<'a, 'tcx>(
place_with_id: &PlaceWithHirId<'tcx>,
) -> ConsumeMode {
if !mc.type_is_copy_modulo_regions(
place_with_id.place.ty,
place_with_id.place.ty(),
mc.tcx().hir().span(place_with_id.hir_id),
) {
Move
Expand Down
67 changes: 48 additions & 19 deletions src/librustc_typeck/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,30 @@ pub enum PlaceBase {
Upvar(ty::UpvarId),
}

#[derive(Clone, Debug)]
pub enum ProjectionKind<'tcx> {
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ProjectionKind {
/// A dereference of a pointer, reference or `Box<T>` of the given type
Deref(Ty<'tcx>),
Deref,
/// An index or a field
Other,
}

#[derive(Clone, Debug)]
pub struct Projection<'tcx> {
// Type after the projection is being applied.
ty: Ty<'tcx>,

/// Defines the type of access
kind: ProjectionKind<'tcx>,
kind: ProjectionKind,
}

/// A `Place` represents how a value is located in memory.
///
/// This is an HIR version of `mir::Place`
#[derive(Clone, Debug)]
pub struct Place<'tcx> {
/// The type of the `Place`
pub ty: Ty<'tcx>,
/// The type of the `PlaceBase`
pub base_ty: Ty<'tcx>,
/// The "outermost" place that holds this value.
pub base: PlaceBase,
/// How this place is derived from the base place.
Expand All @@ -115,13 +118,13 @@ pub struct PlaceWithHirId<'tcx> {
impl<'tcx> PlaceWithHirId<'tcx> {
crate fn new(
hir_id: hir::HirId,
ty: Ty<'tcx>,
base_ty: Ty<'tcx>,
base: PlaceBase,
projections: Vec<Projection<'tcx>>,
) -> PlaceWithHirId<'tcx> {
PlaceWithHirId {
hir_id: hir_id,
place: Place { ty: ty, base: base, projections: projections },
place: Place { base_ty: base_ty, base: base, projections: projections },
}
}
}
Expand All @@ -134,10 +137,26 @@ impl<'tcx> Place<'tcx> {
/// `x: &*const u32` and the `Place` is `**x`, then the types returned are
///`*const u32` then `&*const u32`.
crate fn deref_tys(&self) -> impl Iterator<Item = Ty<'tcx>> + '_ {
self.projections.iter().rev().filter_map(|proj| {
if let ProjectionKind::Deref(deref_ty) = proj.kind { Some(deref_ty) } else { None }
self.projections.iter().enumerate().rev().filter_map(move |(index, proj)| {
if ProjectionKind::Deref == proj.kind {
Some(self.ty_before_projection(index))
} else {
None
}
})
}

// Returns the type of this `Place` after all projections have been applied.
pub fn ty(&self) -> Ty<'tcx> {
self.projections.last().map_or_else(|| self.base_ty, |proj| proj.ty)
}

// Returns the type of this `Place` immediately before `projection_index`th projection
// is applied.
crate fn ty_before_projection(&self, projection_index: usize) -> Ty<'tcx> {
assert!(projection_index < self.projections.len());
if projection_index == 0 { self.base_ty } else { self.projections[projection_index - 1].ty }
}
}

crate trait HirNode {
Expand Down Expand Up @@ -516,8 +535,13 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
ty: Ty<'tcx>,
) -> PlaceWithHirId<'tcx> {
let mut projections = base_place.place.projections;
projections.push(Projection { kind: ProjectionKind::Other });
let ret = PlaceWithHirId::new(node.hir_id(), ty, base_place.place.base, projections);
projections.push(Projection { kind: ProjectionKind::Other, ty: ty });
let ret = PlaceWithHirId::new(
node.hir_id(),
base_place.place.base_ty,
base_place.place.base,
projections,
);
debug!("cat_field ret {:?}", ret);
ret
}
Expand Down Expand Up @@ -552,18 +576,23 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
) -> McResult<PlaceWithHirId<'tcx>> {
debug!("cat_deref: base_place={:?}", base_place);

let base_ty = base_place.place.ty;
let deref_ty = match base_ty.builtin_deref(true) {
let base_curr_ty = base_place.place.ty();
let deref_ty = match base_curr_ty.builtin_deref(true) {
Some(mt) => mt.ty,
None => {
debug!("explicit deref of non-derefable type: {:?}", base_ty);
debug!("explicit deref of non-derefable type: {:?}", base_curr_ty);
return Err(());
}
};
let mut projections = base_place.place.projections;
projections.push(Projection { kind: ProjectionKind::Deref(base_ty) });

let ret = PlaceWithHirId::new(node.hir_id(), deref_ty, base_place.place.base, projections);
projections.push(Projection { kind: ProjectionKind::Deref, ty: deref_ty });

let ret = PlaceWithHirId::new(
node.hir_id(),
base_place.place.base_ty,
base_place.place.base,
projections,
);
debug!("cat_deref ret {:?}", ret);
Ok(ret)
}
Expand Down Expand Up @@ -687,7 +716,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
}

PatKind::Slice(before, ref slice, after) => {
let element_ty = match place_with_id.place.ty.builtin_index() {
let element_ty = match place_with_id.place.ty().builtin_index() {
Some(ty) => ty,
None => {
debug!("explicit index of non-indexable type {:?}", place_with_id);
Expand Down
Loading