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 10 pull requests #74114

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 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
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
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
f226e6b
Add `read_exact_at` and `write_all_at` to WASI's `FileExt`
sunfishcode Jul 3, 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
7610ab3
Expand abbreviation in core::ffi description
pierwill Jul 6, 2020
99fc337
Rollup merge of #70563 - GuillaumeGomez:page-hash-handling, r=ollie27…
Dylan-DPC Jul 6, 2020
4d24341
Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
Dylan-DPC Jul 6, 2020
59112d3
Rollup merge of #73962 - ryr3:unsafe_tcp, r=LukasKalbertodt
Dylan-DPC Jul 6, 2020
5c267ae
Rollup merge of #74067 - rye:rustdoc-fqn-hover-underline, r=Guillaume…
Dylan-DPC Jul 6, 2020
87b8681
Rollup merge of #74074 - sunfishcode:windows-openoptionsext-return-ty…
Dylan-DPC Jul 6, 2020
51d7220
Rollup merge of #74076 - sunfishcode:wasi-fileext-newmethods, r=alexc…
Dylan-DPC Jul 6, 2020
6a8e601
Rollup merge of #74078 - jyn514:lut, r=Manishearth
Dylan-DPC Jul 6, 2020
b5cfc94
Rollup merge of #74090 - tmiasko:rustc-debug-assertions, r=RalfJung
Dylan-DPC Jul 6, 2020
8511ed6
Rollup merge of #74102 - oli-obk:const_prop_icde, r=wesleywiser
Dylan-DPC Jul 6, 2020
f36490d
Rollup merge of #74112 - pierwill:patch-2, r=sfackler
Dylan-DPC Jul 6, 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/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
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
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
4 changes: 0 additions & 4 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ pub struct RenderOptions {
/// If false, the `select` element to have search filtering by crates on rendered docs
/// won't be generated.
pub generate_search_filter: bool,
/// Option (disabled by default) to generate files used by RLS and some other tools.
pub generate_redirect_pages: bool,
/// Document items that have lower than `pub` visibility.
pub document_private: bool,
/// Document items that have `doc(hidden)`.
Expand Down Expand Up @@ -528,7 +526,6 @@ impl Options {
let static_root_path = matches.opt_str("static-root-path");
let generate_search_filter = !matches.opt_present("disable-per-crate-search");
let persist_doctests = matches.opt_str("persist-doctests").map(PathBuf::from);
let generate_redirect_pages = matches.opt_present("generate-redirect-pages");
let test_builder = matches.opt_str("test-builder").map(PathBuf::from);
let codegen_options_strs = matches.opt_strs("C");
let debugging_options_strs = matches.opt_strs("Z");
Expand Down Expand Up @@ -592,7 +589,6 @@ impl Options {
markdown_css,
markdown_playground_url,
generate_search_filter,
generate_redirect_pages,
document_private,
document_hidden,
},
Expand Down
37 changes: 0 additions & 37 deletions src/librustdoc/html/item_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,47 +154,10 @@ impl ItemType {
ItemType::TraitAlias => "traitalias",
}
}

pub fn name_space(&self) -> &'static str {
match *self {
ItemType::Struct
| ItemType::Union
| ItemType::Enum
| ItemType::Module
| ItemType::Typedef
| ItemType::Trait
| ItemType::Primitive
| ItemType::AssocType
| ItemType::OpaqueTy
| ItemType::TraitAlias
| ItemType::ForeignType => NAMESPACE_TYPE,

ItemType::ExternCrate
| ItemType::Import
| ItemType::Function
| ItemType::Static
| ItemType::Impl
| ItemType::TyMethod
| ItemType::Method
| ItemType::StructField
| ItemType::Variant
| ItemType::Constant
| ItemType::AssocConst => NAMESPACE_VALUE,

ItemType::Macro | ItemType::ProcAttribute | ItemType::ProcDerive => NAMESPACE_MACRO,

ItemType::Keyword => NAMESPACE_KEYWORD,
}
}
}

impl fmt::Display for ItemType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}
}

pub const NAMESPACE_TYPE: &str = "t";
pub const NAMESPACE_VALUE: &str = "v";
pub const NAMESPACE_MACRO: &str = "m";
pub const NAMESPACE_KEYWORD: &str = "k";
Loading