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 6 pull requests #96202

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1be1157
Remove `--extern-location` and all associated code
jsgf Apr 15, 2022
8cec88b
`alloc`: make `vec!` unavailable under `no_global_oom_handling`
ojeda Apr 15, 2022
ebe3c56
Provide a better diagnostic on failure to meet send bound on futures …
oribenshir Mar 5, 2022
07ee031
Stop using CRATE_DEF_INDEX.
cjgillot Apr 15, 2022
703a336
Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`.
sunfishcode Mar 27, 2022
5b3023c
Fix an incorrect word in a comment.
sunfishcode Mar 27, 2022
67994b7
Move the `Error` impl for `NotHandle` out of platform-independent code.
sunfishcode Mar 27, 2022
f934043
Split `NotHandle` into `NullHandleError` and `InvalidHandleError`.
sunfishcode Mar 28, 2022
890125d
Add a comment explaining the `(())` idiom for empty structs.
sunfishcode Apr 13, 2022
b7ff103
Update the expected stderr for coerce-issue-49593-box-never.
sunfishcode Apr 15, 2022
19ef182
Update the expected stderr for coerce-issue-49593-box-never.
sunfishcode Apr 19, 2022
0255398
Improve AddrParseError description
chris-morgan Apr 19, 2022
a857380
Rollup merge of #94493 - oribenshir:feature/ISSUE-78543_async_fn_in_f…
Dylan-DPC Apr 19, 2022
47ad09c
Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco
Dylan-DPC Apr 19, 2022
58982f5
Rollup merge of #96089 - ojeda:no-vec-no_global_oom_handling, r=Mark-…
Dylan-DPC Apr 19, 2022
23ed99b
Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov
Dylan-DPC Apr 19, 2022
8417ba8
Rollup merge of #96168 - chris-morgan:AddrParseError-description-impr…
Dylan-DPC Apr 19, 2022
c6114bb
Rollup merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type…
Dylan-DPC Apr 19, 2022
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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3934,7 +3934,6 @@ dependencies = [
"rustc_infer",
"rustc_middle",
"rustc_parse_format",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
Expand Down
17 changes: 2 additions & 15 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::collections::hash_map::Entry::*;

use rustc_ast::expand::allocator::ALLOCATOR_METHODS;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
use rustc_hir::Node;
use rustc_index::vec::IndexVec;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::exported_symbols::{
metadata_symbol_name, ExportedSymbol, SymbolExportLevel,
Expand Down Expand Up @@ -277,17 +275,6 @@ fn upstream_monomorphizations_provider(

let mut instances: DefIdMap<FxHashMap<_, _>> = Default::default();

let cnum_stable_ids: IndexVec<CrateNum, Fingerprint> = {
let mut cnum_stable_ids = IndexVec::from_elem_n(Fingerprint::ZERO, cnums.len() + 1);

for &cnum in cnums.iter() {
cnum_stable_ids[cnum] =
tcx.def_path_hash(DefId { krate: cnum, index: CRATE_DEF_INDEX }).0;
}

cnum_stable_ids
};

let drop_in_place_fn_def_id = tcx.lang_items().drop_in_place_fn();

for &cnum in cnums.iter() {
Expand Down Expand Up @@ -316,7 +303,7 @@ fn upstream_monomorphizations_provider(
// If there are multiple monomorphizations available,
// we select one deterministically.
let other_cnum = *e.get();
if cnum_stable_ids[other_cnum] > cnum_stable_ids[cnum] {
if tcx.stable_crate_id(other_cnum) > tcx.stable_crate_id(cnum) {
e.insert(cnum);
}
}
Expand Down
25 changes: 1 addition & 24 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::snippet::Style;
use crate::{
CodeSuggestion, DiagnosticMessage, Level, MultiSpan, Substitution, SubstitutionPart,
SuggestionStyle, ToolMetadata,
SuggestionStyle,
};
use rustc_data_structures::stable_map::FxHashMap;
use rustc_error_messages::FluentValue;
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_serialize::json::Json;
use rustc_span::edition::LATEST_STABLE_EDITION;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
Expand Down Expand Up @@ -554,7 +553,6 @@ impl Diagnostic {
msg: msg.into(),
style,
applicability,
tool_metadata: Default::default(),
});
self
}
Expand Down Expand Up @@ -582,7 +580,6 @@ impl Diagnostic {
msg: msg.into(),
style: SuggestionStyle::CompletelyHidden,
applicability,
tool_metadata: Default::default(),
});
self
}
Expand Down Expand Up @@ -637,7 +634,6 @@ impl Diagnostic {
msg: msg.into(),
style,
applicability,
tool_metadata: Default::default(),
});
self
}
Expand Down Expand Up @@ -680,7 +676,6 @@ impl Diagnostic {
msg: msg.into(),
style: SuggestionStyle::ShowCode,
applicability,
tool_metadata: Default::default(),
});
self
}
Expand All @@ -705,7 +700,6 @@ impl Diagnostic {
msg: msg.into(),
style: SuggestionStyle::ShowCode,
applicability,
tool_metadata: Default::default(),
});
self
}
Expand Down Expand Up @@ -774,23 +768,6 @@ impl Diagnostic {
self
}

/// Adds a suggestion intended only for a tool. The intent is that the metadata encodes
/// the suggestion in a tool-specific way, as it may not even directly involve Rust code.
pub fn tool_only_suggestion_with_metadata(
&mut self,
msg: impl Into<DiagnosticMessage>,
applicability: Applicability,
tool_metadata: Json,
) {
self.push_suggestion(CodeSuggestion {
substitutions: vec![],
msg: msg.into(),
style: SuggestionStyle::CompletelyHidden,
applicability,
tool_metadata: ToolMetadata::new(tool_metadata),
})
}

pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self {
self.span = sp.into();
if let Some(span) = self.span.primary_span() {
Expand Down
67 changes: 1 addition & 66 deletions compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
use crate::emitter::{Emitter, HumanReadableErrorType};
use crate::registry::Registry;
use crate::DiagnosticId;
use crate::ToolMetadata;
use crate::{
CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, SubDiagnostic,
};
Expand All @@ -30,7 +29,6 @@ use std::sync::{Arc, Mutex};
use std::vec;

use rustc_serialize::json::{as_json, as_pretty_json};
use rustc_serialize::{Encodable, Encoder};

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -205,8 +203,7 @@ impl Emitter for JsonEmitter {

// The following data types are provided just for serialisation.

// NOTE: this has a manual implementation of Encodable which needs to be updated in
// parallel.
#[derive(Encodable)]
struct Diagnostic {
/// The primary error message.
message: String,
Expand All @@ -218,65 +215,6 @@ struct Diagnostic {
children: Vec<Diagnostic>,
/// The message as rustc would render it.
rendered: Option<String>,
/// Extra tool metadata
tool_metadata: ToolMetadata,
}

macro_rules! encode_fields {
(
$enc:expr, // encoder
$idx:expr, // starting field index
$struct:expr, // struct we're serializing
$struct_name:ident, // struct name
[ $($name:ident),+$(,)? ], // fields to encode
[ $($ignore:ident),+$(,)? ] // fields we're skipping
) => {
{
// Pattern match to make sure all fields are accounted for
let $struct_name { $($name,)+ $($ignore: _,)+ } = $struct;
let mut idx = $idx;
$(
$enc.emit_struct_field(
stringify!($name),
idx == 0,
|enc| $name.encode(enc),
)?;
idx += 1;
)+
idx
}
};
}

// Special-case encoder to skip tool_metadata if not set
impl<E: Encoder> Encodable<E> for Diagnostic {
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
s.emit_struct(false, |s| {
let mut idx = 0;

idx = encode_fields!(
s,
idx,
self,
Self,
[message, code, level, spans, children, rendered],
[tool_metadata]
);
if self.tool_metadata.is_set() {
idx = encode_fields!(
s,
idx,
self,
Self,
[tool_metadata],
[message, code, level, spans, children, rendered]
);
}

let _ = idx;
Ok(())
})
}
}

#[derive(Encodable)]
Expand Down Expand Up @@ -380,7 +318,6 @@ impl Diagnostic {
spans: DiagnosticSpan::from_suggestion(sugg, &args, je),
children: vec![],
rendered: None,
tool_metadata: sugg.tool_metadata.clone(),
}
});

Expand Down Expand Up @@ -428,7 +365,6 @@ impl Diagnostic {
.chain(sugg)
.collect(),
rendered: Some(output),
tool_metadata: ToolMetadata::default(),
}
}

Expand All @@ -449,7 +385,6 @@ impl Diagnostic {
.unwrap_or_else(|| DiagnosticSpan::from_multispan(&diag.span, args, je)),
children: vec![],
rendered: None,
tool_metadata: ToolMetadata::default(),
}
}
}
Expand Down
39 changes: 1 addition & 38 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ pub use rustc_error_messages::{
LazyFallbackBundle, MultiSpan, SpanLabel, DEFAULT_LOCALE_RESOURCES,
};
pub use rustc_lint_defs::{pluralize, Applicability};
use rustc_serialize::json::Json;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_span::source_map::SourceMap;
use rustc_span::{Loc, Span};

use std::borrow::Cow;
use std::hash::{Hash, Hasher};
use std::hash::Hash;
use std::num::NonZeroUsize;
use std::panic;
use std::path::Path;
Expand Down Expand Up @@ -93,39 +91,6 @@ impl SuggestionStyle {
}
}

#[derive(Clone, Debug, PartialEq, Default)]
pub struct ToolMetadata(pub Option<Json>);

impl ToolMetadata {
fn new(json: Json) -> Self {
ToolMetadata(Some(json))
}

fn is_set(&self) -> bool {
self.0.is_some()
}
}

impl Hash for ToolMetadata {
fn hash<H: Hasher>(&self, _state: &mut H) {}
}

// Doesn't really need to round-trip
impl<D: Decoder> Decodable<D> for ToolMetadata {
fn decode(_d: &mut D) -> Self {
ToolMetadata(None)
}
}

impl<S: Encoder> Encodable<S> for ToolMetadata {
fn encode(&self, e: &mut S) -> Result<(), S::Error> {
match &self.0 {
None => e.emit_unit(),
Some(json) => json.encode(e),
}
}
}

#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
pub struct CodeSuggestion {
/// Each substitute can have multiple variants due to multiple
Expand Down Expand Up @@ -159,8 +124,6 @@ pub struct CodeSuggestion {
/// which are useful for users but not useful for
/// tools like rustfix
pub applicability: Applicability,
/// Tool-specific metadata
pub tool_metadata: ToolMetadata,
}

#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use crate::def_id::DefId;
use crate::hir;

use rustc_ast as ast;
Expand Down Expand Up @@ -124,9 +124,7 @@ impl DefKind {
pub fn descr(self, def_id: DefId) -> &'static str {
match self {
DefKind::Fn => "function",
DefKind::Mod if def_id.index == CRATE_DEF_INDEX && def_id.krate != LOCAL_CRATE => {
"crate"
}
DefKind::Mod if def_id.is_crate_root() && !def_id.is_local() => "crate",
DefKind::Mod => "module",
DefKind::Static(..) => "static",
DefKind::Enum => "enum",
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_hir/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,6 @@ impl Definitions {
}
}

/// Retrieves the root definition.
pub fn get_root_def(&self) -> LocalDefId {
LocalDefId { local_def_index: CRATE_DEF_INDEX }
}

/// Adds a definition with a parent definition.
pub fn create_def(
&mut self,
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_hir/src/hir_id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::def_id::{LocalDefId, CRATE_DEF_INDEX};
use crate::def_id::{LocalDefId, CRATE_DEF_ID};
use std::fmt;

/// Uniquely identifies a node in the HIR of the current crate. It is
Expand Down Expand Up @@ -84,8 +84,5 @@ impl ItemLocalId {
pub const INVALID: ItemLocalId = ItemLocalId::MAX;
}

/// The `HirId` corresponding to `CRATE_NODE_ID` and `CRATE_DEF_INDEX`.
pub const CRATE_HIR_ID: HirId = HirId {
owner: LocalDefId { local_def_index: CRATE_DEF_INDEX },
local_id: ItemLocalId::from_u32(0),
};
/// The `HirId` corresponding to `CRATE_NODE_ID` and `CRATE_DEF_ID`.
pub const CRATE_HIR_ID: HirId = HirId { owner: CRATE_DEF_ID, local_id: ItemLocalId::from_u32(0) };
1 change: 0 additions & 1 deletion compiler/rustc_lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_feature = { path = "../rustc_feature" }
rustc_index = { path = "../rustc_index" }
rustc_session = { path = "../rustc_session" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_parse_format = { path = "../rustc_parse_format" }
rustc_infer = { path = "../rustc_infer" }
Loading