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 9 pull requests #106656

Merged
merged 43 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
76438d2
Add example for iterator_flatten
HintringerFabian Nov 28, 2022
083560b
Add result example + rewording
HintringerFabian Dec 13, 2022
11331b1
Enable atomic cas for bpf targets
tomerze Nov 26, 2022
564435f
Suppress suggestions for nested use tree
compiler-errors Dec 27, 2022
9e2536b
Note alternative import candidates in nested use tree
compiler-errors Dec 27, 2022
d2404d6
Dont clobber `as ..` rename in import suggestion
compiler-errors Dec 27, 2022
050bc95
Fix some totally useless suggestions
compiler-errors Dec 27, 2022
1296a4c
tweaks to retag diagnostic handling
RalfJung Jan 2, 2023
1010099
Auto merge of #2746 - RalfJung:retag-diagnostic, r=RalfJung
bors Jan 2, 2023
99fc745
Preparing for merge from rustc
RalfJung Jan 3, 2023
d96592b
Merge from rustc
RalfJung Jan 3, 2023
794cc08
clippy
RalfJung Jan 3, 2023
e1968dd
Auto merge of #2747 - RalfJung:rustup, r=RalfJung
bors Jan 3, 2023
23d3ee8
Revert "bootstrap: Get rid of `tail_args` in `stream_cargo`"
jyn514 Jan 2, 2023
54be8aa
Ignore symbol shim clash when symbol is provided by `compiler_builtins`
Aaron1011 Jan 6, 2023
a474872
Test again wasm32-unknown-unknown
Aaron1011 Jan 6, 2023
0f34039
Auto merge of #2748 - Aaron1011:wasm32-support, r=RalfJung
bors Jan 6, 2023
90600e0
Bump tokio from 1.23.0 to 1.23.1 in /test_dependencies
dependabot[bot] Jan 6, 2023
c0f5dc8
Auto merge of #2750 - rust-lang:dependabot/cargo/test_dependencies/to…
bors Jan 9, 2023
c364d32
Relocate changes
HintringerFabian Jan 9, 2023
5977a16
make env::current_exe work on Windows
RalfJung Jan 9, 2023
87a202e
Auto merge of #2752 - RalfJung:win-env-current-exe, r=RalfJung
bors Jan 9, 2023
8740443
Preparing for merge from rustc
RalfJung Jan 9, 2023
236ae26
Merge from rustc
RalfJung Jan 9, 2023
d61d359
Auto merge of #2753 - RalfJung:rustup, r=RalfJung
bors Jan 9, 2023
85e87a8
add dtors_in_dtors_in_dtors
RalfJung Jan 9, 2023
cb15925
Auto merge of #2755 - RalfJung:dtors_in_dtors_in_dtors, r=RalfJung
bors Jan 9, 2023
31099ee
update test for inductive canonical cycles
lcnr Jan 9, 2023
42aa075
Accept old spelling of Fuchsia target triples
Jan 9, 2023
5132e13
No need to take opaques in check_type_bounds
compiler-errors Dec 24, 2022
1d66a67
review comment
compiler-errors Jan 9, 2023
1c766d0
rustdoc: merge common CSS for `a`
notriddle Jan 9, 2023
f769d34
Assert defining anchor is set in take_opaque_types
compiler-errors Jan 9, 2023
9c23629
Add issue number to FIXMEs
tmandry Jan 9, 2023
002eccc
Rollup merge of #105034 - HintringerFabian:improve_iterator_flatten_d…
Jan 9, 2023
5773e8b
Rollup merge of #105708 - tomerze:enable-atomic-cas-bpf, r=nagisa
Jan 9, 2023
684a371
Rollup merge of #106175 - compiler-errors:bad-import-sugg, r=oli-obk
Jan 9, 2023
e5e116d
Rollup merge of #106204 - compiler-errors:no-take-opaques-in-compare,…
Jan 9, 2023
b102673
Rollup merge of #106387 - jyn514:clippy, r=Mark-Simulacrum
Jan 9, 2023
96e53c0
Rollup merge of #106636 - djkoloski:accept_old_fuchsia_triple, r=tmandry
Jan 9, 2023
0ba27de
Rollup merge of #106639 - RalfJung:miri, r=RalfJung
Jan 9, 2023
9bed3d9
Rollup merge of #106640 - lcnr:update-test, r=jackh726
Jan 9, 2023
ed840a6
Rollup merge of #106647 - notriddle:notriddle/a, r=GuillaumeGomez
Jan 9, 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_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {

// This is still required for many(half of the tests in ui/type-alias-impl-trait)
// tests to pass
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
let _ = infcx.take_opaque_types();

if errors.is_empty() {
definition_ty
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
);

translate_outlives_facts(&mut checker);
let opaque_type_values = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
let opaque_type_values = infcx.take_opaque_types();

let opaque_type_values = opaque_type_values
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/util/compare_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ pub fn is_subtype<'tcx>(
// even if they're constrained in our current function.
//
// It seems very unlikely that this hides any bugs.
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
let _ = infcx.take_opaque_types();
errors.is_empty()
}
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ fn check_opaque_meets_bounds<'tcx>(
}
}
// Clean up after ourselves
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
let _ = infcx.take_opaque_types();
}

