Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 0 additions & 17 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3892,8 +3892,6 @@ dependencies = [
"icu_list",
"icu_locale",
"intl-memoizer",
"rustc_ast",
"rustc_ast_pretty",
"rustc_baked_icu_data",
"rustc_data_structures",
"rustc_macros",
Expand All @@ -3910,7 +3908,6 @@ dependencies = [
"anstream",
"anstyle",
"derive_setters",
"rustc_ast",
"rustc_data_structures",
"rustc_error_codes",
"rustc_error_messages",
Expand Down Expand Up @@ -3996,7 +3993,6 @@ dependencies = [
"rustc_data_structures",
"rustc_error_messages",
"rustc_hashes",
"rustc_hir_id",
"rustc_index",
"rustc_lint_defs",
"rustc_macros",
Expand Down Expand Up @@ -4033,17 +4029,6 @@ dependencies = [
"tracing",
]

[[package]]
name = "rustc_hir_id"
version = "0.0.0"
dependencies = [
"rustc_data_structures",
"rustc_index",
"rustc_macros",
"rustc_serialize",
"rustc_span",
]

[[package]]
name = "rustc_hir_pretty"
version = "0.0.0"
Expand Down Expand Up @@ -4224,10 +4209,8 @@ dependencies = [
name = "rustc_lint_defs"
version = "0.0.0"
dependencies = [
"rustc_ast",
"rustc_data_structures",
"rustc_error_messages",
"rustc_hir_id",
"rustc_macros",
"rustc_serialize",
"rustc_span",
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::tagged_ptr::Tag;
use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable};
pub use rustc_span::AttrId;
pub use rustc_span::node_id::{self, CRATE_NODE_ID, DUMMY_NODE_ID, NodeId};
use rustc_span::{
ByteSymbol, DUMMY_SP, ErrorGuaranteed, HashStableContext, Ident, Span, Spanned, Symbol, kw,
respan, sym,
Expand Down Expand Up @@ -370,8 +371,6 @@ impl ParenthesizedArgs {
}
}

pub use crate::node_id::{CRATE_NODE_ID, DUMMY_NODE_ID, NodeId};

/// Modifiers on a trait bound like `[const]`, `?` and `!`.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Walkable)]
pub struct TraitBoundModifiers {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub mod entry;
pub mod expand;
pub mod format;
pub mod mut_visit;
pub mod node_id;
pub mod token;
pub mod tokenstream;
pub mod visit;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,8 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
dcx.emit_err(errors::OutOfOrderParams {
spans: spans.clone(),
sugg_span: span,
param_ord,
max_param,
param_ord: param_ord.to_string(),
max_param: max_param.to_string(),
ordered_params: &ordered_params,
});
}
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Errors emitted by ast_passes.

use rustc_abi::ExternAbi;
use rustc_ast::ParamKindOrd;
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
use rustc_macros::{Diagnostic, Subdiagnostic};
Expand Down Expand Up @@ -632,8 +631,8 @@ pub(crate) struct OutOfOrderParams<'a> {
applicability = "machine-applicable"
)]
pub sugg_span: Span,
pub param_ord: &'a ParamKindOrd,
pub max_param: &'a ParamKindOrd,
pub param_ord: String,
pub max_param: String,
pub ordered_params: &'a str,
}

Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_builtin_macros/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::env::VarError;
use rustc_ast::token::{self, LitKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{ExprKind, GenericArg, Mutability};
use rustc_ast_pretty::pprust;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_span::edit_distance::edit_distance;
use rustc_span::{Ident, Span, Symbol, kw, sym};
Expand Down Expand Up @@ -158,13 +159,13 @@ pub(crate) fn expand_env<'cx>(
cx.dcx().emit_err(errors::EnvNotDefined::CargoEnvVar {
span,
var: *symbol,
var_expr: &var_expr,
var_expr: pprust::expr_to_string(&var_expr),
})
} else {
cx.dcx().emit_err(errors::EnvNotDefined::CustomEnvVar {
span,
var: *symbol,
var_expr: &var_expr,
var_expr: pprust::expr_to_string(&var_expr),
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for EnvNotDefinedWithUserMessag
}

#[derive(Diagnostic)]
pub(crate) enum EnvNotDefined<'a> {
pub(crate) enum EnvNotDefined {
#[diag("environment variable `{$var}` not defined at compile time")]
#[help("`{$var}` may not be available for the current Cargo target")]
#[help(
Expand All @@ -563,7 +563,7 @@ pub(crate) enum EnvNotDefined<'a> {
#[primary_span]
span: Span,
var: Symbol,
var_expr: &'a rustc_ast::Expr,
var_expr: String,
},
#[diag("environment variable `{$var}` not defined at compile time")]
#[help("there is a similar Cargo environment variable: `{$suggested_var}`")]
Expand All @@ -579,7 +579,7 @@ pub(crate) enum EnvNotDefined<'a> {
#[primary_span]
span: Span,
var: Symbol,
var_expr: &'a rustc_ast::Expr,
var_expr: String,
},
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/intrinsic/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
return_error!(InvalidMonomorphization::FloatingPointVector {
span,
name,
f_ty: *f,
f_ty: f.name_str().to_string(),
in_ty
});
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use rustc_errors::{
Level, msg,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutError;
use rustc_middle::ty::{FloatTy, Ty};
use rustc_span::{Span, Symbol};

use crate::assert_module_sources::CguReuse;
Expand Down Expand Up @@ -729,7 +729,7 @@ pub enum InvalidMonomorphization<'tcx> {
#[primary_span]
span: Span,
name: Symbol,
f_ty: FloatTy,
f_ty: String,
in_ty: Ty<'tcx>,
},

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_error_messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ fluent-bundle = "0.16"
icu_list = { version = "2.0", default-features = false, features = ["alloc"] }
icu_locale = { version = "2.0", default-features = false }
intl-memoizer = "0.5.1"
rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_baked_icu_data = { path = "../rustc_baked_icu_data" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_macros = { path = "../rustc_macros" }
Expand Down
47 changes: 0 additions & 47 deletions compiler/rustc_error_messages/src/diagnostic_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use std::num::ParseIntError;
use std::path::{Path, PathBuf};
use std::process::ExitStatus;

use rustc_ast as ast;
use rustc_ast_pretty::pprust;
use rustc_span::edition::Edition;

use crate::{DiagArgValue, IntoDiagArg};
Expand Down Expand Up @@ -69,7 +67,6 @@ macro_rules! into_diag_arg_for_number {
}

into_diag_arg_using_display!(
ast::ParamKindOrd,
std::io::Error,
Box<dyn std::error::Error>,
std::num::NonZero<u32>,
Expand Down Expand Up @@ -142,30 +139,6 @@ impl IntoDiagArg for PathBuf {
}
}

impl IntoDiagArg for ast::Expr {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(pprust::expr_to_string(&self)))
}
}

impl IntoDiagArg for ast::Path {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(pprust::path_to_string(&self)))
}
}

