Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bd39bbb

Browse files
committedFeb 7, 2023
Auto merge of rust-lang#107767 - matthiaskrgr:rollup-9m1qfso, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#100599 (Add compiler error E0523 long description and test) - rust-lang#107471 (rustdoc: do not include empty default-settings tag in HTML) - rust-lang#107555 (Modify existing bounds if they exist) - rust-lang#107662 (Turn projections into copies in CopyProp.) - rust-lang#107695 (Add test for Future inflating arg size to 3x ) - rust-lang#107700 (Run the tools builder on all PRs) - rust-lang#107706 (Mark 'atomic_mut_ptr' methods const) - rust-lang#107709 (Fix problem noticed in PR106859 with char -> u8 suggestion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5dd0e1b + 0e3af6a commit bd39bbb

File tree

36 files changed

+492
-109
lines changed

36 files changed

+492
-109
lines changed
 

‎.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ jobs:
6060
env: {}
6161
- name: x86_64-gnu-tools
6262
tidy: false
63-
env:
64-
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
6563
os: ubuntu-20.04-xl
64+
env: {}
6665
timeout-minutes: 600
6766
runs-on: "${{ matrix.os }}"
6867
steps:

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
803803
predicates
804804
.iter()
805805
.map(|(param, constraint)| (param.name.as_str(), &**constraint, None)),
806+
None,
806807
);
807808
}
808809
}

‎compiler/rustc_const_eval/src/transform/check_consts/ops.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
136136
&param_ty.name.as_str(),
137137
&constraint,
138138
None,
139+
None,
139140
);
140141
}
141142
}

‎compiler/rustc_error_codes/src/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ E0519: include_str!("./error_codes/E0519.md"),
286286
E0520: include_str!("./error_codes/E0520.md"),
287287
E0521: include_str!("./error_codes/E0521.md"),
288288
E0522: include_str!("./error_codes/E0522.md"),
289+
E0523: include_str!("./error_codes/E0523.md"),
289290
E0524: include_str!("./error_codes/E0524.md"),
290291
E0525: include_str!("./error_codes/E0525.md"),
291292
E0527: include_str!("./error_codes/E0527.md"),
@@ -622,7 +623,6 @@ E0793: include_str!("./error_codes/E0793.md"),
622623
// E0488, // lifetime of variable does not enclose its declaration
623624
// E0489, // type/lifetime parameter not in scope here
624625
// E0490, // removed: unreachable
625-
E0523, // two dependencies have same (crate-name, disambiguator) but different SVH
626626
// E0526, // shuffle indices are not constant
627627
// E0540, // multiple rustc_deprecated attributes
628628
// E0548, // replaced with a generic attribute input check
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
The compiler found multiple library files with the requested crate name.
22

3+
```compile_fail
4+
// aux-build:crateresolve-1.rs
5+
// aux-build:crateresolve-2.rs
6+
// aux-build:crateresolve-3.rs
7+
8+
extern crate crateresolve;
9+
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found
10+
11+
fn main() {}
12+
```
13+
314
This error can occur in several different cases -- for example, when using
415
`extern crate` or passing `--extern` options without crate paths. It can also be
516
caused by caching issues with the build directory, in which case `cargo clean`
617
may help.
18+
19+
In the above example, there are three different library files, all of which
20+
define the same crate name. Without providing a full path, there is no way for
21+
the compiler to know which crate it should use.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
3+
The compiler found multiple library files with the requested crate name.
4+
5+
```compile_fail
6+
// aux-build:crateresolve-1.rs
7+
// aux-build:crateresolve-2.rs
8+
// aux-build:crateresolve-3.rs
9+
10+
extern crate crateresolve;
11+
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found
12+
13+
fn main() {}
14+
```
15+
16+
This error can occur in several different cases -- for example, when using
17+
`extern crate` or passing `--extern` options without crate paths. It can also be
18+
caused by caching issues with the build directory, in which case `cargo clean`
19+
may help.
20+
21+
In the above example, there are three different library files, all of which
22+
define the same crate name. Without providing a full path, there is no way for
23+
the compiler to know which crate it should use.
24+
25+
*Note that E0523 has been merged into E0464.*

‎compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
176176
bounds.iter().map(|(param, constraint, def_id)| {
177177
(param.as_str(), constraint.as_str(), *def_id)
178178
}),
179+
None,
179180
);
180181
err.emit();
181182
}