fn is_enum_of_nonnullable_ptr<'tcx>(
Expand Down
18 changes: 1 addition & 17 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ fn compare_asyncness<'tcx>(
ty::Alias(ty::Opaque, ..) => {
// allow both `async fn foo()` and `fn foo() -> impl Future`
}
ty::Error(rustc_errors::ErrorGuaranteed { .. }) => {
ty::Error(_) => {
// We don't know if it's ok, but at least it's already an error.
}
_ => {
Expand Down Expand Up @@ -1972,22 +1972,6 @@ pub(super) fn check_type_bounds<'tcx>(
&outlives_environment,
)?;

let constraints = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
for (key, value) in constraints {
infcx
.err_ctxt()
.report_mismatched_types(
&ObligationCause::misc(
value.hidden_type.span,
tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local()),
),
tcx.mk_opaque(key.def_id.to_def_id(), key.substs),
value.hidden_type.ty,
TypeError::Mismatch,
)
.emit();
}

Ok(())
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_hir_typeck/src/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {

#[instrument(skip(self), level = "debug")]
fn visit_opaque_types(&mut self) {
let opaque_types =
self.fcx.infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
let opaque_types = self.fcx.infcx.take_opaque_types();
for (opaque_type_key, decl) in opaque_types {
let hidden_type = self.resolve(decl.hidden_type, &decl.hidden_type.span);
let opaque_type_key = self.resolve(opaque_type_key, &decl.hidden_type.span);
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_infer/src/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ impl<'tcx> InferCtxt<'tcx> {
/// As the new solver does canonicalization slightly differently, this is also used there
/// for now. This should hopefully change fairly soon.
pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
self.inner
.borrow_mut()
.opaque_type_storage
.take_opaque_types()
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
.into_iter()
.map(|(k, v)| (self.tcx.mk_opaque(k.def_id.to_def_id(), k.substs), v.hidden_type.ty))
.collect()
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,12 @@ impl<'tcx> InferCtxt<'tcx> {
var_infos
}

#[instrument(level = "debug", skip(self), ret)]
pub fn take_opaque_types(&self) -> opaque_types::OpaqueTypeMap<'tcx> {
debug_assert_ne!(self.defining_use_anchor, DefiningAnchor::Error);
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
}

pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
self.resolve_vars_if_possible(t).to_string()
}
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_infer/src/infer/opaque_types/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
}
}

#[instrument(level = "debug", ret)]
pub fn take_opaque_types(&mut self) -> OpaqueTypeMap<'tcx> {
std::mem::take(&mut self.opaque_types)
}

#[inline]
pub(crate) fn with_log<'a>(
&'a mut self,
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl<'a> Resolver<'a> {
found_use,
DiagnosticMode::Normal,
path,
"",
);
err.emit();
} else if let Some((span, msg, sugg, appl)) = suggestion {
Expand Down Expand Up @@ -690,6 +691,7 @@ impl<'a> Resolver<'a> {
FoundUse::Yes,
DiagnosticMode::Pattern,
vec![],
"",
);
}
err
Expand Down Expand Up @@ -1344,6 +1346,7 @@ impl<'a> Resolver<'a> {
FoundUse::Yes,
DiagnosticMode::Normal,
vec![],
"",
);