impl IntoDiagArg for ast::token::Token {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(pprust::token_to_string(&self))
}
}

impl IntoDiagArg for ast::token::TokenKind {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(pprust::token_kind_to_string(&self))
}
}

impl IntoDiagArg for std::ffi::CString {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned()))
Expand All @@ -178,28 +151,8 @@ impl IntoDiagArg for rustc_data_structures::small_c_str::SmallCStr {
}
}

impl IntoDiagArg for ast::Visibility {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
let s = pprust::vis_to_string(&self);
let s = s.trim_end().to_string();
DiagArgValue::Str(Cow::Owned(s))
}
}

impl IntoDiagArg for Backtrace {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(Cow::from(self.to_string()))
}
}

impl IntoDiagArg for ast::util::parser::ExprPrecedence {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Number(self as i32)
}
}

impl IntoDiagArg for ast::FloatTy {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.name_str()))
}
}
1 change: 0 additions & 1 deletion compiler/rustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ annotate-snippets = { version = "0.12.15", features = ["simd"] }
anstream = "0.6.20"
anstyle = "1.0.13"
derive_setters = "0.1.6"
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_codes = { path = "../rustc_error_codes" }
rustc_error_messages = { path = "../rustc_error_messages" }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/decorate_diag.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::any::Any;

