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 #118893

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a48cebc
Coroutine variant fields can be uninitialized
tmiasko Dec 12, 2023
fb32eb3
Clean up CodeBlocks::next code
GuillaumeGomez Dec 12, 2023
e9b16cc
rustc_passes: Enforce `rustc::potential_query_instability` lint
Enselic Dec 12, 2023
d3cb25f
Add `rustX` check to codeblock attributes lint
GuillaumeGomez Dec 12, 2023
98aa20b
Add test for `rustX` codeblock attribute
GuillaumeGomez Dec 12, 2023
bb0fd66
Follow guidelines for lint suggestions
GuillaumeGomez Dec 12, 2023
6892fcd
simplify merging of two vecs
matthiaskrgr Dec 12, 2023
d707461
clippy::complexity fixes
matthiaskrgr Dec 12, 2023
f1342f3
Clean up variables in `search.js`
GuillaumeGomez Dec 12, 2023
58327c1
Add a test for a codeblock with multiple invalid attributes
GuillaumeGomez Dec 12, 2023
046f2de
Typo
smoelius Dec 12, 2023
2a1acc2
Update compiler/rustc_pattern_analysis/src/constructor.rs
matthiaskrgr Dec 12, 2023
5ae76ae
Rollup merge of #118870 - Enselic:rustc_passes-query-stability, r=com…
GuillaumeGomez Dec 12, 2023
a5bd88b
Rollup merge of #118871 - tmiasko:coroutine-maybe-uninit-fields, r=co…
GuillaumeGomez Dec 12, 2023
57d8f24
Rollup merge of #118872 - GuillaumeGomez:codeblock-attr-lint, r=notri…
GuillaumeGomez Dec 12, 2023
a0c6c64
Rollup merge of #118884 - matthiaskrgr:auszweimacheins, r=Nadrieril
GuillaumeGomez Dec 12, 2023
244429d
Rollup merge of #118885 - matthiaskrgr:compl_2023, r=compiler-errors
GuillaumeGomez Dec 12, 2023
c8755d8
Rollup merge of #118886 - GuillaumeGomez:clean-up-search-vars, r=notr…
GuillaumeGomez Dec 12, 2023
ee9b563
Rollup merge of #118887 - smoelius:patch-1, r=Nilstrieb
GuillaumeGomez Dec 12, 2023
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
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
/// `read_discriminant` can be hooked for better error messages.
#[inline(always)]
fn read_discriminant(&mut self, v: &Self::V) -> InterpResult<'tcx, VariantIdx> {
Ok(self.ecx().read_discriminant(&v.to_op(self.ecx())?)?)
self.ecx().read_discriminant(&v.to_op(self.ecx())?)
}

/// This function provides the chance to reorder the order in which fields are visited for
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,8 @@ fn show_md_content_with_pager(content: &str, color: ColorConfig) {
let mut print_formatted = if pager_name == "less" {
cmd.arg("-r");
true
} else if ["bat", "catbat", "delta"].iter().any(|v| *v == pager_name) {
true
} else {
false
["bat", "catbat", "delta"].iter().any(|v| *v == pager_name)
};

if color == ColorConfig::Never {
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_hir_analysis/src/collect/item_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,14 @@ fn associated_type_bounds<'tcx>(
let trait_def_id = tcx.local_parent(assoc_item_def_id);
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);

let bounds_from_parent = trait_predicates
.predicates
.iter()
.copied()
.filter(|(pred, _)| match pred.kind().skip_binder() {
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
match pred.kind().skip_binder() {
ty::ClauseKind::Trait(tr) => tr.self_ty() == item_ty,
ty::ClauseKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
ty::ClauseKind::TypeOutlives(outlives) => outlives.0 == item_ty,
_ => false,
})
.map(|(clause, span)| (clause, span));
}
});