if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
Expand Down Expand Up @@ -2309,7 +2312,7 @@ enum FoundUse {
}

/// Whether a binding is part of a pattern or a use statement. Used for diagnostics.
enum DiagnosticMode {
pub(crate) enum DiagnosticMode {
Normal,
/// The binding is part of a pattern
Pattern,
Expand All @@ -2324,6 +2327,8 @@ pub(crate) fn import_candidates(
// This is `None` if all placement locations are inside expansions
use_placement_span: Option<Span>,
candidates: &[ImportSuggestion],
mode: DiagnosticMode,
append: &str,
) {
show_candidates(
session,
Expand All @@ -2333,8 +2338,9 @@ pub(crate) fn import_candidates(
candidates,
Instead::Yes,
FoundUse::Yes,
DiagnosticMode::Import,
mode,
vec![],
append,
);
}

Expand All @@ -2352,6 +2358,7 @@ fn show_candidates(
found_use: FoundUse,
mode: DiagnosticMode,
path: Vec<Segment>,
append: &str,
) {
if candidates.is_empty() {
return;
Expand Down Expand Up @@ -2416,7 +2423,7 @@ fn show_candidates(
// produce an additional newline to separate the new use statement
// from the directly following item.
let additional_newline = if let FoundUse::Yes = found_use { "" } else { "\n" };
candidate.0 = format!("{}{};\n{}", add_use, &candidate.0, additional_newline);
candidate.0 = format!("{add_use}{}{append};\n{additional_newline}", &candidate.0);
}

err.span_suggestions(
Expand Down
81 changes: 55 additions & 26 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A bunch of methods and structures more or less related to resolving imports.

use crate::diagnostics::{import_candidates, Suggestion};
use crate::diagnostics::{import_candidates, DiagnosticMode, Suggestion};
use crate::Determinacy::{self, *};
use crate::Namespace::*;
use crate::{module_to_string, names_to_string, ImportSuggestion};
Expand Down Expand Up @@ -402,7 +402,7 @@ struct UnresolvedImportError {
label: Option<String>,
note: Option<String>,
suggestion: Option<Suggestion>,
candidate: Option<Vec<ImportSuggestion>>,
candidates: Option<Vec<ImportSuggestion>>,
}

pub struct ImportResolver<'a, 'b> {
Expand Down Expand Up @@ -475,12 +475,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
errors = vec![];
}
if seen_spans.insert(err.span) {
let path = import_path_to_string(
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
&import.kind,
err.span,
);
errors.push((path, err));
errors.push((import, err));
prev_root_id = import.root_id;
}
} else if is_indeterminate {
Expand All @@ -494,10 +489,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
label: None,
note: None,
suggestion: None,
candidate: None,
candidates: None,
};
// FIXME: there should be a better way of doing this than
// formatting this as a string then checking for `::`
if path.contains("::") {
errors.push((path, err))
errors.push((import, err))
}
}
}
Expand All @@ -507,7 +504,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
}
}

fn throw_unresolved_import_error(&self, errors: Vec<(String, UnresolvedImportError)>) {
fn throw_unresolved_import_error(&self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) {
if errors.is_empty() {
return;
}
Expand All @@ -516,7 +513,17 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
const MAX_LABEL_COUNT: usize = 10;

let span = MultiSpan::from_spans(errors.iter().map(|(_, err)| err.span).collect());
let paths = errors.iter().map(|(path, _)| format!("`{}`", path)).collect::<Vec<_>>();
let paths = errors
.iter()
.map(|(import, err)| {
let path = import_path_to_string(
&import.module_path.iter().map(|seg| seg.ident).collect::<Vec<_>>(),
&import.kind,
err.span,
);
format!("`{path}`")
})
.collect::<Vec<_>>();
let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),);

let mut diag = struct_span_err!(self.r.session, span, E0432, "{}", &msg);
Expand All @@ -525,7 +532,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
diag.note(note);
}

