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 7 pull requests #138153

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
30703af
Enable `f16` for LoongArch
heiher Feb 26, 2025
2a4204b
Use default field values in `markdown::parse::Context`
estebank Mar 3, 2025
aae7a3c
Use default field values for `config::NextSolverConfig`
estebank Mar 3, 2025
0c4eaa5
Use default field values for `ErrorOutputType`
estebank Mar 3, 2025
039eb30
Fix a typo in the crashtest output.
nnethercote Mar 4, 2025
5dd8614
Pass `Option<Symbol>` to `def_path_data`/`create_def` methods.
nnethercote Mar 4, 2025
3ef8935
Make synthetic RPITIT assoc ty name handling more rigorous.
nnethercote Mar 4, 2025
8391c08
Revert #138019 after further discussion about adding this exception i…
jdonszelmann Mar 5, 2025
c5b7a9c
Factor out edge breaking code
tmiasko Mar 4, 2025
ccfbfe2
`x clippy src/librustdoc --fix`
yotamofek Mar 6, 2025
329b8a3
Implement `Ord` by-hand instead of `PartialOrd` for `Link`
yotamofek Mar 1, 2025
5d25922
Manual, post-`clippy --fix` cleanups
yotamofek Mar 1, 2025
5c1733e
Break critical edges in inline asm before code generation
tmiasko Mar 5, 2025
02d7fc1
Factor out check whether an unwind action generates invoke
tmiasko Mar 6, 2025
988eb19
library: Use size_of from the prelude instead of imported
thaliaarchi Mar 5, 2025
5dfa2f5
Use turbofish for size_of<T> and align_of<T> in docs
thaliaarchi Mar 5, 2025
3610020
Rollup merge of #137674 - heiher:enable-f16-loong, r=tgross35
matthiaskrgr Mar 7, 2025
6435304
Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino
matthiaskrgr Mar 7, 2025
caf03fd
Rollup merge of #138034 - thaliaarchi:use-prelude-size-of, r=tgross35
matthiaskrgr Mar 7, 2025
e928a26
Rollup merge of #138060 - jdonszelmann:revert-138019, r=compiler-errors
matthiaskrgr Mar 7, 2025
327ead3
Rollup merge of #138073 - tmiasko:inline-asm-critical-edges, r=bjorn3
matthiaskrgr Mar 7, 2025
d207e21
Rollup merge of #138107 - yotamofek:pr/rustdoc/clippy, r=GuillaumeGomez
matthiaskrgr Mar 7, 2025
774976a
Rollup merge of #138111 - estebank:use-dfv, r=nnethercote
matthiaskrgr Mar 7, 2025
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
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_middle::span_bug;
use rustc_middle::ty::TyCtxt;
use rustc_session::errors::report_lit_error;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
use visit::{Visitor, walk_expr};