‎compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14571457
generics,
14581458
diag,
14591459
vec![(param.name.as_str(), "Clone", Some(clone_trait_did))].into_iter(),
1460+
None,
14601461
);
14611462
} else {
14621463
self.suggest_derive(diag, &[(trait_ref.to_predicate(self.tcx), None, None)]);

‎compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19221922
(ty::Uint(ty::UintTy::U8), ty::Char) => {
19231923
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span)
19241924
&& let Some(code) = code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
1925-
&& code.chars().next().map_or(false, |c| c.is_ascii())
1925+
&& !code.starts_with("\\u") // forbid all Unicode escapes
1926+
&& code.chars().next().map_or(false, |c| c.is_ascii()) // forbids literal Unicode characters beyond ASCII
19261927
{
19271928
err.span_suggestion(
19281929
span,

‎compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,49 +77,86 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
7777
(ty::Param(p), ty::Alias(ty::Projection, proj)) | (ty::Alias(ty::Projection, proj), ty::Param(p))
7878
if tcx.def_kind(proj.def_id) != DefKind::ImplTraitPlaceholder =>
7979
{
80-
let generics = tcx.generics_of(body_owner_def_id);
81-
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
80+
let p_def_id = tcx
81+
.generics_of(body_owner_def_id)
82+
.type_param(p, tcx)
83+
.def_id;
84+
let p_span = tcx.def_span(p_def_id);
8285
if !sp.contains(p_span) {
8386
diag.span_label(p_span, "this type parameter");
8487
}
8588
let hir = tcx.hir();
8689
let mut note = true;
87-
if let Some(generics) = generics
88-
.type_param(p, tcx)
89-
.def_id
90+
let parent = p_def_id
9091
.as_local()
91-
.map(|id| hir.local_def_id_to_hir_id(id))
92-
.and_then(|id| tcx.hir().find_parent(id))
93-
.as_ref()
94-
.and_then(|node| node.generics())
92+
.and_then(|id| {
93+
let local_id = hir.local_def_id_to_hir_id(id);
94+
let generics = tcx.hir().find_parent(local_id)?.generics()?;
95+
Some((id, generics))
96+
});
97+
if let Some((local_id, generics)) = parent
9598
{
9699
// Synthesize the associated type restriction `Add<Output = Expected>`.
97100
// FIXME: extract this logic for use in other diagnostics.
98101
let (trait_ref, assoc_substs) = proj.trait_ref_and_own_substs(tcx);
99-
let path =
100-
tcx.def_path_str_with_substs(trait_ref.def_id, trait_ref.substs);
101102
let item_name = tcx.item_name(proj.def_id);
102103
let item_args = self.format_generic_args(assoc_substs);
103104

104-
let path = if path.ends_with('>') {
105-
format!(
106-
"{}, {}{} = {}>",
107-
&path[..path.len() - 1],
108-
item_name,
109-
item_args,
110-
p
111-
)
105+
// Here, we try to see if there's an existing
106+
// trait implementation that matches the one that
107+
// we're suggesting to restrict. If so, find the
108+
// "end", whether it be at the end of the trait
109+
// or the end of the generic arguments.
110+
let mut matching_span = None;
111+
let mut matched_end_of_args = false;
112+
for bound in generics.bounds_for_param(local_id) {
113+
let potential_spans = bound
114+
.bounds
115+
.iter()
116+
.find_map(|bound| {
117+
let bound_trait_path = bound.trait_ref()?.path;
118+
let def_id = bound_trait_path.res.opt_def_id()?;
119+
let generic_args = bound_trait_path.segments.iter().last().map(|path| path.args());
120+
(def_id == trait_ref.def_id).then_some((bound_trait_path.span, generic_args))
121+
});
122+
123+
if let Some((end_of_trait, end_of_args)) = potential_spans {
124+
let args_span = end_of_args.and_then(|args| args.span());
125+
matched_end_of_args = args_span.is_some();
126+
matching_span = args_span
127+
.or_else(|| Some(end_of_trait))
128+
.map(|span| span.shrink_to_hi());
129+
break;
130+
}
131+
}
132+
133+
if matched_end_of_args {
134+
// Append suggestion to the end of our args
135+
let path = format!(", {}{} = {}",item_name, item_args, p);
136+
note = !suggest_constraining_type_param(
137+
tcx,
138+
generics,
139+
diag,
140+
&format!("{}", proj.self_ty()),
141+
&path,
142+
None,
143+
matching_span,
144+
);
112145
} else {
113-
format!("{}<{}{} = {}>", path, item_name, item_args, p)
114-
};
115-
note = !suggest_constraining_type_param(
116-
tcx,
117-
generics,
118-
diag,
119-
&format!("{}", proj.self_ty()),
120-
&path,
121-
None,
122-
);
146+
// Suggest adding a bound to an existing trait
147+
// or if the trait doesn't exist, add the trait
148+
// and the suggested bounds.
149+
let path = format!("<{}{} = {}>", item_name, item_args, p);
150+
note = !suggest_constraining_type_param(
151+
tcx,
152+
generics,
153+
diag,
154+
&format!("{}", proj.self_ty()),
155+
&path,
156+
None,
157+
matching_span,
158+
);
159+
}
123160
}
124161
if note {
125162
diag.note("you might be missing a type parameter or trait bound");

‎compiler/rustc_metadata/src/creader.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,12 @@ impl<'a> CrateLoader<'a> {
356356
for (_, other) in self.cstore.iter_crate_data() {
357357
// Same stable crate id but different SVH
358358
if other.stable_crate_id() == root.stable_crate_id() && other.hash() != root.hash() {
359-
return Err(CrateError::SymbolConflictsOthers(root.name()));
359+
bug!(
360+
"Previously returned E0523 here. \
361+
See https://github.com/rust-lang/rust/pull/100599 for additional discussion.\
362+
root.name() = {}.",
363+
root.name()
364+
);
360365
}
361366
}
362367

‎compiler/rustc_metadata/src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,6 @@ pub struct SymbolConflictsCurrent {
511511
pub crate_name: Symbol,
512512
}
513513

514-
#[derive(Diagnostic)]
515-
#[diag(metadata_symbol_conflicts_others, code = "E0523")]
516-
pub struct SymbolConflictsOthers {
517-
#[primary_span]
518-
pub span: Span,
519-
pub crate_name: Symbol,
520-
}
521-
522514
#[derive(Diagnostic)]
523515
#[diag(metadata_stable_crate_id_collision)]
524516
pub struct StableCrateIdCollision {

‎compiler/rustc_metadata/src/locator.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ pub(crate) enum CrateError {
945945
ExternLocationNotFile(Symbol, PathBuf),
946946
MultipleCandidates(Symbol, CrateFlavor, Vec<PathBuf>),
947947
SymbolConflictsCurrent(Symbol),
948-
SymbolConflictsOthers(Symbol),
949948
StableCrateIdCollision(Symbol, Symbol),
950949
DlOpen(String),
951950
DlSym(String),
@@ -989,9 +988,6 @@ impl CrateError {
989988
CrateError::SymbolConflictsCurrent(root_name) => {
990989
sess.emit_err(errors::SymbolConflictsCurrent { span, crate_name: root_name });
991990
}
992-
CrateError::SymbolConflictsOthers(root_name) => {
993-
sess.emit_err(errors::SymbolConflictsOthers { span, crate_name: root_name });
994-
}
995991
CrateError::StableCrateIdCollision(crate_name0, crate_name1) => {
996992
sess.emit_err(errors::StableCrateIdCollision { span, crate_name0, crate_name1 });
997993
}

‎compiler/rustc_middle/src/ty/diagnostics.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,24 @@ fn suggest_removing_unsized_bound(
193193
}
194194

195195
/// Suggest restricting a type param with a new bound.
196+
///
197+
/// If `span_to_replace` is provided, then that span will be replaced with the
198+
/// `constraint`. If one wasn't provided, then the full bound will be suggested.
196199
pub fn suggest_constraining_type_param(
197200
tcx: TyCtxt<'_>,
198201
generics: &hir::Generics<'_>,
199202
err: &mut Diagnostic,
200203
param_name: &str,
201204
constraint: &str,
202205
def_id: Option<DefId>,
206+
span_to_replace: Option<Span>,
203207
) -> bool {
204208
suggest_constraining_type_params(
205209
tcx,
206210
generics,
207211
err,
208212
[(param_name, constraint, def_id)].into_iter(),
213+
span_to_replace,
209214
)
210215
}
211216

@@ -215,6 +220,7 @@ pub fn suggest_constraining_type_params<'a>(
215220
generics: &hir::Generics<'_>,
216221
err: &mut Diagnostic,
217222
param_names_and_constraints: impl Iterator<Item = (&'a str, &'a str, Option<DefId>)>,
223+
span_to_replace: Option<Span>,
218224
) -> bool {
219225
let mut grouped = FxHashMap::default();
220226
param_names_and_constraints.for_each(|(param_name, constraint, def_id)| {
@@ -253,7 +259,9 @@ pub fn suggest_constraining_type_params<'a>(
253259
let mut suggest_restrict = |span, bound_list_non_empty| {
254260
suggestions.push((
255261
span,
256-
if bound_list_non_empty {
262+
if span_to_replace.is_some() {
263+
constraint.clone()
264+
} else if bound_list_non_empty {
257265
format!(" + {}", constraint)
258266
} else {
259267
format!(" {}", constraint)
@@ -262,6 +270,11 @@ pub fn suggest_constraining_type_params<'a>(
262270
))
263271
};
264272

273+
if let Some(span) = span_to_replace {
274+
suggest_restrict(span, true);
275+
continue;
276+
}
277+
265278
// When the type parameter has been provided bounds
266279
//
267280
// Message:

‎compiler/rustc_mir_transform/src/copy_prop.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
153153

154154
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) {
155155
if let Operand::Move(place) = *operand
156-
&& let Some(local) = place.as_local()
157-
&& !self.fully_moved.contains(local)
156+
// A move out of a projection of a copy is equivalent to a copy of the original projection.
157+
&& !place.has_deref()
158+
&& !self.fully_moved.contains(place.local)
158159
{
159160
*operand = Operand::Copy(place);
160161
}

‎compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
679679
&param_name,
680680
&constraint,
681681
Some(trait_pred.def_id()),
682+
None,
682683
) {
683684
return;
684685
}
@@ -1087,6 +1088,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
10871088
param.name.as_str(),
10881089
"Clone",
10891090
Some(clone_trait),
1091+
None,
10901092
);
10911093
}
10921094
err.span_suggestion_verbose(

‎library/core/src/sync/atomic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,8 @@ impl AtomicBool {
928928
/// ```
929929
#[inline]
930930
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
931-
pub fn as_mut_ptr(&self) -> *mut bool {
932-
self.v.get() as *mut bool
931+
pub const fn as_mut_ptr(&self) -> *mut bool {
932+
self.v.get().cast()
933933
}
934934

935935
/// Fetches the value, and applies a function to it that returns an optional
@@ -1803,7 +1803,7 @@ impl<T> AtomicPtr<T> {
18031803
///
18041804
/// ```ignore (extern-declaration)
18051805
/// #![feature(atomic_mut_ptr)]
1806-
//// use std::sync::atomic::AtomicPtr;
1806+
/// use std::sync::atomic::AtomicPtr;
18071807
///
18081808
/// extern "C" {
18091809
/// fn my_atomic_op(arg: *mut *mut u32);
@@ -1819,7 +1819,7 @@ impl<T> AtomicPtr<T> {
18191819
/// ```
18201820
#[inline]
18211821
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
1822-
pub fn as_mut_ptr(&self) -> *mut *mut T {
1822+
pub const fn as_mut_ptr(&self) -> *mut *mut T {
18231823
self.p.get()
18241824
}
18251825
}
@@ -2727,7 +2727,7 @@ macro_rules! atomic_int {
27272727
#[unstable(feature = "atomic_mut_ptr",
27282728
reason = "recently added",
27292729
issue = "66893")]
2730-
pub fn as_mut_ptr(&self) -> *mut $int_type {
2730+
pub const fn as_mut_ptr(&self) -> *mut $int_type {
27312731
self.v.get()
27322732
}
27332733
}

‎src/ci/github-actions/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ jobs:
307307
- name: x86_64-gnu-tools
308308
<<: *job-linux-xl
309309
tidy: false
310-
env:
311-
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
312310

313311
auto:
314312
permissions:

‎src/ci/scripts/should-skip-this.sh

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
11
#!/bin/bash
2-
# Set the SKIP_JOB environment variable if this job is supposed to only run
3-
# when submodules are updated and they were not. The following time consuming
4-
# tasks will be skipped when the environment variable is present.
2+
# Set the SKIP_JOB environment variable if this job is not supposed to run on the current builder.
53

64
set -euo pipefail
75
IFS=$'\n\t'
86

97
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
108

11-
if [[ -n "${CI_ONLY_WHEN_SUBMODULES_CHANGED-}" ]]; then
12-
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
13-
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
14-
15-
echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
16-
17-
if git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
18-
# Submodules pseudo-files inside git have the 160000 permissions, so when
19-
# those files are present in the diff a submodule was updated.
20-
echo "Submodules were updated"
21-
elif ! (git diff --quiet "$BASE_COMMIT" -- \
22-
src/tools/clippy src/tools/rustfmt src/tools/miri \
23-
library/std/src/sys); then
24-
# There is not an easy blanket search for subtrees. For now, manually list
25-
# the subtrees.
26-
# Also run this when the platform-specific parts of std change, in case
27-
# that breaks Miri.
28-
echo "Tool subtrees were updated"
29-
elif ! (git diff --quiet "$BASE_COMMIT" -- \
30-
tests/rustdoc-gui \
31-
src/librustdoc \
32-
src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile \
33-
src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version \
34-
src/tools/rustdoc-gui); then
35-
# There was a change in either rustdoc or in its GUI tests.
36-
echo "Rustdoc was updated"
37-
else
38-
echo "Not executing this job since no submodules nor subtrees were updated"
39-
ciCommandSetEnv SKIP_JOB 1
40-
exit 0
41-
fi
42-
fi
43-
449
if [[ -n "${CI_ONLY_WHEN_CHANNEL-}" ]]; then
4510
if [[ "${CI_ONLY_WHEN_CHANNEL}" = "$(cat src/ci/channel)" ]]; then
4611
echo "The channel is the expected one"

‎src/librustdoc/html/templates/page.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
{%- for theme in themes -%}
2424
<link rel="stylesheet" disabled href="{{page.root_path|safe}}{{theme}}{{page.resource_suffix}}.css"> {#- -#}
2525
{%- endfor -%}
26+
{%- if !layout.default_settings.is_empty() -%}
2627
<script id="default-settings" {# -#}
2728
{% for (k, v) in layout.default_settings %}
2829
data-{{k}}="{{v}}"
2930
{%- endfor -%}
3031
></script> {#- -#}
32+
{%- endif -%}
3133
<script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {#- -#}
3234
{%- if page.css_class.contains("crate") -%}
3335
<script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {#- -#}

‎src/tools/tidy/src/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E06
3131

3232
// Error codes that don't yet have a UI test. This list will eventually be removed.
3333
const IGNORE_UI_TEST_CHECK: &[&str] =
34-
&["E0461", "E0465", "E0476", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729"];
34+
&["E0461", "E0465", "E0476", "E0514", "E0554", "E0640", "E0717", "E0729"];
3535

3636
macro_rules! verbose_print {
3737
($verbose:expr, $($fmt:tt)*) => {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- // MIR for `f` before CopyProp
2+
+ // MIR for `f` after CopyProp
3+
4+
fn f(_1: Foo) -> bool {
5+
let mut _0: bool; // return place in scope 0 at $DIR/move_projection.rs:+0:17: +0:21
6+
let mut _2: Foo; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
7+
let mut _3: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
8+
9+
bb0: {
10+
- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
11+
- _3 = move (_2.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
12+
- _0 = opaque::<Foo>(move _1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44
13+
+ _3 = (_1.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
14+
+ _0 = opaque::<Foo>(_1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44
15+
// mir::Constant
16+
// + span: $DIR/move_projection.rs:19:28: 19:34
17+
// + literal: Const { ty: fn(Foo) -> bool {opaque::<Foo>}, val: Value(<ZST>) }
18+
}
19+
20+
bb1: {
21+
_0 = opaque::<u8>(move _3) -> bb2; // scope 0 at $DIR/move_projection.rs:+9:13: +9:44
22+
// mir::Constant
23+
// + span: $DIR/move_projection.rs:22:28: 22:34
24+
// + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) }
25+
}
26+
27+
bb2: {
28+
return; // scope 0 at $DIR/move_projection.rs:+12:13: +12:21
29+
}
30+
}
31+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// unit-test: CopyProp
2+
3+
#![feature(custom_mir, core_intrinsics)]
4+
#![allow(unused_assignments)]
5+
extern crate core;
6+
use core::intrinsics::mir::*;
7+
8+
fn opaque(_: impl Sized) -> bool { true }
9+
10+
struct Foo(u8);
11+
12+
#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
13+
fn f(a: Foo) -> bool {
14+
mir!(
15+
{
16+
let b = a;
17+
// This is a move out of a copy, so must become a copy of `a.0`.
18+
let c = Move(b.0);
19+
Call(RET, bb1, opaque(Move(a)))
20+
}
21+
bb1 = {
22+
Call(RET, ret, opaque(Move(c)))
23+
}
24+
ret = {
25+
Return()
26+
}
27+
)
28+
}
29+
30+
fn main() {
31+
assert!(f(Foo(0)));
32+
}
33+
34+
// EMIT_MIR move_projection.f.CopyProp.diff

‎tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn ezmap(_1: Option<i32>) -> Option<i32> {
3434
}
3535

3636
bb3: {
37-
_4 = move ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
37+
_4 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
3838
StorageLive(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
3939
_5 = Add(_4, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21
4040
_0 = Option::<i32>::Some(move _5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30

‎tests/ui/associated-types/hr-associated-type-projection-1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ LL | for<'b> <Self as UnsafeCopy<'b, T>>::Item: std::ops::Deref<Target = T>,
1616
| ^^^^^^^^^^ required by this bound in `UnsafeCopy`
1717
help: consider further restricting this bound
1818
|
19-
LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<'_, T> for T {
20-
| +++++++++++++++++++
19+
LL | impl<T: Copy + std::ops::Deref<Target = T>> UnsafeCopy<'_, T> for T {
20+
| ++++++++++++
2121

2222
error: aborting due to previous error
2323

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// compile-flags: -Z print-type-sizes --crate-type lib
2+
// edition:2021
3+
// build-pass
4+
// ignore-pass
5+
6+
async fn wait() {}
7+
8+
async fn big_fut(arg: [u8; 1024]) {}
9+
10+
async fn calls_fut(fut: impl std::future::Future<Output = ()>) {
11+
loop {
12+
wait().await;
13+
if true {
14+
return fut.await;
15+
} else {
16+
wait().await;
17+
}
18+
}
19+
}
20+
21+
pub async fn test() {
22+
let fut = big_fut([0u8; 1024]);
23+
calls_fut(fut).await;
24+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:21:21: 24:2]`: 3078 bytes, alignment: 1 bytes
2+
print-type-size discriminant: 1 bytes
3+
print-type-size variant `Unresumed`: 0 bytes
4+
print-type-size variant `Suspend0`: 3077 bytes
5+
print-type-size local `.__awaitee`: 3077 bytes, offset: 0 bytes, alignment: 1 bytes
6+
print-type-size variant `Returned`: 0 bytes
7+
print-type-size variant `Panicked`: 0 bytes
8+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]`: 3077 bytes, alignment: 1 bytes
9+
print-type-size discriminant: 1 bytes
10+
print-type-size variant `Unresumed`: 2051 bytes
11+
print-type-size padding: 1026 bytes
12+
print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes
13+
print-type-size variant `Suspend0`: 2052 bytes
14+
print-type-size local `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
15+
print-type-size local `..generator_field4`: 1 bytes
16+
print-type-size padding: 1 bytes
17+
print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes
18+
print-type-size local `.__awaitee`: 1 bytes
19+
print-type-size variant `Suspend1`: 3076 bytes
20+
print-type-size padding: 1024 bytes
21+
print-type-size local `..generator_field4`: 1 bytes, alignment: 1 bytes
22+
print-type-size padding: 1 bytes
23+
print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes
24+
print-type-size local `.__awaitee`: 1025 bytes
25+
print-type-size variant `Suspend2`: 2052 bytes
26+
print-type-size local `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
27+
print-type-size local `..generator_field4`: 1 bytes
28+
print-type-size padding: 1 bytes
29+
print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes
30+
print-type-size local `.__awaitee`: 1 bytes
31+
print-type-size variant `Returned`: 2051 bytes
32+
print-type-size padding: 1026 bytes
33+
print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes
34+
print-type-size variant `Panicked`: 2051 bytes
35+
print-type-size padding: 1026 bytes
36+
print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes
37+
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]>`: 3077 bytes, alignment: 1 bytes
38+
print-type-size field `.value`: 3077 bytes
39+
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]>`: 3077 bytes, alignment: 1 bytes
40+
print-type-size variant `MaybeUninit`: 3077 bytes
41+
print-type-size field `.uninit`: 0 bytes
42+
print-type-size field `.value`: 3077 bytes
43+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:8:35: 8:37]`: 1025 bytes, alignment: 1 bytes
44+
print-type-size discriminant: 1 bytes
45+
print-type-size variant `Unresumed`: 1024 bytes
46+
print-type-size upvar `.arg`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
47+
print-type-size variant `Returned`: 1024 bytes
48+
print-type-size upvar `.arg`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
49+
print-type-size variant `Panicked`: 1024 bytes
50+
print-type-size upvar `.arg`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
51+
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:8:35: 8:37]>`: 1025 bytes, alignment: 1 bytes
52+
print-type-size field `.value`: 1025 bytes
53+
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:8:35: 8:37]>`: 1025 bytes, alignment: 1 bytes
54+
print-type-size variant `MaybeUninit`: 1025 bytes
55+
print-type-size field `.uninit`: 0 bytes
56+
print-type-size field `.value`: 1025 bytes
57+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:6:17: 6:19]`: 1 bytes, alignment: 1 bytes
58+
print-type-size discriminant: 1 bytes
59+
print-type-size variant `Unresumed`: 0 bytes
60+
print-type-size variant `Returned`: 0 bytes
61+
print-type-size variant `Panicked`: 0 bytes
62+
print-type-size type: `std::mem::ManuallyDrop<bool>`: 1 bytes, alignment: 1 bytes
63+
print-type-size field `.value`: 1 bytes
64+
print-type-size type: `std::mem::MaybeUninit<bool>`: 1 bytes, alignment: 1 bytes
65+
print-type-size variant `MaybeUninit`: 1 bytes
66+
print-type-size field `.uninit`: 0 bytes
67+
print-type-size field `.value`: 1 bytes
68+
print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes
69+
print-type-size discriminant: 1 bytes
70+
print-type-size variant `Ready`: 0 bytes
71+
print-type-size field `.0`: 0 bytes
72+
print-type-size variant `Pending`: 0 bytes

‎tests/ui/error-codes/E0523.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// aux-build:crateresolve1-1.rs
2+
// aux-build:crateresolve1-2.rs
3+
// aux-build:crateresolve1-3.rs
4+
5+
// normalize-stderr-test: "\.nll/" -> "/"
6+
// normalize-stderr-test: "\\\?\\" -> ""
7+
// normalize-stderr-test: "(lib)?crateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$2.somelib"
8+
9+
// NOTE: This test is duplicated from `tests/ui/crate-loading/crateresolve1.rs`.
10+
11+
extern crate crateresolve1;
12+
//~^ ERROR multiple candidates for `rlib` dependency `crateresolve1` found
13+
14+
fn main() {}

‎tests/ui/error-codes/E0523.stderr

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found
2+
--> $DIR/E0523.rs:11:1
3+
|
4+
LL | extern crate crateresolve1;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: candidate #1: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-1.somelib
8+
= note: candidate #2: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-2.somelib
9+
= note: candidate #3: $TEST_BUILD_DIR/error-codes/E0523/auxiliary/libcrateresolve1-3.somelib
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0464`.

‎tests/ui/generic-associated-types/issue-68656-unsized-values.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ LL | type Item<'a>: std::ops::Deref<Target = T>;
1515
| ^^^^^^^^^^ required by this bound in `UnsafeCopy::Item`
1616
help: consider further restricting this bound
1717
|
18-
LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<T> for T {
19-
| +++++++++++++++++++
18+
LL | impl<T: Copy + std::ops::Deref<Target = T>> UnsafeCopy<T> for T {
19+
| ++++++++++++
2020

2121
error: aborting due to previous error
2222

‎tests/ui/generic-associated-types/missing-bounds.fixed

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::ops::Add;
44

55
struct A<B>(B);
66

7-
impl<B> Add for A<B> where B: Add + Add<Output = B> {
7+
impl<B> Add for A<B> where B: Add<Output = B> {
88
type Output = Self;
99

1010
fn add(self, rhs: Self) -> Self {
@@ -14,7 +14,7 @@ impl<B> Add for A<B> where B: Add + Add<Output = B> {
1414

1515
struct C<B>(B);
1616

17-
impl<B: Add + Add<Output = B>> Add for C<B> {
17+
impl<B: Add<Output = B>> Add for C<B> {
1818
type Output = Self;
1919

2020
fn add(self, rhs: Self) -> Self {
@@ -34,7 +34,7 @@ impl<B: std::ops::Add<Output = B>> Add for D<B> {
3434

3535
struct E<B>(B);
3636

37-
impl<B: Add + Add<Output = B>> Add for E<B> where B: Add<Output = B> {
37+
impl<B: Add<Output = B>> Add for E<B> where B: Add<Output = B> {
3838
//~^ ERROR equality constraints are not yet supported in `where` clauses
3939
type Output = Self;
4040

‎tests/ui/generic-associated-types/missing-bounds.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ LL | struct A<B>(B);
3737
| ^
3838
help: consider further restricting this bound
3939
|
40-
LL | impl<B> Add for A<B> where B: Add + Add<Output = B> {
41-
| +++++++++++++++++
40+
LL | impl<B> Add for A<B> where B: Add<Output = B> {
41+
| ++++++++++++
4242

4343
error[E0308]: mismatched types
4444
--> $DIR/missing-bounds.rs:21:14
@@ -60,8 +60,8 @@ LL | struct C<B>(B);
6060
| ^
6161
help: consider further restricting this bound
6262
|
63-
LL | impl<B: Add + Add<Output = B>> Add for C<B> {
64-
| +++++++++++++++++
63+
LL | impl<B: Add<Output = B>> Add for C<B> {
64+
| ++++++++++++
6565

6666
error[E0369]: cannot add `B` to `B`
6767
--> $DIR/missing-bounds.rs:31:21
@@ -96,8 +96,8 @@ LL | struct E<B>(B);
9696
| ^
9797
help: consider further restricting this bound
9898
|
99-
LL | impl<B: Add + Add<Output = B>> Add for E<B> where <B as Add>::Output = B {
100-
| +++++++++++++++++
99+
LL | impl<B: Add<Output = B>> Add for E<B> where <B as Add>::Output = B {
100+
| ++++++++++++
101101

102102
error: aborting due to 5 previous errors
103103

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
pub trait TryAdd<Rhs = Self> {
2+
type Error;
3+
type Output;
4+
5+
fn try_add(self, rhs: Rhs) -> Result<Self::Output, Self::Error>;
6+
}
7+
8+
impl<T: TryAdd> TryAdd for Option<T> {
9+
type Error = <T as TryAdd>::Error;
10+
type Output = Option<<T as TryAdd>::Output>;
11+
12+
fn try_add(self, rhs: Self) -> Result<Self::Output, Self::Error> {
13+
Ok(self) //~ ERROR mismatched types
14+
}
15+
}
16+
17+
struct Other<A>(A);
18+
19+
struct X;
20+
21+
impl<T: TryAdd<Error = X>> TryAdd for Other<T> {
22+
type Error = <T as TryAdd>::Error;
23+
type Output = Other<<T as TryAdd>::Output>;
24+
25+
fn try_add(self, rhs: Self) -> Result<Self::Output, Self::Error> {
26+
Ok(self) //~ ERROR mismatched types
27+
}
28+
}
29+
30+
fn main() {}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/restrict-existing-type-bounds.rs:13:12
3+
|
4+
LL | impl<T: TryAdd> TryAdd for Option<T> {
5+
| - this type parameter
6+
...
7+
LL | Ok(self)
8+
| -- ^^^^ expected `Option<<T as TryAdd>::Output>`, found `Option<T>`
9+
| |
10+
| arguments to this enum variant are incorrect
11+
|
12+
= note: expected enum `Option<<T as TryAdd>::Output>`
13+
found enum `Option<T>`
14+
help: the type constructed contains `Option<T>` due to the type of the argument passed
15+
--> $DIR/restrict-existing-type-bounds.rs:13:9
16+
|
17+
LL | Ok(self)
18+
| ^^^----^
19+
| |
20+
| this argument influences the type of `Ok`
21+
note: tuple variant defined here
22+
--> $SRC_DIR/core/src/result.rs:LL:COL
23+
help: consider further restricting this bound
24+
|
25+
LL | impl<T: TryAdd<Output = T>> TryAdd for Option<T> {
26+
| ++++++++++++
27+
28+
error[E0308]: mismatched types
29+
--> $DIR/restrict-existing-type-bounds.rs:26:12
30+
|
31+
LL | impl<T: TryAdd<Error = X>> TryAdd for Other<T> {
32+
| - this type parameter
33+
...
34+
LL | Ok(self)
35+
| -- ^^^^ expected `Other<<T as TryAdd>::Output>`, found `Other<T>`
36+
| |
37+
| arguments to this enum variant are incorrect
38+
|
39+
= note: expected struct `Other<<T as TryAdd>::Output>`
40+
found struct `Other<T>`
41+
help: the type constructed contains `Other<T>` due to the type of the argument passed
42+
--> $DIR/restrict-existing-type-bounds.rs:26:9
43+
|
44+
LL | Ok(self)
45+
| ^^^----^
46+
| |
47+
| this argument influences the type of `Ok`
48+
note: tuple variant defined here
49+
--> $SRC_DIR/core/src/result.rs:LL:COL
50+
help: consider further restricting this bound
51+
|
52+
LL | impl<T: TryAdd<Error = X, Output = T>> TryAdd for Other<T> {
53+
| ++++++++++++
54+
55+
error: aborting due to 2 previous errors
56+
57+
For more information about this error, try `rustc --explain E0308`.

‎tests/ui/suggestions/type-mismatch-byte-literal.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,19 @@ fn main() {
1212
//~^ ERROR: mismatched types [E0308]
1313
//~| HELP: if you meant to write a byte literal, prefix with `b`
1414

15+
let _a: u8 = '\x20';
16+
//~^ ERROR: mismatched types [E0308]
17+
//~| HELP: if you meant to write a byte literal, prefix with `b`
18+
19+
// Do not issue the suggestion if the char literal is a Unicode escape
20+
foo('\u{0080}');
21+
//~^ ERROR: mismatched types [E0308]
22+
1523
// Do not issue the suggestion if the char literal isn't ASCII
1624
let _t: u8 = '€';
1725
//~^ ERROR: mismatched types [E0308]
26+
27+
// Do not issue the suggestion if the char literal isn't ASCII
28+
foo('\u{1f980}');
29+
//~^ ERROR: mismatched types [E0308]
1830
}

‎tests/ui/suggestions/type-mismatch-byte-literal.stderr

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,54 @@ LL | foo(b'#');
3030
| ~~~~
3131

3232
error[E0308]: mismatched types
33-
--> $DIR/type-mismatch-byte-literal.rs:16:18
33+
--> $DIR/type-mismatch-byte-literal.rs:15:18
34+
|
35+
LL | let _a: u8 = '\x20';
36+
| -- ^^^^^^ expected `u8`, found `char`
37+
| |
38+
| expected due to this
39+
|
40+
help: if you meant to write a byte literal, prefix with `b`
41+
|
42+
LL | let _a: u8 = b'\x20';
43+
| ~~~~~~~
44+
45+
error[E0308]: mismatched types
46+
--> $DIR/type-mismatch-byte-literal.rs:20:9
47+
|
48+
LL | foo('\u{0080}');
49+
| --- ^^^^^^^^^^ expected `u8`, found `char`
50+
| |
51+
| arguments to this function are incorrect
52+
|
53+
note: function defined here
54+
--> $DIR/type-mismatch-byte-literal.rs:4:4
55+
|
56+
LL | fn foo(_t: u8) {}
57+
| ^^^ ------
58+
59+
error[E0308]: mismatched types
60+
--> $DIR/type-mismatch-byte-literal.rs:24:18
3461
|
3562
LL | let _t: u8 = '€';
3663
| -- ^^^ expected `u8`, found `char`
3764
| |
3865
| expected due to this
3966

40-
error: aborting due to 3 previous errors
67+
error[E0308]: mismatched types
68+
--> $DIR/type-mismatch-byte-literal.rs:28:9
69+
|
70+
LL | foo('\u{1f980}');
71+
| --- ^^^^^^^^^^^ expected `u8`, found `char`
72+
| |
73+
| arguments to this function are incorrect
74+
|
75+
note: function defined here
76+
--> $DIR/type-mismatch-byte-literal.rs:4:4
77+
|
78+
LL | fn foo(_t: u8) {}
79+
| ^^^ ------
80+
81+
error: aborting due to 6 previous errors
4182

4283
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
Please sign in to comment.