for (_, err) in errors.into_iter().take(MAX_LABEL_COUNT) {
for (import, err) in errors.into_iter().take(MAX_LABEL_COUNT) {
if let Some(label) = err.label {
diag.span_label(err.span, label);
}
Expand All @@ -538,14 +545,36 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
diag.multipart_suggestion(&msg, suggestions, applicability);
}

if let Some(candidate) = &err.candidate {
import_candidates(
self.r.session,
&self.r.untracked.source_span,
&mut diag,
Some(err.span),
&candidate,
)
if let Some(candidates) = &err.candidates {
match &import.kind {
ImportKind::Single { nested: false, source, target, .. } => import_candidates(
self.r.session,
&self.r.untracked.source_span,
&mut diag,
Some(err.span),
&candidates,
DiagnosticMode::Import,
(source != target)
.then(|| format!(" as {target}"))
.as_deref()
.unwrap_or(""),
),
ImportKind::Single { nested: true, source, target, .. } => {
import_candidates(
self.r.session,
&self.r.untracked.source_span,
&mut diag,
None,
&candidates,
DiagnosticMode::Normal,
(source != target)
.then(|| format!(" as {target}"))
.as_deref()
.unwrap_or(""),
);
}
_ => {}
}
}
}

Expand Down Expand Up @@ -707,14 +736,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
String::from("a similar path exists"),
Applicability::MaybeIncorrect,
)),
candidate: None,
candidates: None,
},
None => UnresolvedImportError {
span,
label: Some(label),
note: None,
suggestion,
candidate: None,
candidates: None,
},
};
return Some(err);
Expand Down Expand Up @@ -761,7 +790,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
)),
note: None,
suggestion: None,
candidate: None,
candidates: None,
});
}
}
Expand Down Expand Up @@ -873,7 +902,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
let resolutions = resolutions.as_ref().into_iter().flat_map(|r| r.iter());
let names = resolutions
.filter_map(|(BindingKey { ident: i, .. }, resolution)| {
if *i == ident {
if i.name == ident.name {
return None;
} // Never suggest the same name
match *resolution.borrow() {
Expand Down Expand Up @@ -943,7 +972,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
label: Some(label),
note,
suggestion,
candidate: if !parent_suggestion.is_empty() {
candidates: if !parent_suggestion.is_empty() {
Some(parent_suggestion)
} else {
None
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/aarch64_fuchsia.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use crate::spec::aarch64_unknown_fuchsia::target;
6 changes: 5 additions & 1 deletion compiler/rustc_target/src/spec/bpf_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn opts(endian: Endian) -> TargetOptions {
allow_asm: true,
endian,
linker_flavor: LinkerFlavor::Bpf,
atomic_cas: false,
atomic_cas: true,
dynamic_linking: true,
no_builtins: true,
panic_strategy: PanicStrategy::Abort,
Expand All @@ -19,6 +19,10 @@ pub fn opts(endian: Endian) -> TargetOptions {
obj_is_bitcode: true,
requires_lto: false,
singlethread: true,
// When targeting the `v3` cpu in llvm, 32-bit atomics are also supported.
// But making this value change based on the target cpu can be mostly confusing
// and would require a bit of a refactor.
min_atomic_width: Some(64),
max_atomic_width: Some(64),
..Default::default()
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ impl fmt::Display for StackProtector {
}

macro_rules! supported_targets {
( $(($triple:literal, $module:ident ),)+ ) => {
( $(($triple:literal, $module:ident),)+ ) => {
$(mod $module;)+

/// List of supported targets
Expand Down Expand Up @@ -1109,7 +1109,11 @@ supported_targets! {
("x86_64-apple-darwin", x86_64_apple_darwin),
("i686-apple-darwin", i686_apple_darwin),

// FIXME(#106649): Remove aarch64-fuchsia in favor of aarch64-unknown-fuchsia
("aarch64-fuchsia", aarch64_fuchsia),
("aarch64-unknown-fuchsia", aarch64_unknown_fuchsia),
// FIXME(#106649): Remove x86_64-fuchsia in favor of x86_64-unknown-fuchsia
("x86_64-fuchsia", x86_64_fuchsia),
("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia),

("avr-unknown-gnu-atmega328", avr_unknown_gnu_atmega328),
Expand Down
Loading