/// This module provides types and traits for buffering lints until later in compilation.
use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_error_messages::MultiSpan;
use rustc_lint_defs::{AttributeLintKind, Lint, LintId};
/// This module provides types and traits for buffering lints until later in compilation.
use rustc_span::node_id::NodeId;

use crate::{Diag, DiagCtxtHandle, Diagnostic, Level};

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::borrow::Cow;

use rustc_ast::ast;
use rustc_errors::codes::*;
use rustc_hir::limit::Limit;
use rustc_macros::{Diagnostic, Subdiagnostic};
Expand Down Expand Up @@ -230,7 +229,7 @@ pub(crate) struct WrongFragmentKind<'a> {
#[primary_span]
pub span: Span,
pub kind: &'a str,
pub name: &'a ast::Path,
pub name: String,
}

#[derive(Diagnostic)]
Expand All @@ -249,7 +248,7 @@ pub(crate) struct IncompleteParse<'a> {
pub descr: String,
#[label("caused by the macro expansion here")]
pub label_span: Span,
pub macro_path: &'a ast::Path,
pub macro_path: String,
pub kind_name: &'a str,
#[note("macros cannot expand to match arms")]
pub expands_to_match_arm: bool,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
mac: &ast::MacCall,
span: Span,
) -> ErrorGuaranteed {
let guar =
self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name: &mac.path });
let name = pprust::path_to_string(&mac.path);
let guar = self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name });
self.cx.macro_error_and_trace_macros_diag();
guar
}
Expand Down Expand Up @@ -1218,7 +1218,7 @@ pub(crate) fn ensure_complete_parse<'a>(
span: def_site_span,
descr,
label_span: span,
macro_path,
macro_path: pprust::path_to_string(macro_path),
kind_name,
expands_to_match_arm,
add_semicolon,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_messages = { path = "../rustc_error_messages" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir_id = { path = "../rustc_hir_id" }
rustc_index = { path = "../rustc_index" }
rustc_lint_defs = { path = "../rustc_lint_defs" }
rustc_macros = { path = "../rustc_macros" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl DefKind {
/// pointing to the definition of `str_to_string` in the current crate.
//
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
pub enum Res<Id = hir::HirId> {
pub enum Res<Id = crate::def_id::HirId> {
/// Definition having a unique ID (`DefId`), corresponds to something defined in user code.
///
/// **Not bound to a specific namespace.**
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ use tracing::debug;

use crate::attrs::AttributeKind;
use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res};
use crate::def_id::{DefId, LocalDefIdMap};
pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
use crate::def_id::{DefId, HirId, ItemLocalId, ItemLocalMap, LocalDefIdMap, OwnerId};
use crate::intravisit::{FnKind, VisitorExt};
use crate::lints::DelayedLints;

Expand Down Expand Up @@ -4794,7 +4793,7 @@ impl<'hir> OwnerNode<'hir> {
| OwnerNode::TraitItem(TraitItem { owner_id, .. })
| OwnerNode::ImplItem(ImplItem { owner_id, .. })
| OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
OwnerNode::Crate(..) => crate::def_id::CRATE_HIR_ID.owner,
OwnerNode::Synthetic => unreachable!(),
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ use rustc_ast::visit::{VisitorResult, try_visit, visit_opt, walk_list};
use rustc_span::def_id::LocalDefId;
use rustc_span::{Ident, Span, Symbol};

use crate::def_id::HirId;
use crate::hir::*;

pub trait IntoVisitor<'hir> {
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ pub mod def_path_hash_map;
pub mod definitions;
pub mod diagnostic_items;
pub use rustc_span::def_id;
pub use rustc_span::def_id::{
CRATE_HIR_ID, CRATE_OWNER_ID, HirId, HirIdMap, HirIdMapEntry, HirIdSet, ItemLocalId,
ItemLocalMap, ItemLocalMapEntry, ItemLocalSet, OwnerId,
};
mod hir;
pub use rustc_hir_id::{self as hir_id, *};
pub mod intravisit;
pub mod lang_items;
pub mod limit;
Expand Down
Loading
Loading