1
Fork 0

Auto merge of #135896 - matthiaskrgr:rollup-g6rv7za, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #132983 (Edit dangling pointers )
 - #135409 (Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block)
 - #135557 (Point at invalid utf-8 span on user's source code)
 - #135596 (Properly note when query stack is being cut off)
 - #135794 (Detect missing fields with default values and suggest `..`)
 - #135814 (ci: use ghcr buildkit image)
 - #135826 (Misc. `rustc_resolve` cleanups)
 - #135837 (Remove test panic from File::open)
 - #135856 (Library: Finalize dyn compatibility renaming)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-22 22:19:08 +00:00
commit a30f9151fe
55 changed files with 1081 additions and 684 deletions

View file

@ -16,6 +16,7 @@
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![feature(rustdoc_internals)]
#![feature(string_from_utf8_lossy_owned)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end

View file

@ -13,7 +13,7 @@ use rustc_expand::base::{
use rustc_expand::module::DirOwnership;
use rustc_lint_defs::BuiltinLintDiag;
use rustc_parse::parser::{ForceCollect, Parser};
use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal};
use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal, utf8_error};
use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
use rustc_span::source_map::SourceMap;
use rustc_span::{Pos, Span, Symbol};
@ -209,9 +209,10 @@ pub(crate) fn expand_include_str(
let interned_src = Symbol::intern(src);
MacEager::expr(cx.expr_str(cx.with_def_site_ctxt(bsp), interned_src))
}
Err(_) => {
let guar = cx.dcx().span_err(sp, format!("`{path}` wasn't a utf-8 file"));
DummyResult::any(sp, guar)
Err(utf8err) => {
let mut err = cx.dcx().struct_span_err(sp, format!("`{path}` wasn't a utf-8 file"));
utf8_error(cx.source_map(), path.as_str(), None, &mut err, utf8err, &bytes[..]);
DummyResult::any(sp, err.emit())
}
},
Err(dummy) => dummy,
@ -273,7 +274,7 @@ fn load_binary_file(
.and_then(|path| path.into_os_string().into_string().ok());
if let Some(new_path) = new_path {
err.span_suggestion(
err.span_suggestion_verbose(
path_span,
"there is a file with the same name in a different directory",
format!("\"{}\"", new_path.replace('\\', "/").escape_debug()),

View file

@ -1528,9 +1528,9 @@ fn report_ice(
// If backtraces are enabled, also print the query stack
let backtrace = env::var_os("RUST_BACKTRACE").is_some_and(|x| &x != "0");
let num_frames = if backtrace { None } else { Some(2) };
let limit_frames = if backtrace { None } else { Some(2) };
interface::try_print_query_stack(dcx, num_frames, file);
interface::try_print_query_stack(dcx, limit_frames, file);
// We don't trust this callback not to panic itself, so run it at the end after we're sure we've
// printed all the relevant info.

View file

@ -2349,6 +2349,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.report_missing_fields(
adt_ty,
path_span,
expr.span,
remaining_fields,
variant,
hir_fields,
@ -2386,6 +2387,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self,
adt_ty: Ty<'tcx>,
span: Span,
full_span: Span,
remaining_fields: UnordMap<Ident, (FieldIdx, &ty::FieldDef)>,
variant: &'tcx ty::VariantDef,
hir_fields: &'tcx [hir::ExprField<'tcx>],
@ -2425,6 +2427,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
err.span_label(span, format!("missing {remaining_fields_names}{truncated_fields_error}"));
if remaining_fields.items().all(|(_, (_, field))| field.value.is_some())
&& self.tcx.sess.is_nightly_build()
{
let msg = format!(
"all remaining fields have default values, {you_can} use those values with `..`",
you_can = if self.tcx.features().default_field_values() {
"you can"
} else {
"if you added `#![feature(default_field_values)]` to your crate you could"
},
);
if let Some(hir_field) = hir_fields.last() {
err.span_suggestion_verbose(
hir_field.span.shrink_to_hi(),
msg,
", ..".to_string(),
Applicability::MachineApplicable,
);
} else if hir_fields.is_empty() {
err.span_suggestion_verbose(
span.shrink_to_hi().with_hi(full_span.hi()),
msg,
" { .. }".to_string(),
Applicability::MachineApplicable,
);
}
}
if let Some(hir_field) = hir_fields.last() {
self.suggest_fru_from_range_and_emit(hir_field, variant, args, err);
} else {

View file

@ -533,7 +533,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
pub fn try_print_query_stack(
dcx: DiagCtxtHandle<'_>,
num_frames: Option<usize>,
limit_frames: Option<usize>,
file: Option<std::fs::File>,
) {
eprintln!("query stack during panic:");
@ -541,13 +541,13 @@ pub fn try_print_query_stack(
// Be careful relying on global state here: this code is called from
// a panic hook, which means that the global `DiagCtxt` may be in a weird
// state if it was responsible for triggering the panic.
let i = ty::tls::with_context_opt(|icx| {
let all_frames = ty::tls::with_context_opt(|icx| {
if let Some(icx) = icx {
ty::print::with_no_queries!(print_query_stack(
QueryCtxt::new(icx.tcx),
icx.query,
dcx,
num_frames,
limit_frames,
file,
))
} else {
@ -555,9 +555,14 @@ pub fn try_print_query_stack(
}
});
if num_frames == None || num_frames >= Some(i) {
eprintln!("end of query stack");
if let Some(limit_frames) = limit_frames
&& all_frames > limit_frames
{
eprintln!(
"... and {} other queries... use `env RUST_BACKTRACE=1` to see the full query stack",
all_frames - limit_frames
);
} else {
eprintln!("we're just showing a limited slice of the query stack");
eprintln!("end of query stack");
}
}

View file

@ -209,7 +209,9 @@ lint_dangling_pointers_from_temporaries = a dangling pointer will be produced be
.label_ptr = this pointer will immediately be invalid
.label_temporary = this `{$ty}` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
.note = pointers do not have a lifetime; when calling `{$callee}` the `{$ty}` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
.help = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
.help_bind = you must make sure that the variable you bind the `{$ty}` to lives at least as long as the pointer returned by the call to `{$callee}`
.help_returned = in particular, if this pointer is returned from the current function, binding the `{$ty}` inside the function will not suffice
.help_visit = for more information, see <https://doc.rust-lang.org/reference/destructors.html>
lint_default_hash_types = prefer `{$preferred}` over `{$used}`, it has better performance
.note = a `use rustc_data_structures::fx::{$preferred}` may be necessary

View file

@ -1139,7 +1139,9 @@ pub(crate) struct IgnoredUnlessCrateSpecified<'a> {
#[derive(LintDiagnostic)]
#[diag(lint_dangling_pointers_from_temporaries)]
#[note]
#[help]
#[help(lint_help_bind)]
#[help(lint_help_returned)]
#[help(lint_help_visit)]
// FIXME: put #[primary_span] on `ptr_span` once it does not cause conflicts
pub(crate) struct DanglingPointersFromTemporaries<'tcx> {
pub callee: Symbol,

View file

@ -1986,6 +1986,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
return;
}
let false_edge_start_block = candidate.subcandidates[0].false_edge_start_block;
candidate.subcandidates.retain_mut(|candidate| {
if candidate.extra_data.is_never {
candidate.visit_leaves(|subcandidate| {
@ -2000,8 +2001,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
});
if candidate.subcandidates.is_empty() {
// If `candidate` has become a leaf candidate, ensure it has a `pre_binding_block`.
candidate.pre_binding_block = Some(self.cfg.start_new_block());
// If `candidate` has become a leaf candidate, ensure it has a `pre_binding_block` and `otherwise_block`.
let next_block = self.cfg.start_new_block();
candidate.pre_binding_block = Some(next_block);
candidate.otherwise_block = Some(next_block);
// In addition, if `candidate` doesn't have `false_edge_start_block`, it should be assigned here.
if candidate.false_edge_start_block.is_none() {
candidate.false_edge_start_block = false_edge_start_block;
}
}
}

View file

@ -11,18 +11,21 @@
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![feature(string_from_utf8_lossy_owned)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::path::Path;
use std::path::{Path, PathBuf};
use std::str::Utf8Error;
use rustc_ast as ast;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{AttrItem, Attribute, MetaItemInner, token};
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Diag, FatalError, PResult};
use rustc_errors::{Diag, EmissionGuarantee, FatalError, PResult, pluralize};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::SourceMap;
use rustc_span::{FileName, SourceFile, Span};
pub use unicode_normalization::UNICODE_VERSION as UNICODE_NORMALIZATION_VERSION;
@ -73,9 +76,22 @@ pub fn new_parser_from_file<'a>(
path: &Path,
sp: Option<Span>,
) -> Result<Parser<'a>, Vec<Diag<'a>>> {
let source_file = psess.source_map().load_file(path).unwrap_or_else(|e| {
let msg = format!("couldn't read {}: {}", path.display(), e);
let sm = psess.source_map();
let source_file = sm.load_file(path).unwrap_or_else(|e| {
let msg = format!("couldn't read `{}`: {}", path.display(), e);
let mut err = psess.dcx().struct_fatal(msg);
if let Ok(contents) = std::fs::read(path)
&& let Err(utf8err) = String::from_utf8(contents.clone())
{
utf8_error(
sm,
&path.display().to_string(),
sp,
&mut err,
utf8err.utf8_error(),
&contents,
);
}
if let Some(sp) = sp {
err.span(sp);
}
@ -84,6 +100,49 @@ pub fn new_parser_from_file<'a>(
new_parser_from_source_file(psess, source_file)
}
pub fn utf8_error<E: EmissionGuarantee>(
sm: &SourceMap,
path: &str,
sp: Option<Span>,
err: &mut Diag<'_, E>,
utf8err: Utf8Error,
contents: &[u8],
) {
// The file exists, but it wasn't valid UTF-8.
let start = utf8err.valid_up_to();
let note = format!("invalid utf-8 at byte `{start}`");
let msg = if let Some(len) = utf8err.error_len() {
format!(
"byte{s} `{bytes}` {are} not valid utf-8",
bytes = if len == 1 {
format!("{:?}", contents[start])
} else {
format!("{:?}", &contents[start..start + len])
},
s = pluralize!(len),
are = if len == 1 { "is" } else { "are" },
)
} else {
note.clone()
};
let contents = String::from_utf8_lossy(contents).to_string();
let source = sm.new_source_file(PathBuf::from(path).into(), contents);
let span = Span::with_root_ctxt(
source.normalized_byte_pos(start as u32),
source.normalized_byte_pos(start as u32),
);
if span.is_dummy() {
err.note(note);
} else {
if sp.is_some() {
err.span_note(span, msg);
} else {
err.span(span);
err.span_label(span, msg);
}
}
}
/// Given a session and a `source_file`, return a parser. Returns any buffered errors from lexing
/// the initial token stream.
fn new_parser_from_source_file(

View file

@ -567,7 +567,7 @@ pub fn print_query_stack<Qcx: QueryContext>(
qcx: Qcx,
mut current_query: Option<QueryJobId>,
dcx: DiagCtxtHandle<'_>,
num_frames: Option<usize>,
limit_frames: Option<usize>,
mut file: Option<std::fs::File>,
) -> usize {
// Be careful relying on global state here: this code is called from
@ -584,7 +584,7 @@ pub fn print_query_stack<Qcx: QueryContext>(
let Some(query_info) = query_map.get(&query) else {
break;
};
if Some(count_printed) < num_frames || num_frames.is_none() {
if Some(count_printed) < limit_frames || limit_frames.is_none() {
// Only print to stderr as many stack frames as `num_frames` when present.
// FIXME: needs translation
#[allow(rustc::diagnostic_outside_of_impl)]
@ -615,5 +615,5 @@ pub fn print_query_stack<Qcx: QueryContext>(
if let Some(ref mut file) = file {
let _ = writeln!(file, "end of query stack");
}
count_printed
count_total
}

View file

@ -645,11 +645,11 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
let self_spans = items
.iter()
.filter_map(|(use_tree, _)| {
if let ast::UseTreeKind::Simple(..) = use_tree.kind {
if use_tree.ident().name == kw::SelfLower {
if let ast::UseTreeKind::Simple(..) = use_tree.kind
&& use_tree.ident().name == kw::SelfLower
{
return Some(use_tree.span);
}
}
None
})
@ -947,12 +947,13 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
let imported_binding = self.r.import(binding, import);
if parent == self.r.graph_root {
let ident = ident.normalize_to_macros_2_0();
if let Some(entry) = self.r.extern_prelude.get(&ident) {
if expansion != LocalExpnId::ROOT && orig_name.is_some() && !entry.is_import() {
if let Some(entry) = self.r.extern_prelude.get(&ident)
&& expansion != LocalExpnId::ROOT
&& orig_name.is_some()
&& !entry.is_import()
{
self.r.dcx().emit_err(
errors::MacroExpandedExternCrateCannotShadowExternArguments {
span: item.span,
},
errors::MacroExpandedExternCrateCannotShadowExternArguments { span: item.span },
);
// `return` is intended to discard this binding because it's an
// unregistered ambiguity error which would result in a panic
@ -960,7 +961,6 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
// more details: https://github.com/rust-lang/rust/pull/111761
return;
}
}
let entry = self
.r
.extern_prelude
@ -1040,11 +1040,11 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
span: item.span,
});
}
if let ItemKind::ExternCrate(Some(orig_name)) = item.kind {
if orig_name == kw::SelfLower {
if let ItemKind::ExternCrate(Some(orig_name)) = item.kind
&& orig_name == kw::SelfLower
{
self.r.dcx().emit_err(errors::MacroUseExternCrateSelf { span: attr.span });
}
}
let ill_formed = |span| {
self.r.dcx().emit_err(errors::BadMacroImport { span });
};
@ -1179,15 +1179,13 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
return Some((MacroKind::Bang, item.ident, item.span));
} else if ast::attr::contains_name(&item.attrs, sym::proc_macro_attribute) {
return Some((MacroKind::Attr, item.ident, item.span));
} else if let Some(attr) = ast::attr::find_by_name(&item.attrs, sym::proc_macro_derive) {
if let Some(meta_item_inner) =
} else if let Some(attr) = ast::attr::find_by_name(&item.attrs, sym::proc_macro_derive)
&& let Some(meta_item_inner) =
attr.meta_item_list().and_then(|list| list.get(0).cloned())
&& let Some(ident) = meta_item_inner.ident()
{
if let Some(ident) = meta_item_inner.ident() {
return Some((MacroKind::Derive, ident, ident.span));
}
}
}
None
}

View file

@ -225,11 +225,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let (name, span) =
(ident.name, self.tcx.sess.source_map().guess_head_span(new_binding.span));
if let Some(s) = self.name_already_seen.get(&name) {
if s == &span {
if self.name_already_seen.get(&name) == Some(&span) {
return;
}
}
let old_kind = match (ns, old_binding.module()) {
(ValueNS, _) => "value",
@ -380,22 +378,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
suggestion = Some(format!("self as {suggested_name}"))
}
ImportKind::Single { source, .. } => {
if let Some(pos) =
source.span.hi().0.checked_sub(binding_span.lo().0).map(|pos| pos as usize)
if let Some(pos) = source.span.hi().0.checked_sub(binding_span.lo().0)
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(binding_span)
&& pos as usize <= snippet.len()
{
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(binding_span) {
if pos <= snippet.len() {
span = binding_span
.with_lo(binding_span.lo() + BytePos(pos as u32))
.with_hi(
binding_span.hi()
- BytePos(if snippet.ends_with(';') { 1 } else { 0 }),
span = binding_span.with_lo(binding_span.lo() + BytePos(pos)).with_hi(
binding_span.hi() - BytePos(if snippet.ends_with(';') { 1 } else { 0 }),
);
suggestion = Some(format!(" as {suggested_name}"));
}
}
}
}
ImportKind::ExternCrate { source, target, .. } => {
suggestion = Some(format!(
"extern crate {} as {};",
@ -510,14 +502,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// If the first element of our path was actually resolved to an
// `ExternCrate` (also used for `crate::...`) then no need to issue a
// warning, this looks all good!
if let Some(binding) = second_binding {
if let NameBindingKind::Import { import, .. } = binding.kind {
if let Some(binding) = second_binding
&& let NameBindingKind::Import { import, .. } = binding.kind
// Careful: we still want to rewrite paths from renamed extern crates.
if let ImportKind::ExternCrate { source: None, .. } = import.kind {
&& let ImportKind::ExternCrate { source: None, .. } = import.kind
{
return;
}
}
}
let diag = BuiltinLintDiag::AbsPathWithModule(root_span);
self.lint_buffer.buffer_lint(
@ -1047,14 +1038,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
if filter_fn(res) {
for derive in parent_scope.derives {
let parent_scope = &ParentScope { derives: &[], ..*parent_scope };
if let Ok((Some(ext), _)) = this.resolve_macro_path(
let Ok((Some(ext), _)) = this.resolve_macro_path(
derive,
Some(MacroKind::Derive),
parent_scope,
false,
false,
None,
) {
) else {
continue;
};
suggestions.extend(
ext.helper_attrs
.iter()
@ -1063,7 +1056,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
}
}
}
Scope::MacroRules(macro_rules_scope) => {
if let MacroRulesScope::Binding(macro_rules_binding) = macro_rules_scope.get() {
let res = macro_rules_binding.binding.res();
@ -1215,13 +1207,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
// #90113: Do not count an inaccessible reexported item as a candidate.
if let NameBindingKind::Import { binding, .. } = name_binding.kind {
if this.is_accessible_from(binding.vis, parent_scope.module)
if let NameBindingKind::Import { binding, .. } = name_binding.kind
&& this.is_accessible_from(binding.vis, parent_scope.module)
&& !this.is_accessible_from(name_binding.vis, parent_scope.module)
{
return;
}
}
let res = name_binding.res();
let did = match res {
@ -1253,15 +1244,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
segms.push(ast::PathSegment::from_ident(ident));
let path = Path { span: name_binding.span, segments: segms, tokens: None };
if child_accessible {
if child_accessible
// Remove invisible match if exists
if let Some(idx) = candidates
&& let Some(idx) = candidates
.iter()
.position(|v: &ImportSuggestion| v.did == did && !v.accessible)
{
candidates.remove(idx);
}
}
if candidates.iter().all(|v: &ImportSuggestion| v.did != did) {
// See if we're recommending TryFrom, TryInto, or FromIterator and add
@ -1373,8 +1363,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// otherwise cause duplicate suggestions.
continue;
}
let crate_id = self.crate_loader(|c| c.maybe_process_path_extern(ident.name));
if let Some(crate_id) = crate_id {
let Some(crate_id) = self.crate_loader(|c| c.maybe_process_path_extern(ident.name))
else {
continue;
};
let crate_def_id = crate_id.as_def_id();
let crate_root = self.expect_module(crate_def_id);
@ -1416,7 +1409,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
));
}
}
}
suggestions
}
@ -1511,7 +1503,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
});
}
for ns in [Namespace::MacroNS, Namespace::TypeNS, Namespace::ValueNS] {
if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
ident,
ScopeSet::All(ns),
parent_scope,
@ -1519,11 +1511,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
false,
None,
None,
) {
) else {
continue;
};
let desc = match binding.res() {
Res::Def(DefKind::Macro(MacroKind::Bang), _) => {
"a function-like macro".to_string()
}
Res::Def(DefKind::Macro(MacroKind::Bang), _) => "a function-like macro".to_string(),
Res::Def(DefKind::Macro(MacroKind::Attr), _) | Res::NonMacroAttr(..) => {
format!("an attribute: `#[{ident}]`")
}
@ -1545,8 +1538,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
macro_kind.descr_expected(),
),
};
if let crate::NameBindingKind::Import { import, .. } = binding.kind {
if !import.span.is_dummy() {
if let crate::NameBindingKind::Import { import, .. } = binding.kind
&& !import.span.is_dummy()
{
let note = errors::IdentImporterHereButItIsDesc {
span: import.span,
imported_ident: ident,
@ -1558,7 +1552,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
self.record_use(ident, binding, Used::Other);
return;
}
}
let note = errors::IdentInScopeButItIsDesc {
imported_ident: ident,
imported_ident_desc: &desc,
@ -1567,7 +1560,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
return;
}
}
}
pub(crate) fn add_typo_suggestion(
&self,
@ -1749,15 +1741,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
/// If the binding refers to a tuple struct constructor with fields,
/// returns the span of its fields.
fn ctor_fields_span(&self, binding: NameBinding<'_>) -> Option<Span> {
if let NameBindingKind::Res(Res::Def(
let NameBindingKind::Res(Res::Def(
DefKind::Ctor(CtorOf::Struct, CtorKind::Fn),
ctor_def_id,
)) = binding.kind
{
else {
return None;
};
let def_id = self.tcx.parent(ctor_def_id);
return self.field_idents(def_id)?.iter().map(|&f| f.span).reduce(Span::to); // None for `struct Foo()`
}
None
self.field_idents(def_id)?.iter().map(|&f| f.span).reduce(Span::to) // None for `struct Foo()`
}
fn report_privacy_error(&mut self, privacy_error: &PrivacyError<'ra>) {
@ -1983,10 +1976,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
.collect::<Vec<_>>();
candidates.sort();
candidates.dedup();
match find_best_match_for_name(&candidates, ident, None) {
Some(sugg) if sugg == ident => None,
sugg => sugg,
}
find_best_match_for_name(&candidates, ident, None).filter(|sugg| *sugg != ident)
}
pub(crate) fn report_path_resolution_error(
@ -2410,7 +2400,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let binding_key = BindingKey::new(ident, MacroNS);
let resolution = resolutions.get(&binding_key)?;
let binding = resolution.borrow().binding()?;
if let Res::Def(DefKind::Macro(MacroKind::Bang), _) = binding.res() {
let Res::Def(DefKind::Macro(MacroKind::Bang), _) = binding.res() else {
return None;
};
let module_name = crate_module.kind.name().unwrap();
let import_snippet = match import.kind {
ImportKind::Single { source, target, .. } if source != target => {
@ -2436,7 +2428,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
debug!(found_closing_brace, ?binding_span);
let mut removal_span = binding_span;
if found_closing_brace {
// If the binding span ended with a closing brace, as in the below example:
// ie. `use a::b::{c, d};`
// ^
@ -2444,13 +2436,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// binding's trailing comma.
// ie. `use a::b::{c, d};`
// ^^^
if let Some(previous_span) =
if found_closing_brace
&& let Some(previous_span) =
extend_span_to_previous_binding(self.tcx.sess, binding_span)
{
debug!(?previous_span);
removal_span = removal_span.with_lo(previous_span.lo());
}
}
debug!(?removal_span);
// Remove the `removal_span`.
@ -2462,11 +2454,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// ^^^^^^^^^
// or `use a::{b, c, d}};`
// ^^^^^^^^^^^
let (has_nested, after_crate_name) = find_span_immediately_after_crate_name(
self.tcx.sess,
module_name,
import.use_span,
);
let (has_nested, after_crate_name) =
find_span_immediately_after_crate_name(self.tcx.sess, module_name, import.use_span);
debug!(has_nested, ?after_crate_name);
let source_map = self.tcx.sess.source_map();
@ -2496,8 +2485,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// Add a `};` to the end if nested, matching the `{` added at the start.
if !has_nested {
corrections
.push((source_map.end_point(after_crate_name), "};".to_string()));
corrections.push((source_map.end_point(after_crate_name), "};".to_string()));
}
} else {
// If the root import is module-relative, add the import separately
@ -2513,12 +2501,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
String::from("a macro with this name exists at the root of the crate"),
Applicability::MaybeIncorrect,
));
Some((suggestion, Some("this could be because a macro annotated with `#[macro_export]` will be exported \
Some((
suggestion,
Some(
"this could be because a macro annotated with `#[macro_export]` will be exported \
at the root of the crate instead of the module where it is defined"
.to_string())))
} else {
None
}
.to_string(),
),
))
}
/// Finds a cfg-ed out item inside `module` with the matching name.
@ -3042,7 +3032,6 @@ impl<'tcx> visit::Visitor<'tcx> for UsePlacementFinder {
self.first_legal_span = Some(inject);
}
self.first_use_span = search_for_any_use_in_items(&c.items);
return;
} else {
visit::walk_crate(self, c);
}
@ -3056,7 +3045,6 @@ impl<'tcx> visit::Visitor<'tcx> for UsePlacementFinder {
self.first_legal_span = Some(inject);
}
self.first_use_span = search_for_any_use_in_items(items);
return;
}
} else {
visit::walk_item(self, item);
@ -3066,8 +3054,9 @@ impl<'tcx> visit::Visitor<'tcx> for UsePlacementFinder {
fn search_for_any_use_in_items(items: &[P<ast::Item>]) -> Option<Span> {
for item in items {
if let ItemKind::Use(..) = item.kind {
if is_span_suitable_for_use_injection(item.span) {
if let ItemKind::Use(..) = item.kind
&& is_span_suitable_for_use_injection(item.span)
{
let mut lo = item.span.lo();
for attr in &item.attrs {
if attr.span.eq_ctxt(item.span) {
@ -3077,7 +3066,6 @@ fn search_for_any_use_in_items(items: &[P<ast::Item>]) -> Option<Span> {
return Some(Span::new(lo, lo, item.span.ctxt(), item.span.parent()));
}
}
}
None
}

View file

@ -118,7 +118,9 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
let resolutions = self.r.resolutions(module);
for (_, name_resolution) in resolutions.borrow().iter() {
if let Some(mut binding) = name_resolution.borrow().binding() {
let Some(mut binding) = name_resolution.borrow().binding() else {
continue;
};
// Set the given effective visibility level to `Level::Direct` and
// sets the rest of the `use` chain to `Level::Reexported` until
// we hit the actual exported item.
@ -151,7 +153,6 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
}
}
}
}
fn effective_vis_or_private(&mut self, parent_id: ParentId<'ra>) -> EffectiveVisibility {
// Private nodes are only added to the table for caching, they could be added or removed at

View file

@ -246,14 +246,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// ---- end
// ```
// So we have to fall back to the module's parent during lexical resolution in this case.
if derive_fallback_lint_id.is_some() {
if let Some(parent) = module.parent {
// Inner module is inside the macro, parent module is outside of the macro.
if module.expansion != parent.expansion
if derive_fallback_lint_id.is_some()
&& let Some(parent) = module.parent
// Inner module is inside the macro
&& module.expansion != parent.expansion
// Parent module is outside of the macro
&& module.expansion.is_descendant_of(parent.expansion)
{
// The macro is a proc macro derive
if let Some(def_id) = module.expansion.expn_data().macro_def_id {
&& let Some(def_id) = module.expansion.expn_data().macro_def_id
{
let ext = &self.get_macro_by_def_id(def_id).ext;
if ext.builtin_name.is_none()
&& ext.macro_kind() == MacroKind::Derive
@ -262,9 +263,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
return Some((parent, derive_fallback_lint_id));
}
}
}
}
}
None
}
@ -593,8 +591,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
},
Scope::StdLibPrelude => {
let mut result = Err(Determinacy::Determined);
if let Some(prelude) = this.prelude {
if let Ok(binding) = this.resolve_ident_in_module_unadjusted(
if let Some(prelude) = this.prelude
&& let Ok(binding) = this.resolve_ident_in_module_unadjusted(
ModuleOrUniformRoot::Module(prelude),
ident,
ns,
@ -603,14 +601,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
None,
ignore_binding,
ignore_import,
) {
if matches!(use_prelude, UsePrelude::Yes)
|| this.is_builtin_macro(binding.res())
)
&& (matches!(use_prelude, UsePrelude::Yes)
|| this.is_builtin_macro(binding.res()))
{
result = Ok((binding, Flags::MISC_FROM_PRELUDE));
}
}
}
result
}
Scope::BuiltinTypes => match this.builtin_types_bindings.get(&ident.name) {
@ -939,11 +936,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
};
// Items and single imports are not shadowable, if we have one, then it's determined.
if let Some(binding) = binding {
if !binding.is_glob_import() {
if let Some(binding) = binding
&& !binding.is_glob_import()
{
return check_usable(self, binding);
}
}
// --- From now on we either have a glob resolution or no resolution. ---
@ -1437,14 +1434,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
for (segment_idx, &Segment { ident, id, .. }) in path.iter().enumerate() {
debug!("resolve_path ident {} {:?} {:?}", segment_idx, ident, id);
let record_segment_res = |this: &mut Self, res| {
if finalize.is_some() {
if let Some(id) = id {
if !this.partial_res_map.contains_key(&id) {
if finalize.is_some()
&& let Some(id) = id
&& !this.partial_res_map.contains_key(&id)
{
assert!(id != ast::DUMMY_NODE_ID, "Trying to resolve dummy id");
this.record_partial_res(id, PartialRes::new(res));
}
}
}
};
let is_last = segment_idx + 1 == path.len();
@ -1463,14 +1459,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
_ => None,
},
};
if let Some(self_module) = self_module {
if let Some(parent) = self_module.parent {
module = Some(ModuleOrUniformRoot::Module(
self.resolve_self(&mut ctxt, parent),
));
if let Some(self_module) = self_module
&& let Some(parent) = self_module.parent
{
module =
Some(ModuleOrUniformRoot::Module(self.resolve_self(&mut ctxt, parent)));
continue;
}
}
return PathResult::failed(
ident,
false,
@ -1644,14 +1639,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
Err(Undetermined) => return PathResult::Indeterminate,
Err(Determined) => {
if let Some(ModuleOrUniformRoot::Module(module)) = module {
if opt_ns.is_some() && !module.is_normal() {
if let Some(ModuleOrUniformRoot::Module(module)) = module
&& opt_ns.is_some()
&& !module.is_normal()
{
return PathResult::NonModule(PartialRes::with_unresolved_segments(
module.res().unwrap(),
path.len() - segment_idx,
));
}
}
return PathResult::failed(
ident,

View file

@ -287,13 +287,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
binding.vis
};
if let ImportKind::Glob { ref max_vis, .. } = import.kind {
if vis == import_vis
|| max_vis.get().is_none_or(|max_vis| vis.is_at_least(max_vis, self.tcx))
if let ImportKind::Glob { ref max_vis, .. } = import.kind
&& (vis == import_vis
|| max_vis.get().is_none_or(|max_vis| vis.is_at_least(max_vis, self.tcx)))
{
max_vis.set(Some(vis.expect_local()))
}
}
self.arenas.alloc_name_binding(NameBindingData {
kind: NameBindingKind::Import { binding, import },
@ -543,21 +542,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// resolution for it so that later resolve stages won't complain.
self.import_dummy_binding(*import, is_indeterminate);
if let Some(err) = unresolved_import_error {
let Some(err) = unresolved_import_error else { continue };
glob_error |= import.is_glob();
if let ImportKind::Single { source, ref source_bindings, .. } = import.kind {
if source.name == kw::SelfLower {
if let ImportKind::Single { source, ref source_bindings, .. } = import.kind
&& source.name == kw::SelfLower
// Silence `unresolved import` error if E0429 is already emitted
if let Err(Determined) = source_bindings.value_ns.get() {
&& let Err(Determined) = source_bindings.value_ns.get()
{
continue;
}
}
}
if prev_root_id != NodeId::ZERO
&& prev_root_id != import.root_id
&& !errors.is_empty()
if prev_root_id != NodeId::ZERO && prev_root_id != import.root_id && !errors.is_empty()
{
// In the case of a new import line, throw a diagnostic message
// for the previous line.
@ -569,7 +566,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
prev_root_id = import.root_id;
}
}
}
if !errors.is_empty() {
self.throw_unresolved_import_error(errors, glob_error);
@ -609,7 +605,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
for (key, resolution) in self.resolutions(*module).borrow().iter() {
let resolution = resolution.borrow();
if let Some(binding) = resolution.binding {
let Some(binding) = resolution.binding else { continue };
if let NameBindingKind::Import { import, .. } = binding.kind
&& let Some((amb_binding, _)) = binding.ambiguity
&& binding.res() != Res::Err
@ -666,7 +663,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
}
}
}
fn throw_unresolved_import_error(
&mut self,
@ -1006,14 +1002,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
self.lint_if_path_starts_with_module(Some(finalize), &full_path, None);
}
if let ModuleOrUniformRoot::Module(module) = module {
if module == import.parent_scope.module {
if let ModuleOrUniformRoot::Module(module) = module
&& module == import.parent_scope.module
{
// Importing a module into itself is not allowed.
return Some(UnresolvedImportError {
span: import.span,
label: Some(String::from(
"cannot glob-import a module into itself",
)),
label: Some(String::from("cannot glob-import a module into itself")),
note: None,
suggestion: None,
candidates: None,
@ -1021,7 +1016,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
module: None,
});
}
}
if !is_prelude
&& let Some(max_vis) = max_vis.get()
&& !max_vis.is_at_least(import.vis, self.tcx)
@ -1081,8 +1075,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// Consistency checks, analogous to `finalize_macro_resolutions`.
let initial_res = source_bindings[ns].get().map(|initial_binding| {
all_ns_err = false;
if let Some(target_binding) = target_bindings[ns].get() {
if target.name == kw::Underscore
if let Some(target_binding) = target_bindings[ns].get()
&& target.name == kw::Underscore
&& initial_binding.is_extern_crate()
&& !initial_binding.is_import()
{
@ -1093,7 +1087,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
};
this.record_use(ident, target_binding, used);
}
}
initial_binding.res()
});
let res = binding.res();
@ -1247,18 +1240,20 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let mut any_successful_reexport = false;
let mut crate_private_reexport = false;
self.per_ns(|this, ns| {
if let Ok(binding) = source_bindings[ns].get() {
let Ok(binding) = source_bindings[ns].get() else {
return;
};
if !binding.vis.is_at_least(import.vis, this.tcx) {
reexport_error = Some((ns, binding));
if let ty::Visibility::Restricted(binding_def_id) = binding.vis {
if binding_def_id.is_top_level_module() {
if let ty::Visibility::Restricted(binding_def_id) = binding.vis
&& binding_def_id.is_top_level_module()
{
crate_private_reexport = true;
}
}
} else {
any_successful_reexport = true;
}
}
});
// All namespaces must be re-exported with extra visibility for an error to occur.
@ -1474,7 +1469,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// Since import resolution is finished, globs will not define any more names.
*module.globs.borrow_mut() = Vec::new();
if let Some(def_id) = module.opt_def_id() {
let Some(def_id) = module.opt_def_id() else { return };
let mut children = Vec::new();
module.for_each_child(self, |this, ident, _, binding| {
@ -1498,7 +1494,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
}
}
}
fn import_path_to_string(names: &[Ident], import_kind: &ImportKind<'_>, span: Span) -> String {
let pos = names.iter().position(|p| span == p.span && p.name != kw::PathRoot);

View file

@ -468,16 +468,12 @@ impl<'a> PathSource<'a> {
{
"external crate"
}
ExprKind::Path(_, path) => {
let mut msg = "function";
if let Some(segment) = path.segments.iter().last() {
if let Some(c) = segment.ident.to_string().chars().next() {
if c.is_uppercase() {
msg = "function, tuple struct or tuple variant";
}
}
}
msg
ExprKind::Path(_, path)
if let Some(segment) = path.segments.last()
&& let Some(c) = segment.ident.to_string().chars().next()
&& c.is_uppercase() =>
{
"function, tuple struct or tuple variant"
}
_ => "function",
},
@ -1182,10 +1178,11 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
// namespace first, and if that fails we try again in the value namespace. If
// resolution in the value namespace succeeds, we have an generic const argument on
// our hands.
if let TyKind::Path(None, ref path) = ty.kind {
if let TyKind::Path(None, ref path) = ty.kind
// We cannot disambiguate multi-segment paths right now as that requires type
// checking.
if path.is_potential_trivial_const_arg() {
&& path.is_potential_trivial_const_arg()
{
let mut check_ns = |ns| {
self.maybe_resolve_ident_in_lexical_scope(path.segments[0].ident, ns)
.is_some()
@ -1195,12 +1192,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
true,
AnonConstKind::ConstArg(IsRepeatExpr::No),
|this| {
this.smart_resolve_path(
ty.id,
&None,
path,
PathSource::Expr(None),
);
this.smart_resolve_path(ty.id, &None, path, PathSource::Expr(None));
this.visit_path(path, ty.id);
},
);
@ -1209,7 +1201,6 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
return;
}
}
}
self.visit_ty(ty);
}
@ -1243,7 +1234,10 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
}
fn visit_path_segment(&mut self, path_segment: &'ast PathSegment) {
if let Some(ref args) = path_segment.args {
let Some(ref args) = path_segment.args else {
return;
};
match &**args {
GenericArgs::AngleBracketed(..) => visit::walk_generic_args(self, args),
GenericArgs::Parenthesized(p_args) => {
@ -1292,7 +1286,6 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
GenericArgs::ParenthesizedElided(_) => {}
}
}
}
fn visit_where_predicate(&mut self, p: &'ast WherePredicate) {
debug!("visit_where_predicate {:?}", p);
@ -1735,13 +1728,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
}
let normalized_ident = ident.normalize_to_macros_2_0();
let mut outer_res = None;
for rib in lifetime_rib_iter {
if let Some((&outer, _)) = rib.bindings.get_key_value(&normalized_ident) {
outer_res = Some(outer);
break;
}
}
let outer_res = lifetime_rib_iter
.find_map(|rib| rib.bindings.get_key_value(&normalized_ident).map(|(&outer, _)| outer));
self.emit_undeclared_lifetime_error(lifetime, outer_res);
self.record_lifetime_res(lifetime.id, LifetimeRes::Error, LifetimeElisionCandidate::Named);
@ -1808,23 +1796,21 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
}
LifetimeRibKind::AnonymousReportError => {
if elided {
let mut suggestion = None;
for rib in self.lifetime_ribs[i..].iter().rev() {
let suggestion = self.lifetime_ribs[i..].iter().rev().find_map(|rib| {
if let LifetimeRibKind::Generics {
span,
kind: LifetimeBinderKind::PolyTrait | LifetimeBinderKind::WhereBound,
..
} = &rib.kind
} = rib.kind
{
suggestion =
Some(errors::ElidedAnonymousLivetimeReportErrorSuggestion {
lo: span.shrink_to_lo(),
hi: lifetime.ident.span.shrink_to_hi(),
})
} else {
None
}
});
break;
}
}
// are we trying to use an anonymous lifetime
// on a non GAT associated trait type?
if !self.in_func_body
@ -2460,13 +2446,13 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
for i in (0..self.label_ribs.len()).rev() {
let rib = &self.label_ribs[i];
if let RibKind::MacroDefinition(def) = rib.kind {
if let RibKind::MacroDefinition(def) = rib.kind
// If an invocation of this macro created `ident`, give up on `ident`
// and switch to `ident`'s source from the macro definition.
if def == self.r.macro_def(label.span.ctxt()) {
&& def == self.r.macro_def(label.span.ctxt())
{
label.span.remove_mark();
}
}
let ident = label.normalize_to_macro_rules();
if let Some((ident, id)) = rib.bindings.get_key_value(&ident) {
@ -2493,14 +2479,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
/// Determine whether or not a label from the `rib_index`th label rib is reachable.
fn is_label_valid_from_rib(&self, rib_index: usize) -> bool {
let ribs = &self.label_ribs[rib_index + 1..];
for rib in ribs {
if rib.kind.is_label_barrier() {
return false;
}
}
true
ribs.iter().all(|rib| !rib.kind.is_label_barrier())
}
fn resolve_adt(&mut self, item: &'ast Item, generics: &'ast Generics) {
@ -3505,7 +3484,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
self.visit_ty(&qself.ty);
}
self.visit_path(&delegation.path, delegation.id);
if let Some(body) = &delegation.body {
let Some(body) = &delegation.body else { return };
self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| {
// `PatBoundCtx` is not necessary in this context
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];
@ -3520,7 +3499,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
this.visit_block(body);
});
}
}
fn resolve_params(&mut self, params: &'ast [Param]) {
let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())];

View file

@ -2387,13 +2387,12 @@ mod async_keyword {}
/// [`async`]: ../std/keyword.async.html
mod await_keyword {}
// FIXME(dyn_compat_renaming): Update URL and link text.
#[doc(keyword = "dyn")]
//
/// `dyn` is a prefix of a [trait object]'s type.
///
/// The `dyn` keyword is used to highlight that calls to methods on the associated `Trait`
/// are [dynamically dispatched]. To use the trait this way, it must be 'dyn-compatible'[^1].
/// are [dynamically dispatched]. To use the trait this way, it must be *dyn compatible*[^1].
///
/// Unlike generic parameters or `impl Trait`, the compiler does not know the concrete type that
/// is being passed. That is, the type has been [erased].
@ -2406,7 +2405,7 @@ mod await_keyword {}
/// the function pointer and then that function pointer is called.
///
/// See the Reference for more information on [trait objects][ref-trait-obj]
/// and [object safety][ref-obj-safety].
/// and [dyn compatibility][ref-dyn-compat].
///
/// ## Trade-offs
///
@ -2419,9 +2418,9 @@ mod await_keyword {}
/// [trait object]: ../book/ch17-02-trait-objects.html
/// [dynamically dispatched]: https://en.wikipedia.org/wiki/Dynamic_dispatch
/// [ref-trait-obj]: ../reference/types/trait-object.html
/// [ref-obj-safety]: ../reference/items/traits.html#object-safety
/// [ref-dyn-compat]: ../reference/items/traits.html#dyn-compatibility
/// [erased]: https://en.wikipedia.org/wiki/Type_erasure
/// [^1]: Formerly known as 'object safe'.
/// [^1]: Formerly known as *object safe*.
mod dyn_keyword {}
#[doc(keyword = "union")]

View file

@ -328,9 +328,6 @@ impl File {
mem::size_of::<c::FILE_ALLOCATION_INFO>() as u32,
);
if result == 0 {
if api::get_last_error().code != 0 {
panic!("FILE_ALLOCATION_INFO failed!!!");
}
let eof = c::FILE_END_OF_FILE_INFO { EndOfFile: 0 };
let result = c::SetFileInformationByHandle(
handle.as_raw_handle(),

View file

@ -123,6 +123,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
build_args+=("--build-arg" "SCRIPT_ARG=${DOCKER_SCRIPT}")
fi
GHCR_BUILDKIT_IMAGE="ghcr.io/rust-lang/buildkit:buildx-stable-1"
# On non-CI jobs, we try to download a pre-built image from the rust-lang-ci
# ghcr.io registry. If it is not possible, we fall back to building the image
# locally.
@ -140,7 +141,9 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
elif [[ "$PR_CI_JOB" == "1" ]];
then
# Enable a new Docker driver so that --cache-from works with a registry backend
docker buildx create --use --driver docker-container
# Use a custom image to avoid DockerHub rate limits
docker buildx create --use --driver docker-container \
--driver-opt image=${GHCR_BUILDKIT_IMAGE}
# Build the image using registry caching backend
retry docker \
@ -156,7 +159,9 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
--password-stdin
# Enable a new Docker driver so that --cache-from/to works with a registry backend
docker buildx create --use --driver docker-container
# Use a custom image to avoid DockerHub rate limits
docker buildx create --use --driver docker-container \
--driver-opt image=${GHCR_BUILDKIT_IMAGE}
# Build the image using registry caching backend
retry docker \

View file

@ -101,6 +101,8 @@ pub fn load_errors(testfile: &Path, revision: Option<&str>) -> Vec<Error> {
rdr.lines()
.enumerate()
// We want to ignore utf-8 failures in tests during collection of annotations.
.filter(|(_, line)| line.is_ok())
.filter_map(|(line_num, line)| {
parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), revision).map(
|(which, error)| {

View file

@ -58,7 +58,7 @@ pub fn check(tests_path: impl AsRef<Path>, bad: &mut bool) {
let mut expected_revisions = BTreeSet::new();
let contents = std::fs::read_to_string(test).unwrap();
let Ok(contents) = std::fs::read_to_string(test) else { continue };
// Collect directives.
iter_header(&contents, &mut |HeaderLine { revision, directive, .. }| {

View file

@ -1,11 +0,0 @@
//@ known-bug: #130779
#![feature(never_patterns)]
enum E { A }
fn main() {
match E::A {
! |
if true => {}
}
}

View file

@ -1,8 +0,0 @@
//@ known-bug: #133063
fn foo(x: !) {
match x {
(! | !) if false => {}
_ => {}
}
}

View file

@ -1,8 +0,0 @@
//@ known-bug: #133117
fn main() {
match () {
(!|!) if true => {}
(!|!) if true => {}
}
}

View file

@ -6,6 +6,6 @@ Box<dyn Any>
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at $DIR/issue-80742.rs:26:1: 28:32>::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
end of query stack
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 1 previous error

View file

@ -5,4 +5,4 @@ error: the compiler unexpectedly panicked. this is a bug.
query stack during panic:
#0 [layout_of] computing layout of `Foo`
#1 [eval_to_allocation_raw] const-evaluating + checking `FOO`
end of query stack
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack

View file

@ -7,6 +7,8 @@ LL | dbg!(String::new().as_ptr());
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/allow.rs:7:12
@ -23,6 +25,8 @@ LL | dbg!(String::new().as_ptr());
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/allow.rs:18:12

View file

@ -7,6 +7,8 @@ LL | let ptr = cstring().as_ptr();
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/calls.rs:1:9
@ -23,6 +25,8 @@ LL | let ptr = cstring().as_ptr();
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `CString` will be dropped
@ -34,6 +38,8 @@ LL | let _ptr: *const u8 = cstring().as_ptr().cast();
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `CString` will be dropped
@ -45,6 +51,8 @@ LL | let _ptr: *const u8 = { cstring() }.as_ptr().cast();
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `CString` will be dropped
@ -56,6 +64,8 @@ LL | let _ptr: *const u8 = { cstring().as_ptr() }.cast();
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: aborting due to 5 previous errors

View file

@ -15,6 +15,8 @@ LL | let s = CString::new("some text").unwrap().as_ptr();
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/cstring-as-ptr.rs:2:9
@ -34,6 +36,8 @@ LL | mymacro!();
| ---------- in this macro invocation
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
= note: this error originates in the macro `mymacro` (in Nightly builds, run with -Z macro-backtrace for more info)

View file

@ -7,6 +7,8 @@ LL | let str1 = String::with_capacity(MAX_PATH).as_mut_ptr();
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_mut_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_mut_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/example-from-issue123613.rs:1:9
@ -23,6 +25,8 @@ LL | let str2 = String::from("TotototototototototototototototototoT").as_ptr
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: aborting due to 2 previous errors

View file

@ -7,6 +7,8 @@ LL | let _ptr1 = Vec::<u32>::new().as_ptr().dbg();
| this `Vec<u32>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u32>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Vec<u32>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u32>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/ext.rs:1:9
@ -23,6 +25,8 @@ LL | let _ptr2 = vec![0].as_ptr().foo();
| this `Vec<u32>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u32>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Vec<u32>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u32>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: aborting due to 2 previous errors

View file

@ -7,6 +7,8 @@ LL | vec![0u8].as_ptr();
| this `Vec<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Vec<u8>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/methods.rs:1:9
@ -23,6 +25,8 @@ LL | vec![0u8].as_mut_ptr();
| this `Vec<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_mut_ptr` the `Vec<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Vec<u8>` to lives at least as long as the pointer returned by the call to `as_mut_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: aborting due to 2 previous errors

View file

@ -7,6 +7,8 @@ LL | string().as_ptr();
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/temporaries.rs:2:9
@ -23,6 +25,8 @@ LL | "hello".to_string().as_ptr();
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `String` will be dropped
@ -34,6 +38,8 @@ LL | (string() + "hello").as_ptr();
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `String` will be dropped
@ -45,6 +51,8 @@ LL | (if true { String::new() } else { "hello".into() }).as_ptr();
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `String` will be dropped
@ -58,6 +66,8 @@ LL | .as_ptr();
| ^^^^^^ this pointer will immediately be invalid
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `String` will be dropped
@ -71,6 +81,8 @@ LL | .as_ptr();
| ^^^^^^ this pointer will immediately be invalid
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `String` will be dropped
@ -82,6 +94,8 @@ LL | { string() }.as_ptr();
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Vec<u8>` will be dropped
@ -93,6 +107,8 @@ LL | vec![0u8].as_ptr();
| this `Vec<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Vec<u8>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: aborting due to 8 previous errors

View file

@ -7,6 +7,8 @@ LL | declval::<CString>().as_ptr();
| this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
note: the lint level is defined here
--> $DIR/types.rs:1:9
@ -23,6 +25,8 @@ LL | declval::<String>().as_ptr();
| this `String` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `String` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `String` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `String` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Vec<u8>` will be dropped
@ -34,6 +38,8 @@ LL | declval::<Vec<u8>>().as_ptr();
| this `Vec<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Vec<u8>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Vec<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<CString>` will be dropped
@ -45,6 +51,8 @@ LL | declval::<Box<CString>>().as_ptr();
| this `Box<CString>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<CString>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<CString>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<CString>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<[u8]>` will be dropped
@ -56,6 +64,8 @@ LL | declval::<Box<[u8]>>().as_ptr();
| this `Box<[u8]>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<[u8]>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<[u8]>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<[u8]>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<str>` will be dropped
@ -67,6 +77,8 @@ LL | declval::<Box<str>>().as_ptr();
| this `Box<str>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<str>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<str>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<str>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<CStr>` will be dropped
@ -78,6 +90,8 @@ LL | declval::<Box<CStr>>().as_ptr();
| this `Box<CStr>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<CStr>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<CStr>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<CStr>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `[u8; 10]` will be dropped
@ -89,6 +103,8 @@ LL | declval::<[u8; 10]>().as_ptr();
| this `[u8; 10]` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `[u8; 10]` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `[u8; 10]` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `[u8; 10]` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<[u8; 10]>` will be dropped
@ -100,6 +116,8 @@ LL | declval::<Box<[u8; 10]>>().as_ptr();
| this `Box<[u8; 10]>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<[u8; 10]>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<[u8; 10]>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<[u8; 10]>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<Vec<u8>>` will be dropped
@ -111,6 +129,8 @@ LL | declval::<Box<Vec<u8>>>().as_ptr();
| this `Box<Vec<u8>>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<Vec<u8>>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<Vec<u8>>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<Vec<u8>>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<String>` will be dropped
@ -122,6 +142,8 @@ LL | declval::<Box<String>>().as_ptr();
| this `Box<String>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<String>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<String>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<String>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Box<Box<Box<Box<[u8]>>>>` will be dropped
@ -133,6 +155,8 @@ LL | declval::<Box<Box<Box<Box<[u8]>>>>>().as_ptr();
| this `Box<Box<Box<Box<[u8]>>>>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Box<Box<Box<Box<[u8]>>>>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Box<Box<Box<Box<[u8]>>>>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Box<Box<Box<Box<[u8]>>>>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Cell<u8>` will be dropped
@ -144,6 +168,8 @@ LL | declval::<Cell<u8>>().as_ptr();
| this `Cell<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Cell<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Cell<u8>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Cell<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `MaybeUninit<u8>` will be dropped
@ -155,6 +181,8 @@ LL | declval::<MaybeUninit<u8>>().as_ptr();
| this `MaybeUninit<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `MaybeUninit<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `MaybeUninit<u8>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `MaybeUninit<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `Vec<AsPtrFake>` will be dropped
@ -166,6 +194,8 @@ LL | declval::<Vec<AsPtrFake>>().as_ptr();
| this `Vec<AsPtrFake>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `as_ptr` the `Vec<AsPtrFake>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `Vec<AsPtrFake>` to lives at least as long as the pointer returned by the call to `as_ptr`
= help: in particular, if this pointer is returned from the current function, binding the `Vec<AsPtrFake>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `UnsafeCell<u8>` will be dropped
@ -177,6 +207,8 @@ LL | declval::<UnsafeCell<u8>>().get();
| this `UnsafeCell<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `get` the `UnsafeCell<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `UnsafeCell<u8>` to lives at least as long as the pointer returned by the call to `get`
= help: in particular, if this pointer is returned from the current function, binding the `UnsafeCell<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: a dangling pointer will be produced because the temporary `SyncUnsafeCell<u8>` will be dropped
@ -188,6 +220,8 @@ LL | declval::<SyncUnsafeCell<u8>>().get();
| this `SyncUnsafeCell<u8>` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
|
= note: pointers do not have a lifetime; when calling `get` the `SyncUnsafeCell<u8>` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
= help: you must make sure that the variable you bind the `SyncUnsafeCell<u8>` to lives at least as long as the pointer returned by the call to `get`
= help: in particular, if this pointer is returned from the current function, binding the `SyncUnsafeCell<u8>` inside the function will not suffice
= help: for more information, see <https://doc.rust-lang.org/reference/destructors.html>
error: aborting due to 17 previous errors

View file

@ -3,5 +3,5 @@
//@ reference: input.encoding.invalid
fn foo() {
include!("not-utf8.bin")
include!("not-utf8.bin");
}

View file

@ -1,9 +1,14 @@
error: couldn't read $DIR/not-utf8.bin: stream did not contain valid UTF-8
error: couldn't read `$DIR/not-utf8.bin`: stream did not contain valid UTF-8
--> $DIR/not-utf8.rs:6:5
|
LL | include!("not-utf8.bin")
LL | include!("not-utf8.bin");
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: byte `193` is not valid utf-8
--> $DIR/not-utf8.bin:1:1
|
LL | <20>|<7C>␂!5<>cc␕␂<E29095>Ӻi<D3BA><69>WWj<57>ȥ<EFBFBD>'<27>}<7D><EFBFBD>J<EFBFBD>ȉ<EFBFBD><C889>W<EFBFBD>␞O<E2909E>@<40><><EFBFBD><EFBFBD>␜w<E2909C>V<EFBFBD><56><EFBFBD>LO<4C><4F><EFBFBD><EFBFBD>␔[ ␃_<E29083>'<27><><EFBFBD>SQ<53><><D8B0>ų&<26><>- <20><>lN~<7E><>!@␌ _#<23><><EFBFBD>kQ<6B><51>h<68>␝<EF8F81>:<3A>...
| ^
= note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error

View file

@ -1,4 +1,4 @@
//@ normalize-stderr: "\.:.*\(" -> ".: $$ACCESS_DENIED_MSG ("
//@ normalize-stderr: "\.`:.*\(" -> ".`: $$ACCESS_DENIED_MSG ("
//@ normalize-stderr: "os error \d+" -> "os error $$ACCESS_DENIED_CODE"
#[path = "."]

View file

@ -1,4 +1,4 @@
error: couldn't read $DIR/.: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE)
error: couldn't read `$DIR/.`: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE)
--> $DIR/path-no-file-name.rs:5:1
|
LL | mod m;

View file

@ -1,4 +1,4 @@
//@ normalize-stderr: "parser:.*\(" -> "parser: $$ACCESS_DENIED_MSG ("
//@ normalize-stderr: "parser`:.*\(" -> "parser`: $$ACCESS_DENIED_MSG ("
//@ normalize-stderr: "os error \d+" -> "os error $$ACCESS_DENIED_CODE"
#[path = "../parser"]

View file

@ -1,4 +1,4 @@
error: couldn't read $DIR/../parser: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE)
error: couldn't read `$DIR/../parser`: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE)
--> $DIR/issue-5806.rs:5:1
|
LL | mod foo;

View file

@ -1,4 +1,4 @@
//@ normalize-stderr: "not_a_real_file.rs:.*\(" -> "not_a_real_file.rs: $$FILE_NOT_FOUND_MSG ("
//@ normalize-stderr: "not_a_real_file.rs`:.*\(" -> "not_a_real_file.rs`: $$FILE_NOT_FOUND_MSG ("
#[path = "not_a_real_file.rs"]
mod m; //~ ERROR not_a_real_file.rs

View file

@ -1,4 +1,4 @@
error: couldn't read $DIR/not_a_real_file.rs: $FILE_NOT_FOUND_MSG (os error 2)
error: couldn't read `$DIR/not_a_real_file.rs`: $FILE_NOT_FOUND_MSG (os error 2)
--> $DIR/mod_file_with_path_attr.rs:4:1
|
LL | mod m;

View file

@ -21,7 +21,7 @@ Box<dyn Any>
query stack during panic:
#0 [mir_built] building MIR for `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq`
#1 [check_unsafety] unsafety-checking `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq`
end of query stack
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0428`.

View file

@ -12,6 +12,6 @@ Box<dyn Any>
query stack during panic:
#0 [mir_built] building MIR for `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq`
#1 [check_unsafety] unsafety-checking `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq`
end of query stack
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 1 previous error

View file

@ -0,0 +1,12 @@
#![feature(never_patterns)]
#![allow(incomplete_features)]
enum E { A }
fn main() {
match E::A {
! | //~ ERROR: a trailing `|` is not allowed in an or-pattern
//~^ ERROR: mismatched types
if true => {} //~ ERROR: a never pattern is always unreachable
}
}

View file

@ -0,0 +1,33 @@
error: a trailing `|` is not allowed in an or-pattern
--> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:8:11
|
LL | ! |
| - ^
| |
| while parsing this or-pattern starting here
|
help: remove the `|`
|
LL - ! |
LL + !
|
error: a never pattern is always unreachable
--> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20
|
LL | if true => {}
| ^^
| |
| this will never be executed
| help: remove this expression
error: mismatched types
--> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:8:9
|
LL | ! |
| ^ a never pattern must be used on an uninhabited type
|
= note: the matched value is of type `E`
error: aborting due to 3 previous errors

View file

@ -0,0 +1,16 @@
#![feature(never_type)]
#![feature(never_patterns)]
#![allow(incomplete_features)]
enum Void {}
fn foo(x: Void) {
loop {
match x {
(!|!) if false => {} //~ ERROR a never pattern is always unreachable
_ => {}
}
}
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: a never pattern is always unreachable
--> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:10:31
|
LL | (!|!) if false => {}
| ^^
| |
| this will never be executed
| help: remove this expression
error: aborting due to 1 previous error

View file

@ -0,0 +1,14 @@
#![feature(never_type)]
#![feature(never_patterns)]
#![allow(incomplete_features)]
enum Void {}
fn foo(x: Void) {
match x {
(!|!) if true => {} //~ ERROR a never pattern is always unreachable
(!|!) if true => {} //~ ERROR a never pattern is always unreachable
}
}
fn main() {}

View file

@ -0,0 +1,20 @@
error: a never pattern is always unreachable
--> $DIR/ICE-133117-duplicate-never-arm.rs:9:26
|
LL | (!|!) if true => {}
| ^^
| |
| this will never be executed
| help: remove this expression
error: a never pattern is always unreachable
--> $DIR/ICE-133117-duplicate-never-arm.rs:10:26
|
LL | (!|!) if true => {}
| ^^
| |
| this will never be executed
| help: remove this expression
error: aborting due to 2 previous errors

View file

@ -0,0 +1,86 @@
error[E0658]: default values on fields are experimental
--> $DIR/non-exhaustive-ctor.rs:9:22
|
LL | pub field: () = (),
| ^^^^^
|
= note: see issue #132162 <https://github.com/rust-lang/rust/issues/132162> for more information
= help: add `#![feature(default_field_values)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: default values on fields are experimental
--> $DIR/non-exhaustive-ctor.rs:11:25
|
LL | pub field1: Priv = Priv,
| ^^^^^^^
|
= note: see issue #132162 <https://github.com/rust-lang/rust/issues/132162> for more information
= help: add `#![feature(default_field_values)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: default values on fields are experimental
--> $DIR/non-exhaustive-ctor.rs:13:25
|
LL | pub field2: Priv = Priv,
| ^^^^^^^
|
= note: see issue #132162 <https://github.com/rust-lang/rust/issues/132162> for more information
= help: add `#![feature(default_field_values)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0797]: base expression required after `..`
--> $DIR/non-exhaustive-ctor.rs:20:19
|
LL | let _ = S { .. }; // ok
| ^
|
help: add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields
|
LL + #![feature(default_field_values)]
|
help: add a base expression here
|
LL | let _ = S { ../* expr */ }; // ok
| ++++++++++
error[E0797]: base expression required after `..`
--> $DIR/non-exhaustive-ctor.rs:22:30
|
LL | let _ = S { field: (), .. }; // ok
| ^
|
help: add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields
|
LL + #![feature(default_field_values)]
|
help: add a base expression here
|
LL | let _ = S { field: (), ../* expr */ }; // ok
| ++++++++++
error[E0063]: missing fields `field`, `field1` and `field2` in initializer of `S`
--> $DIR/non-exhaustive-ctor.rs:24:13
|
LL | let _ = S { };
| ^ missing `field`, `field1` and `field2`
|
help: all remaining fields have default values, if you added `#![feature(default_field_values)]` to your crate you could use those values with `..`
|
LL | let _ = S { .. };
| ~~~~~~
error[E0063]: missing fields `field1` and `field2` in initializer of `S`
--> $DIR/non-exhaustive-ctor.rs:26:13
|
LL | let _ = S { field: () };
| ^ missing `field1` and `field2`
|
help: all remaining fields have default values, if you added `#![feature(default_field_values)]` to your crate you could use those values with `..`
|
LL | let _ = S { field: (), .. };
| ++++
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0063, E0658, E0797.
For more information about an error, try `rustc --explain E0063`.

View file

@ -0,0 +1,28 @@
//@ revisions: enabled disabled
//@[enabled] run-rustfix
#![allow(private_interfaces, dead_code)]
#![cfg_attr(enabled, feature(default_field_values))]
use m::S;
mod m {
pub struct S {
pub field: () = (),
//[disabled]~^ ERROR default values on fields are experimental
pub field1: Priv = Priv,
//[disabled]~^ ERROR default values on fields are experimental
pub field2: Priv = Priv,
//[disabled]~^ ERROR default values on fields are experimental
}
struct Priv;
}
fn main() {
let _ = S { .. }; // ok
//[disabled]~^ ERROR base expression required after `..`
let _ = S { field: (), .. }; // ok
//[disabled]~^ ERROR base expression required after `..`
let _ = S { .. };
//~^ ERROR missing fields `field`, `field1` and `field2`
let _ = S { field: (), .. };
//~^ ERROR missing fields `field1` and `field2`
}

View file

@ -0,0 +1,25 @@
error[E0063]: missing fields `field`, `field1` and `field2` in initializer of `S`
--> $DIR/non-exhaustive-ctor.rs:24:13
|
LL | let _ = S { };
| ^ missing `field`, `field1` and `field2`
|
help: all remaining fields have default values, you can use those values with `..`
|
LL | let _ = S { .. };
| ~~~~~~
error[E0063]: missing fields `field1` and `field2` in initializer of `S`
--> $DIR/non-exhaustive-ctor.rs:26:13
|
LL | let _ = S { field: () };
| ^ missing `field1` and `field2`
|
help: all remaining fields have default values, you can use those values with `..`
|
LL | let _ = S { field: (), .. };
| ++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0063`.

View file

@ -0,0 +1,28 @@
//@ revisions: enabled disabled
//@[enabled] run-rustfix
#![allow(private_interfaces, dead_code)]
#![cfg_attr(enabled, feature(default_field_values))]
use m::S;
mod m {
pub struct S {
pub field: () = (),
//[disabled]~^ ERROR default values on fields are experimental
pub field1: Priv = Priv,
//[disabled]~^ ERROR default values on fields are experimental
pub field2: Priv = Priv,
//[disabled]~^ ERROR default values on fields are experimental
}
struct Priv;
}
fn main() {
let _ = S { .. }; // ok
//[disabled]~^ ERROR base expression required after `..`
let _ = S { field: (), .. }; // ok
//[disabled]~^ ERROR base expression required after `..`
let _ = S { };
//~^ ERROR missing fields `field`, `field1` and `field2`
let _ = S { field: () };
//~^ ERROR missing fields `field1` and `field2`
}

View file

@ -1,4 +1,4 @@
error: couldn't read $DIR/lol: No such file or directory (os error 2)
error: couldn't read `$DIR/lol`: No such file or directory (os error 2)
--> $DIR/staged-api-invalid-path-108697.rs:8:1
|
LL | mod foo;