Expand Down Expand Up @@ -483,7 +483,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
if legacy_args_idx.contains(&idx) {
let parent_def_id = self.current_hir_id_owner.def_id;
let node_id = self.next_node_id();
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
self.create_def(parent_def_id, node_id, None, DefKind::AnonConst, f.span);
let mut visitor = WillCreateDefIdsVisitor {};
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
AstP(Expr {
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&mut self,
parent: LocalDefId,
node_id: ast::NodeId,
name: Symbol,
name: Option<Symbol>,
def_kind: DefKind,
span: Span,
) -> LocalDefId {
Expand Down Expand Up @@ -774,7 +774,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let _def_id = self.create_def(
self.current_hir_id_owner.def_id,
param,
kw::UnderscoreLifetime,
Some(kw::UnderscoreLifetime),
DefKind::LifetimeParam,
ident.span,
);
Expand Down Expand Up @@ -2089,8 +2089,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// We're lowering a const argument that was originally thought to be a type argument,
// so the def collector didn't create the def ahead of time. That's why we have to do
// it here.
let def_id =
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, span);
let def_id = self.create_def(parent_def_id, node_id, None, DefKind::AnonConst, span);
let hir_id = self.lower_node_id(node_id);

let path_expr = Expr {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn intern_as_new_static<'tcx>(
) {
let feed = tcx.create_def(
static_id,
sym::nested,
Some(sym::nested),
DefKind::Static { safety: hir::Safety::Safe, mutability: alloc.0.mutability, nested: true },
);
tcx.set_nested_alloc_id_static(alloc_id, feed.def_id());
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#![feature(associated_type_defaults)]
#![feature(box_into_inner)]
#![feature(box_patterns)]
#![feature(default_field_values)]
#![feature(error_reporter)]
#![feature(if_let_guard)]
#![feature(let_chains)]
Expand Down
20 changes: 7 additions & 13 deletions compiler/rustc_errors/src/markdown/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ type ParseResult<'a> = Option<Parsed<'a>>;

/// Parsing context
#[derive(Clone, Copy, Debug, PartialEq)]
// The default values are the most common setting for non top-level parsing: not top block, not at
// line start (yes leading whitespace, not escaped).
struct Context {
/// If true, we are at a the topmost level (not recursing a nested tt)
top_block: bool,
top_block: bool = false,
/// Previous character
prev: Prev,
prev: Prev = Prev::Whitespace,
}

/// Character class preceding this one
Expand All @@ -57,14 +59,6 @@ enum Prev {
Any,
}

impl Default for Context {
/// Most common setting for non top-level parsing: not top block, not at
/// line start (yes leading whitespace, not escaped)
fn default() -> Self {
Self { top_block: false, prev: Prev::Whitespace }
}
}

/// Flags to simple parser function
#[derive(Clone, Copy, Debug, PartialEq)]
enum ParseOpt {
Expand Down Expand Up @@ -248,7 +242,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> {
}

let (txt, rest) = parse_to_newline(&buf[1..]);
let ctx = Context { top_block: false, prev: Prev::Whitespace };
let ctx = Context { .. };
let stream = parse_recursive(txt, ctx);

Some((MdTree::Heading(level.try_into().unwrap(), stream), rest))
Expand All @@ -257,7 +251,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> {
/// Bulleted list
fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> {
let (txt, rest) = get_indented_section(&buf[2..]);
let ctx = Context { top_block: false, prev: Prev::Whitespace };
let ctx = Context { .. };
let stream = parse_recursive(trim_ascii_start(txt), ctx);
(MdTree::UnorderedListItem(stream), rest)
}
Expand All @@ -266,7 +260,7 @@ fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> {
fn parse_ordered_li(buf: &[u8]) -> Parsed<'_> {
let (num, pos) = ord_list_start(buf).unwrap(); // success tested in caller
let (txt, rest) = get_indented_section(&buf[pos..]);
let ctx = Context { top_block: false, prev: Prev::Whitespace };
let ctx = Context { .. };
let stream = parse_recursive(trim_ascii_start(txt), ctx);
(MdTree::OrderedListItem(num, stream), rest)
}
Expand Down
18 changes: 12 additions & 6 deletions compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ impl DefKind {
}
}

pub fn def_path_data(self, name: Symbol) -> DefPathData {
// Some `DefKind`s require a name, some don't. Panics if one is needed but
// not provided. (`AssocTy` is an exception, see below.)
pub fn def_path_data(self, name: Option<Symbol>) -> DefPathData {
match self {
DefKind::Mod
| DefKind::Struct
Expand All @@ -264,9 +266,13 @@ impl DefKind {
| DefKind::TyAlias
| DefKind::ForeignTy
| DefKind::TraitAlias
| DefKind::AssocTy
| DefKind::TyParam
| DefKind::ExternCrate => DefPathData::TypeNs(name),
| DefKind::ExternCrate => DefPathData::TypeNs(Some(name.unwrap())),

// An associated type names will be missing for an RPITIT. It will
// later be given a name with `synthetic` in it, if necessary.
DefKind::AssocTy => DefPathData::TypeNs(name),

// It's not exactly an anon const, but wrt DefPathData, there
// is no difference.
DefKind::Static { nested: true, .. } => DefPathData::AnonConst,
Expand All @@ -276,9 +282,9 @@ impl DefKind {
| DefKind::Static { .. }
| DefKind::AssocFn
| DefKind::AssocConst
| DefKind::Field => DefPathData::ValueNs(name),
DefKind::Macro(..) => DefPathData::MacroNs(name),
DefKind::LifetimeParam => DefPathData::LifetimeNs(name),
| DefKind::Field => DefPathData::ValueNs(name.unwrap()),
DefKind::Macro(..) => DefPathData::MacroNs(name.unwrap()),
DefKind::LifetimeParam => DefPathData::LifetimeNs(name.unwrap()),
DefKind::Ctor(..) => DefPathData::Ctor,
DefKind::Use => DefPathData::Use,
DefKind::ForeignMod => DefPathData::ForeignMod,
Expand Down
22 changes: 13 additions & 9 deletions compiler/rustc_hir/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ pub enum DefPathData {
Use,
/// A global asm item.
GlobalAsm,
/// Something in the type namespace.
TypeNs(Symbol),
/// Something in the type namespace. Will be empty for RPITIT associated
/// types, which are given a synthetic name later, if necessary.
TypeNs(Option<Symbol>),
/// Something in the value namespace.
ValueNs(Symbol),
/// Something in the macro namespace.
Expand Down Expand Up @@ -410,8 +411,9 @@ impl DefPathData {
pub fn get_opt_name(&self) -> Option<Symbol> {
use self::DefPathData::*;
match *self {
TypeNs(name) if name == kw::Empty => None,
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
TypeNs(name) => name,

ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),

Impl | ForeignMod | CrateRoot | Use | GlobalAsm | Closure | Ctor | AnonConst
| OpaqueTy => None,
Expand All @@ -421,12 +423,14 @@ impl DefPathData {
pub fn name(&self) -> DefPathDataName {
use self::DefPathData::*;
match *self {
TypeNs(name) if name == kw::Empty => {
DefPathDataName::Anon { namespace: sym::synthetic }
}
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => {
DefPathDataName::Named(name)
TypeNs(name) => {
if let Some(name) = name {
DefPathDataName::Named(name)
} else {
DefPathDataName::Anon { namespace: sym::synthetic }
}
}
ValueNs(name) | MacroNs(name) | LifetimeNs(name) => DefPathDataName::Named(name),
// Note that this does not show up in user print-outs.
CrateRoot => DefPathDataName::Anon { namespace: kw::Crate },
Impl => DefPathDataName::Anon { namespace: kw::Impl },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
for &(opaque_def_id, captures) in opaque_capture_scopes.iter().rev() {
let mut captures = captures.borrow_mut();
let remapped = *captures.entry(lifetime).or_insert_with(|| {
let feed = self.tcx.create_def(opaque_def_id, ident.name, DefKind::LifetimeParam);
let feed =
self.tcx.create_def(opaque_def_id, Some(ident.name), DefKind::LifetimeParam);
feed.def_span(ident.span);
feed.def_ident_span(Some(ident.span));
feed.def_id()
Expand Down
74 changes: 0 additions & 74 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,80 +117,6 @@ impl<'a> State<'a> {
));
self.hardbreak()
}
hir::Attribute::Parsed(AttributeKind::Deprecation { deprecation, .. }) => {
self.word("#[deprecated");

// There are three possible forms here:
// 1. a form with explicit components like
// `#[deprecated(since = "1.2.3", note = "some note", suggestion = "something")]`
// where each component may be present or absent.
// 2. `#[deprecated = "message"]`
// 3. `#[deprecated]`
//
// Let's figure out which we need.
// If there's a `since` or `suggestion` value, we're definitely in form 1.
if matches!(
deprecation.since,
rustc_attr_parsing::DeprecatedSince::RustcVersion(..)
| rustc_attr_parsing::DeprecatedSince::Future
| rustc_attr_parsing::DeprecatedSince::NonStandard(..)
) || deprecation.suggestion.is_some()
{
self.word("(");
let mut use_comma = false;

match &deprecation.since {
rustc_attr_parsing::DeprecatedSince::RustcVersion(rustc_version) => {
self.word("since = \"");
self.word(format!(
"{}.{}.{}",
rustc_version.major, rustc_version.minor, rustc_version.patch
));
self.word("\"");
use_comma = true;
}
rustc_attr_parsing::DeprecatedSince::Future => {
self.word("since = \"future\"");
use_comma = true;
}
rustc_attr_parsing::DeprecatedSince::NonStandard(symbol) => {
self.word("since = \"");
self.word(symbol.to_ident_string());
self.word("\"");
use_comma = true;
}
_ => {}
}

if let Some(note) = &deprecation.note {
if use_comma {
self.word(", ");
}
self.word("note = \"");
self.word(note.to_ident_string());
self.word("\"");
use_comma = true;
}

if let Some(suggestion) = &deprecation.suggestion {
if use_comma {
self.word(", ");
}
self.word("suggestion = \"");
self.word(suggestion.to_ident_string());
self.word("\"");
}
} else if let Some(note) = &deprecation.note {
// We're in form 2: `#[deprecated = "message"]`.
self.word(" = \"");
self.word(note.to_ident_string());
self.word("\"");
} else {
// We're in form 3: `#[deprecated]`. Nothing to do here.
}

self.word("]");
}
hir::Attribute::Parsed(pa) => {
self.word("#[attr=\"");
pa.print_attribute(self);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
pub fn create_def(
self,
parent: LocalDefId,
name: Symbol,
name: Option<Symbol>,
def_kind: DefKind,
) -> TyCtxtFeed<'tcx, LocalDefId> {
let feed = self.tcx.create_def(parent, name, def_kind);
Expand All @@ -1905,7 +1905,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn create_def(
self,
parent: LocalDefId,
name: Symbol,
name: Option<Symbol>,
def_kind: DefKind,
) -> TyCtxtFeed<'tcx, LocalDefId> {
let data = def_kind.def_path_data(name);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
// the children of the visible parent (as was done when computing
// `visible_parent_map`), looking for the specific child we currently have and then
// have access to the re-exported name.
DefPathData::TypeNs(ref mut name) if Some(visible_parent) != actual_parent => {
DefPathData::TypeNs(Some(ref mut name)) if Some(visible_parent) != actual_parent => {
// Item might be re-exported several times, but filter for the one
// that's public and whose identifier isn't `_`.
let reexport = self
Expand All @@ -590,7 +590,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}
// Re-exported `extern crate` (#43189).
DefPathData::CrateRoot => {
data = DefPathData::TypeNs(self.tcx().crate_name(def_id.krate));
data = DefPathData::TypeNs(Some(self.tcx().crate_name(def_id.krate)));
}
_ => {}
}
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/ty/significant_drop_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ fn true_significant_drop_ty<'tcx>(

match key.disambiguated_data.data {
rustc_hir::definitions::DefPathData::CrateRoot => {
name_rev.push(tcx.crate_name(did.krate))
name_rev.push(tcx.crate_name(did.krate));
}
rustc_hir::definitions::DefPathData::TypeNs(symbol) => {
name_rev.push(symbol.unwrap());
}
rustc_hir::definitions::DefPathData::TypeNs(symbol) => name_rev.push(symbol),
_ => return None,
}
if let Some(parent) = key.parent {
Expand Down
Loading
Loading