Skip to content

Commit

Permalink
Merge rustc into rmc - 2021 week 43 (rust-lang#591)
Browse files Browse the repository at this point in the history
Conflicts:
    src/librustdoc/lib.rs: import conflict
  • Loading branch information
celinval authored and tedinski committed Nov 3, 2021
1 parent 1ee2161 commit 5011097
Show file tree
Hide file tree
Showing 314 changed files with 4,327 additions and 2,094 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2459,9 +2459,9 @@ dependencies = [

[[package]]
name = "odht"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2504d29fda40b3f2f9ef525392435ab660e407c188196cb664b116ebcca0142"
checksum = "5a518809ac14b25b569624d0268eba1e88498f71615893dca57982bed7621abb"
dependencies = [
"cfg-if 1.0.0",
]
Expand Down Expand Up @@ -4406,6 +4406,7 @@ dependencies = [
"rustc_span",
"tracing",
"unicode-normalization",
"unicode-width",
]

[[package]]
Expand Down Expand Up @@ -4762,8 +4763,8 @@ dependencies = [
"itertools 0.9.0",
"minifier",
"pulldown-cmark 0.8.0",
"rayon",
"regex",
"rustc-rayon",
"rustdoc-json-types",
"serde",
"serde_json",
Expand Down
8 changes: 8 additions & 0 deletions UPSTREAM-RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 1.56.1 (2021-11-01)
===========================

- New lints to detect the presence of bidirectional-override Unicode
codepoints in the compiled source code ([CVE-2021-42574])

[CVE-2021-42574]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42574

Version 1.56.0 (2021-10-21)
========================

Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ impl AttrAnnotatedTokenStream {
for attr in &data.attrs {
match attr.style {
crate::AttrStyle::Outer => {
assert!(
inner_attrs.len() == 0,
"Found outer attribute {:?} after inner attrs {:?}",
attr,
inner_attrs
);
outer_attrs.push(attr);
}
crate::AttrStyle::Inner => {
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::fmt::Write;

impl<'a, 'hir> LoweringContext<'a, 'hir> {
crate fn lower_inline_asm(&mut self, sp: Span, asm: &InlineAsm) -> &'hir hir::InlineAsm<'hir> {
// Rustdoc needs to support asm! from foriegn architectures: don't try
// lowering the register contraints in this case.
// Rustdoc needs to support asm! from foreign architectures: don't try
// lowering the register constraints in this case.
let asm_arch = if self.sess.opts.actually_rustdoc { None } else { self.sess.asm_arch };
if asm_arch.is_none() && !self.sess.opts.actually_rustdoc {
struct_span_err!(self.sess, sp, E0472, "inline assembly is unsupported on this target")
Expand Down Expand Up @@ -214,9 +214,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// means that we disallow passing a value in/out of the asm and
// require that the operand name an explicit register, not a
// register class.
if reg_class.is_clobber_only(asm_arch.unwrap())
&& !(op.is_clobber() && matches!(reg, asm::InlineAsmRegOrRegClass::Reg(_)))
{
if reg_class.is_clobber_only(asm_arch.unwrap()) && !op.is_clobber() {
let msg = format!(
"register class `{}` can only be used as a clobber, \
not as an input or output",
Expand Down
24 changes: 5 additions & 19 deletions compiler/rustc_ast_lowering/src/index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::definitions;
Expand All @@ -9,14 +10,13 @@ use rustc_session::Session;
use rustc_span::source_map::SourceMap;
use rustc_span::{Span, DUMMY_SP};

use std::iter::repeat;
use tracing::debug;

/// A visitor that walks over the HIR and collects `Node`s into a HIR map.
pub(super) struct NodeCollector<'a, 'hir> {
/// Source map
source_map: &'a SourceMap,
bodies: &'a IndexVec<ItemLocalId, Option<&'hir Body<'hir>>>,
bodies: &'a SortedMap<ItemLocalId, &'hir Body<'hir>>,

/// Outputs
nodes: IndexVec<ItemLocalId, Option<ParentedNode<'hir>>>,
Expand All @@ -30,21 +30,11 @@ pub(super) struct NodeCollector<'a, 'hir> {
definitions: &'a definitions::Definitions,
}

fn insert_vec_map<K: Idx, V: Clone>(map: &mut IndexVec<K, Option<V>>, k: K, v: V) {
let i = k.index();
let len = map.len();
if i >= len {
map.extend(repeat(None).take(i - len + 1));
}
debug_assert!(map[k].is_none());
map[k] = Some(v);
}

pub(super) fn index_hir<'hir>(
sess: &Session,
definitions: &definitions::Definitions,
item: hir::OwnerNode<'hir>,
bodies: &IndexVec<ItemLocalId, Option<&'hir Body<'hir>>>,
bodies: &SortedMap<ItemLocalId, &'hir Body<'hir>>,
) -> (IndexVec<ItemLocalId, Option<ParentedNode<'hir>>>, FxHashMap<LocalDefId, ItemLocalId>) {
let mut nodes = IndexVec::new();
// This node's parent should never be accessed: the owner's parent is computed by the
Expand Down Expand Up @@ -94,11 +84,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
}
}

insert_vec_map(
&mut self.nodes,
hir_id.local_id,
ParentedNode { parent: self.parent_node, node: node },
);
self.nodes.insert(hir_id.local_id, ParentedNode { parent: self.parent_node, node: node });
}

fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_node_id: HirId, f: F) {
Expand Down Expand Up @@ -144,7 +130,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {

fn visit_nested_body(&mut self, id: BodyId) {
debug_assert_eq!(id.hir_id.owner, self.owner);
let body = self.bodies[id.hir_id.local_id].unwrap();
let body = self.bodies[&id.hir_id.local_id];
self.visit_body(body);
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let body = hir::Body { generator_kind: self.generator_kind, params, value };
let id = body.id();
debug_assert_eq!(id.hir_id.owner, self.current_hir_id_owner);
self.bodies.ensure_contains_elem(id.hir_id.local_id, || None);
self.bodies[id.hir_id.local_id] = Some(self.arena.alloc(body));
self.bodies.push((id.hir_id.local_id, self.arena.alloc(body)));
id
}

Expand Down
19 changes: 10 additions & 9 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#![feature(iter_zip)]
#![feature(never_type)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]

use rustc_ast::token::{self, Token};
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree};
Expand All @@ -45,6 +44,7 @@ use rustc_ast_pretty::pprust;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{struct_span_err, Applicability};
Expand All @@ -67,7 +67,6 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};

use smallvec::SmallVec;
use std::collections::BTreeMap;
use tracing::{debug, trace};

macro_rules! arena_vec {
Expand Down Expand Up @@ -104,9 +103,9 @@ struct LoweringContext<'a, 'hir: 'a> {
/// The items being lowered are collected here.
owners: IndexVec<LocalDefId, Option<hir::OwnerInfo<'hir>>>,
/// Bodies inside the owner being lowered.
bodies: IndexVec<hir::ItemLocalId, Option<&'hir hir::Body<'hir>>>,
bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
/// Attributes inside the owner being lowered.
attrs: BTreeMap<hir::ItemLocalId, &'hir [Attribute]>,
attrs: SortedMap<hir::ItemLocalId, &'hir [Attribute]>,

generator_kind: Option<hir::GeneratorKind>,

Expand Down Expand Up @@ -301,8 +300,8 @@ pub fn lower_crate<'a, 'hir>(
nt_to_tokenstream,
arena,
owners,
bodies: IndexVec::new(),
attrs: BTreeMap::default(),
bodies: Vec::new(),
attrs: SortedMap::new(),
catch_scope: None,
loop_scope: None,
is_in_loop_condition: false,
Expand Down Expand Up @@ -479,7 +478,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

fn make_owner_info(&mut self, node: hir::OwnerNode<'hir>) -> hir::OwnerInfo<'hir> {
let attrs = std::mem::take(&mut self.attrs);
let bodies = std::mem::take(&mut self.bodies);
let mut bodies = std::mem::take(&mut self.bodies);
let local_node_ids = std::mem::take(&mut self.local_node_ids);
let trait_map = local_node_ids
.into_iter()
Expand All @@ -491,13 +490,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.collect();

#[cfg(debug_assertions)]
for (&id, attrs) in attrs.iter() {
for (id, attrs) in attrs.iter() {
// Verify that we do not store empty slices in the map.
if attrs.is_empty() {
panic!("Stored empty attributes for {:?}", id);
}
}

bodies.sort_by_key(|(k, _)| *k);
let bodies = SortedMap::from_presorted_elements(bodies);
let (hash_including_bodies, hash_without_bodies) = self.hash_owner(node, &bodies);
let (nodes, parenting) =
index::index_hir(self.sess, self.resolver.definitions(), node, &bodies);
Expand All @@ -518,7 +519,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn hash_owner(
&mut self,
node: hir::OwnerNode<'hir>,
bodies: &IndexVec<hir::ItemLocalId, Option<&'hir hir::Body<'hir>>>,
bodies: &SortedMap<hir::ItemLocalId, &'hir hir::Body<'hir>>,
) -> (Fingerprint, Fingerprint) {
let mut hcx = self.resolver.create_stable_hashing_context();
let mut stable_hasher = StableHasher::new();
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#![feature(iter_is_partitioned)]
#![feature(box_patterns)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]

pub mod ast_validation;
pub mod feature_gate;
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ use rustc_mir_dataflow::move_paths::MoveData;
use std::fmt;
use std::ops::Index;

crate struct BorrowSet<'tcx> {
pub struct BorrowSet<'tcx> {
/// The fundamental map relating bitvector indexes to the borrows
/// in the MIR. Each borrow is also uniquely identified in the MIR
/// by the `Location` of the assignment statement in which it
/// appears on the right hand side. Thus the location is the map
/// key, and its position in the map corresponds to `BorrowIndex`.
crate location_map: FxIndexMap<Location, BorrowData<'tcx>>,
pub location_map: FxIndexMap<Location, BorrowData<'tcx>>,

/// Locations which activate borrows.
/// NOTE: a given location may activate more than one borrow in the future
/// when more general two-phase borrow support is introduced, but for now we
/// only need to store one borrow index.
crate activation_map: FxHashMap<Location, Vec<BorrowIndex>>,
pub activation_map: FxHashMap<Location, Vec<BorrowIndex>>,

/// Map from local to all the borrows on that local.
crate local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
pub local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,

crate locals_state_at_exit: LocalsStateAtExit,
}
Expand All @@ -43,27 +43,27 @@ impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> {
/// Location where a two-phase borrow is activated, if a borrow
/// is in fact a two-phase borrow.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
crate enum TwoPhaseActivation {
pub enum TwoPhaseActivation {
NotTwoPhase,
NotActivated,
ActivatedAt(Location),
}

#[derive(Debug, Clone)]
crate struct BorrowData<'tcx> {
pub struct BorrowData<'tcx> {
/// Location where the borrow reservation starts.
/// In many cases, this will be equal to the activation location but not always.
crate reserve_location: Location,
pub reserve_location: Location,
/// Location where the borrow is activated.
crate activation_location: TwoPhaseActivation,
pub activation_location: TwoPhaseActivation,
/// What kind of borrow this is
crate kind: mir::BorrowKind,
pub kind: mir::BorrowKind,
/// The region for which this borrow is live
crate region: RegionVid,
pub region: RegionVid,
/// Place from which we are borrowing
crate borrowed_place: mir::Place<'tcx>,
pub borrowed_place: mir::Place<'tcx>,
/// Place to which the borrow was stored
crate assigned_place: mir::Place<'tcx>,
pub assigned_place: mir::Place<'tcx>,
}

impl<'tcx> fmt::Display for BorrowData<'tcx> {
Expand All @@ -78,7 +78,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
}
}

crate enum LocalsStateAtExit {
pub enum LocalsStateAtExit {
AllAreInvalidated,
SomeAreInvalidated { has_storage_dead_or_moved: BitSet<Local> },
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#![feature(trusted_step)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]

#[macro_use]
extern crate rustc_middle;
Expand Down Expand Up @@ -64,7 +63,7 @@ use facts::AllFacts;

use self::path_utils::*;

mod borrow_set;
pub mod borrow_set;
mod borrowck_errors;
mod constraint_generation;
mod constraints;
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::VariantIdx;
use rustc_trait_selection::infer::InferCtxtExt as _;
use rustc_trait_selection::opaque_types::InferCtxtExt;
use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
use rustc_trait_selection::traits::query::type_op;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]

extern crate proc_macro;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
true
}

fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, _span: &[Span]) {
fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, _span: &[Span], _instance: Instance<'_>) {
let asm_arch = self.tcx.sess.asm_arch.unwrap();
let is_x86 = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64);
let att_dialect = is_x86 && options.contains(InlineAsmOptions::ATT_SYNTAX);
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,16 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
// TODO(antoyo)
}

fn type_metadata(&mut self, _function: RValue<'gcc>, _typeid: String) {
// Unsupported.
}

fn typeid_metadata(&mut self, _typeid: String) -> RValue<'gcc> {
// Unsupported.
self.context.new_rvalue_from_int(self.int_type, 0)
}


fn store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> {
self.store_with_flags(val, ptr, align, MemFlags::empty())
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
// TODO(antoyo)
}

fn type_test(&mut self, _pointer: Self::Value, _typeid: Self::Value) -> Self::Value {
// Unsupported.
self.context.new_rvalue_from_int(self.int_type, 0)
}

fn va_start(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> {
unimplemented!();
}
Expand Down
Loading

0 comments on commit 5011097

Please sign in to comment.