let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
debug!(
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_hir_typeck/src/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let final_tupled_upvars_type = Ty::new_tup(self.tcx, &final_upvar_tys);
self.demand_suptype(span, args.tupled_upvars_ty(), final_tupled_upvars_type);

let fake_reads = delegate
.fake_reads
.into_iter()
.map(|(place, cause, hir_id)| (place, cause, hir_id))
.collect();
let fake_reads = delegate.fake_reads;

self.typeck_results.borrow_mut().closure_fake_reads.insert(closure_def_id, fake_reads);

if self.tcx.sess.opts.unstable_opts.profile_closures {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/jump_threading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ impl OpportunitySet {

// `succ` must be a successor of `current`. If it is not, this means this TO is not
// satisfiable and a previous TO erased this edge, so we bail out.
if basic_blocks[current].terminator().successors().find(|s| *s == succ).is_none() {
if !basic_blocks[current].terminator().successors().any(|s| s == succ) {
debug!("impossible");
return;
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_passes/src/diagnostic_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {

// Collect diagnostic items in other crates.
for &cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
// We are collecting many DiagnosticItems hash maps into one
// DiagnosticItems hash map. The iteration order does not matter.
#[allow(rustc::potential_query_instability)]
for (&name, &def_id) in &tcx.diagnostic_items(cnum).name_to_id {
collect_item(tcx, &mut items, name, def_id);
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_passes/src/hir_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ impl<'k> StatCollector<'k> {
}

fn print(&self, title: &str, prefix: &str) {
// We will soon sort, so the initial order does not matter.
#[allow(rustc::potential_query_instability)]
let mut nodes: Vec<_> = self.nodes.iter().collect();
nodes.sort_by_key(|(_, node)| node.stats.count * node.stats.size);

Expand All @@ -147,6 +149,8 @@ impl<'k> StatCollector<'k> {
to_readable_str(node.stats.size)
);
if !node.subnodes.is_empty() {
// We will soon sort, so the initial order does not matter.
#[allow(rustc::potential_query_instability)]
let mut subnodes: Vec<_> = node.subnodes.iter().collect();
subnodes.sort_by_key(|(_, subnode)| subnode.count * subnode.size);

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//!
//! This API is completely unstable and subject to change.

#![allow(rustc::potential_query_instability)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,9 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
tcx.sess.emit_err(errors::UnknownFeature { span, feature: *feature });
}

// We only use the hash map contents to emit errors, and the order of
// emitted errors do not affect query stability.
#[allow(rustc::potential_query_instability)]
for (implied_by, feature) in remaining_implications {
let local_defined_features = tcx.lib_features(LOCAL_CRATE);
let span = local_defined_features
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_pattern_analysis/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,8 @@ impl ConstructorSet {
&& !(pcx.is_top_level && matches!(self, Self::NoConstructors))
{
// Treat all missing constructors as nonempty.
missing.extend(missing_empty.drain(..));
// This clears `missing_empty`.
missing.append(&mut missing_empty);
}

SplitConstructorSet { present, missing, missing_empty }
Expand Down
14 changes: 1 addition & 13 deletions compiler/rustc_query_system/src/dep_graph/serialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const DEP_NODE_PAD: usize = DEP_NODE_SIZE - 1;
const DEP_NODE_WIDTH_BITS: usize = DEP_NODE_SIZE / 2;

/// Data for use when recompiling the **current crate**.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct SerializedDepGraph {
/// The set of all DepNodes in the graph
nodes: IndexVec<SerializedDepNodeIndex, DepNode>,
Expand All @@ -89,18 +89,6 @@ pub struct SerializedDepGraph {
index: Vec<UnhashMap<PackedFingerprint, SerializedDepNodeIndex>>,
}

impl Default for SerializedDepGraph {
fn default() -> Self {
SerializedDepGraph {
nodes: Default::default(),
fingerprints: Default::default(),
edge_list_indices: Default::default(),
edge_list_data: Default::default(),
index: Default::default(),
}
}
}

impl SerializedDepGraph {
#[inline]
pub fn edge_targets_from(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
let (span, text) = match path.segments.first() {
Some(seg) if let Some(name) = seg.ident.as_str().strip_prefix("let") => {
// a special case for #117894
let name = name.strip_prefix("_").unwrap_or(name);
let name = name.strip_prefix('_').unwrap_or(name);
(ident_span, format!("let {name}"))
}
_ => (ident_span.shrink_to_lo(), "let ".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_smir/src/rustc_smir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
(name == crate_name).then(|| smir_crate(tables.tcx, *crate_num))
})
.into_iter()
.filter_map(|c| c)
.flatten()
.collect();
crates
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
// _ZTSFvu27NvNtC1234_5crate6Trait13fooIu22NtC1234_5crate7Struct1Iu3i32ES_EE
//
// The reason for not using v0's extended form of paths is to use a consistent and simpler
// encoding, as the reasoning for using it isn't relevand for type metadata identifiers (i.e.,
// encoding, as the reasoning for using it isn't relevant for type metadata identifiers (i.e.,
// keep symbol names close to how methods are represented in error messages). See
// https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html#methods.
let mut s = String::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
if !self.tcx.is_diagnostic_item(sym::Result, def.did()) {
return None;
}
Some(arg.as_type()?)
arg.as_type()
};

let mut suggested = false;
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_ty_utils/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,10 @@ fn coroutine_layout<'tcx>(
Assigned(_) => bug!("assignment does not match variant"),
Ineligible(_) => false,
})
.map(|local| subst_field(info.field_tys[*local].ty));
.map(|local| {
let field_ty = subst_field(info.field_tys[*local].ty);
Ty::new_maybe_uninit(tcx, field_ty)
});

let mut variant = univariant_uninterned(
cx,
Expand Down
99 changes: 56 additions & 43 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! ```

use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_errors::{DiagnosticBuilder, DiagnosticMessage};
use rustc_hir::def_id::DefId;
use rustc_middle::ty::TyCtxt;
pub(crate) use rustc_resolve::rustdoc::main_body_opts;
Expand Down Expand Up @@ -234,10 +234,6 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {

fn next(&mut self) -> Option<Self::Item> {
let event = self.inner.next();
let compile_fail;
let should_panic;
let ignore;
let edition;
let Some(Event::Start(Tag::CodeBlock(kind))) = event else {
return event;
};
Expand All @@ -253,49 +249,44 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
}
}

let parse_result = match kind {
CodeBlockKind::Fenced(ref lang) => {
let parse_result = LangString::parse_without_check(
lang,
self.check_error_codes,
false,
self.custom_code_classes_in_docs,
);
if !parse_result.rust {
let added_classes = parse_result.added_classes;
let lang_string = if let Some(lang) = parse_result.unknown.first() {
format!("language-{}", lang)
} else {
String::new()
};
let whitespace = if added_classes.is_empty() { "" } else { " " };
return Some(Event::Html(
format!(
"<div class=\"example-wrap\">\
let LangString { added_classes, compile_fail, should_panic, ignore, edition, .. } =
match kind {
CodeBlockKind::Fenced(ref lang) => {
let parse_result = LangString::parse_without_check(
lang,
self.check_error_codes,
false,
self.custom_code_classes_in_docs,
);
if !parse_result.rust {
let added_classes = parse_result.added_classes;
let lang_string = if let Some(lang) = parse_result.unknown.first() {
format!("language-{}", lang)
} else {
String::new()
};
let whitespace = if added_classes.is_empty() { "" } else { " " };
return Some(Event::Html(
format!(
"<div class=\"example-wrap\">\
<pre class=\"{lang_string}{whitespace}{added_classes}\">\
<code>{text}</code>\
</pre>\
</div>",
added_classes = added_classes.join(" "),
text = Escape(&original_text),
)
.into(),
));
added_classes = added_classes.join(" "),
text = Escape(&original_text),
)
.into(),
));
}
parse_result
}
parse_result
}
CodeBlockKind::Indented => Default::default(),
};
CodeBlockKind::Indented => Default::default(),
};

let added_classes = parse_result.added_classes;
let lines = original_text.lines().filter_map(|l| map_line(l).for_html());
let text = lines.intersperse("\n".into()).collect::<String>();

compile_fail = parse_result.compile_fail;
should_panic = parse_result.should_panic;
ignore = parse_result.ignore;
edition = parse_result.edition;

let explicit_edition = edition.is_some();
let edition = edition.unwrap_or(self.edition);

Expand Down Expand Up @@ -852,15 +843,17 @@ impl<'tcx> ExtraInfo<'tcx> {
fn error_invalid_codeblock_attr_with_help(
&self,
msg: impl Into<DiagnosticMessage>,
help: impl Into<SubdiagnosticMessage>,
f: impl for<'a, 'b> FnOnce(
&'b mut DiagnosticBuilder<'a, ()>,
) -> &'b mut DiagnosticBuilder<'a, ()>,
) {
if let Some(def_id) = self.def_id.as_local() {
self.tcx.struct_span_lint_hir(
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
self.tcx.local_def_id_to_hir_id(def_id),
self.sp,
msg,
|lint| lint.help(help),
f,
);
}
}
Expand Down Expand Up @@ -1293,6 +1286,21 @@ impl LangString {
LangStringToken::LangToken(x) if x.starts_with("edition") => {
data.edition = x[7..].parse::<Edition>().ok();
}
LangStringToken::LangToken(x)
if x.starts_with("rust") && x[4..].parse::<Edition>().is_ok() =>
{
if let Some(extra) = extra {
extra.error_invalid_codeblock_attr_with_help(
format!("unknown attribute `{x}`"),
|lint| {
lint.help(format!(
"there is an attribute with a similar name: `edition{}`",
&x[4..],
))
},
);
}
}
LangStringToken::LangToken(x)
if allow_error_code_check && x.starts_with('E') && x.len() == 5 =>
{
Expand Down Expand Up @@ -1337,8 +1345,13 @@ impl LangString {
} {
if let Some(extra) = extra {
extra.error_invalid_codeblock_attr_with_help(
format!("unknown attribute `{x}`. Did you mean `{flag}`?"),
help,
format!("unknown attribute `{x}`"),
|lint| {
lint.help(format!(
"there is an attribute with a similar name: `{flag}`"
))
.help(help)
},
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/render/type_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub(crate) fn document_type_layout<'a, 'cx: 'a>(
TypeLayoutSize { is_unsized, is_uninhabited, size }
});

Ok(TypeLayout { variants, type_layout_size }.render_into(f).unwrap())
TypeLayout { variants, type_layout_size }.render_into(f).unwrap();
Ok(())
})
}
Loading
Loading