Skip to content

Commit 38528d4

Browse files
committedAug 23, 2022
Auto merge of rust-lang#100904 - matthiaskrgr:rollup-z3yzivj, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#100382 (Make the GATS self outlives error take into GATs in the inputs) - rust-lang#100565 (Suggest adding a missing semicolon before an item) - rust-lang#100641 (Add the armv4t-none-eabi target to the supported_targets) - rust-lang#100789 (Use separate infcx to solve obligations during negative coherence) - rust-lang#100832 (Some small bootstrap cleanup) - rust-lang#100861 (fix ICE with extra-const-ub-checks) - rust-lang#100862 (tidy: remove crossbeam-utils) - rust-lang#100887 (Refactor part of codegen_call_terminator) - rust-lang#100893 (Remove out-of-context comment in `mem::MaybeUninit` documentation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7e3e8a8 + 683a08a commit 38528d4

26 files changed

+403
-111
lines changed
 

‎Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -5295,7 +5295,6 @@ name = "tidy"
52955295
version = "0.1.0"
52965296
dependencies = [
52975297
"cargo_metadata 0.14.0",
5298-
"crossbeam-utils",
52995298
"lazy_static",
53005299
"regex",
53015300
"walkdir",

‎compiler/rustc_ast/src/token.rs

+24
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,30 @@ impl Token {
436436
|| self == &OpenDelim(Delimiter::Parenthesis)
437437
}
438438

439+
/// Returns `true` if the token can appear at the start of an item.
440+
pub fn can_begin_item(&self) -> bool {
441+
match self.kind {
442+
Ident(name, _) => [
443+
kw::Fn,
444+
kw::Use,
445+
kw::Struct,
446+
kw::Enum,
447+
kw::Pub,
448+
kw::Trait,
449+
kw::Extern,
450+
kw::Impl,
451+
kw::Unsafe,
452+
kw::Static,
453+
kw::Union,
454+
kw::Macro,
455+
kw::Mod,
456+
kw::Type,
457+
]
458+
.contains(&name),
459+
_ => false,
460+
}
461+
}
462+
439463
/// Returns `true` if the token is any literal.
440464
pub fn is_lit(&self) -> bool {
441465
matches!(self.kind, Literal(..))

‎compiler/rustc_codegen_ssa/src/mir/block.rs

+44-47
Original file line numberDiff line numberDiff line change
@@ -798,58 +798,55 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
798798
let mut op = self.codegen_operand(&mut bx, arg);
799799

800800
if let (0, Some(ty::InstanceDef::Virtual(_, idx))) = (i, def) {
801-
if let Pair(..) = op.val {
802-
// In the case of Rc<Self>, we need to explicitly pass a
803-
// *mut RcBox<Self> with a Scalar (not ScalarPair) ABI. This is a hack
804-
// that is understood elsewhere in the compiler as a method on
805-
// `dyn Trait`.
806-
// To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
807-
// we get a value of a built-in pointer type
808-
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
809-
&& !op.layout.ty.is_region_ptr()
810-
{
811-
for i in 0..op.layout.fields.count() {
812-
let field = op.extract_field(&mut bx, i);
813-
if !field.layout.is_zst() {
814-
// we found the one non-zero-sized field that is allowed
815-
// now find *its* non-zero-sized field, or stop if it's a
816-
// pointer
817-
op = field;
818-
continue 'descend_newtypes;
801+
match op.val {
802+
Pair(data_ptr, meta) => {
803+
// In the case of Rc<Self>, we need to explicitly pass a
804+
// *mut RcBox<Self> with a Scalar (not ScalarPair) ABI. This is a hack
805+
// that is understood elsewhere in the compiler as a method on
806+
// `dyn Trait`.
807+
// To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
808+
// we get a value of a built-in pointer type
809+
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
810+
&& !op.layout.ty.is_region_ptr()
811+
{
812+
for i in 0..op.layout.fields.count() {
813+
let field = op.extract_field(&mut bx, i);
814+
if !field.layout.is_zst() {
815+
// we found the one non-zero-sized field that is allowed
816+
// now find *its* non-zero-sized field, or stop if it's a
817+
// pointer
818+
op = field;
819+
continue 'descend_newtypes;
820+
}
819821
}
822+
823+
span_bug!(span, "receiver has no non-zero-sized fields {:?}", op);
820824
}
821825

822-
span_bug!(span, "receiver has no non-zero-sized fields {:?}", op);
826+
// now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
827+
// data pointer and vtable. Look up the method in the vtable, and pass
828+
// the data pointer as the first argument
829+
llfn = Some(meth::VirtualIndex::from_index(idx).get_fn(
830+
&mut bx,
831+
meta,
832+
op.layout.ty,
833+
&fn_abi,
834+
));
835+
llargs.push(data_ptr);
836+
continue 'make_args;
823837
}
824-
825-
// now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
826-
// data pointer and vtable. Look up the method in the vtable, and pass
827-
// the data pointer as the first argument
828-
match op.val {
829-
Pair(data_ptr, meta) => {
830-
llfn = Some(meth::VirtualIndex::from_index(idx).get_fn(
831-
&mut bx,
832-
meta,
833-
op.layout.ty,
834-
&fn_abi,
835-
));
836-
llargs.push(data_ptr);
837-
continue 'make_args;
838-
}
839-
other => bug!("expected a Pair, got {:?}", other),
838+
Ref(data_ptr, Some(meta), _) => {
839+
// by-value dynamic dispatch
840+
llfn = Some(meth::VirtualIndex::from_index(idx).get_fn(
841+
&mut bx,
842+
meta,
843+
op.layout.ty,
844+
&fn_abi,
845+
));
846+
llargs.push(data_ptr);
847+
continue;
840848
}
841-
} else if let Ref(data_ptr, Some(meta), _) = op.val {
842-
// by-value dynamic dispatch
843-
llfn = Some(meth::VirtualIndex::from_index(idx).get_fn(
844-
&mut bx,
845-
meta,
846-
op.layout.ty,
847-
&fn_abi,
848-
));
849-
llargs.push(data_ptr);
850-
continue;
851-
} else {
852-
span_bug!(span, "can't codegen a virtual call on {:?}", op);
849+
_ => span_bug!(span, "can't codegen a virtual call on {:?}", op),
853850
}
854851
}
855852

‎compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
8181
}
8282

8383
/// The `InterpCx` is only meant to be used to do field and index projections into constants for
84-
/// `simd_shuffle` and const patterns in match arms.
84+
/// `simd_shuffle` and const patterns in match arms. It never performs alignment checks.
8585
///
8686
/// The function containing the `match` that is currently being analyzed may have generic bounds
8787
/// that inform us about the generic bounds of the constant. E.g., using an associated constant
@@ -98,7 +98,11 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>(
9898
tcx,
9999
root_span,
100100
param_env,
101-
CompileTimeInterpreter::new(tcx.const_eval_limit(), can_access_statics),
101+
CompileTimeInterpreter::new(
102+
tcx.const_eval_limit(),
103+
can_access_statics,
104+
/*check_alignment:*/ false,
105+
),
102106
)
103107
}
104108

@@ -203,7 +207,13 @@ pub(crate) fn turn_into_const_value<'tcx>(
203207
let cid = key.value;
204208
let def_id = cid.instance.def.def_id();
205209
let is_static = tcx.is_static(def_id);
206-
let ecx = mk_eval_cx(tcx, tcx.def_span(key.value.instance.def_id()), key.param_env, is_static);
210+
// This is just accessing an already computed constant, so no need to check alginment here.
211+
let ecx = mk_eval_cx(
212+
tcx,
213+
tcx.def_span(key.value.instance.def_id()),
214+
key.param_env,
215+
/*can_access_statics:*/ is_static,
216+
);
207217

208218
let mplace = ecx.raw_const_to_mplace(constant).expect(
209219
"can only fail if layout computation failed, \
@@ -300,7 +310,11 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
300310
key.param_env,
301311
// Statics (and promoteds inside statics) may access other statics, because unlike consts
302312
// they do not have to behave "as if" they were evaluated at runtime.
303-
CompileTimeInterpreter::new(tcx.const_eval_limit(), /*can_access_statics:*/ is_static),
313+
CompileTimeInterpreter::new(
314+
tcx.const_eval_limit(),
315+
/*can_access_statics:*/ is_static,
316+
/*check_alignment:*/ tcx.sess.opts.unstable_opts.extra_const_ub_checks,
317+
),
304318
);
305319

306320
let res = ecx.load_mir(cid.instance.def, cid.promoted);

‎compiler/rustc_const_eval/src/const_eval/machine.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,22 @@ pub struct CompileTimeInterpreter<'mir, 'tcx> {
101101
/// * Pointers to allocations inside of statics can never leak outside, to a non-static global.
102102
/// This boolean here controls the second part.
103103
pub(super) can_access_statics: bool,
104+
105+
/// Whether to check alignment during evaluation.
106+
check_alignment: bool,
104107
}
105108

106109
impl<'mir, 'tcx> CompileTimeInterpreter<'mir, 'tcx> {
107-
pub(crate) fn new(const_eval_limit: Limit, can_access_statics: bool) -> Self {
110+
pub(crate) fn new(
111+
const_eval_limit: Limit,
112+
can_access_statics: bool,
113+
check_alignment: bool,
114+
) -> Self {
108115
CompileTimeInterpreter {
109116
steps_remaining: const_eval_limit.0,
110117
stack: Vec::new(),
111118
can_access_statics,
119+
check_alignment,
112120
}
113121
}
114122
}
@@ -238,7 +246,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
238246

239247
#[inline(always)]
240248
fn enforce_alignment(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
241-
ecx.tcx.sess.opts.unstable_opts.extra_const_ub_checks
249+
ecx.machine.check_alignment
242250
}
243251

244252
#[inline(always)]

‎compiler/rustc_const_eval/src/might_permit_raw_init.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ pub fn might_permit_raw_init<'tcx>(
1313
let strict = tcx.sess.opts.unstable_opts.strict_init_checks;
1414

1515
if strict {
16-
let machine = CompileTimeInterpreter::new(Limit::new(0), false);
16+
let machine = CompileTimeInterpreter::new(
17+
Limit::new(0),
18+
/*can_access_statics:*/ false,
19+
/*check_alignment:*/ true,
20+
);
1721

1822
let mut cx = InterpCx::new(tcx, rustc_span::DUMMY_SP, ParamEnv::reveal_all(), machine);
1923

‎compiler/rustc_parse/src/parser/diagnostics.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,12 @@ impl<'a> Parser<'a> {
927927
return Ok(true);
928928
} else if self.look_ahead(0, |t| {
929929
t == &token::CloseDelim(Delimiter::Brace)
930-
|| (t.can_begin_expr() && t != &token::Semi && t != &token::Pound)
930+
|| ((t.can_begin_expr() || t.can_begin_item())
931+
&& t != &token::Semi
932+
&& t != &token::Pound)
931933
// Avoid triggering with too many trailing `#` in raw string.
932934
|| (sm.is_multiline(
933-
self.prev_token.span.shrink_to_hi().until(self.token.span.shrink_to_lo())
935+
self.prev_token.span.shrink_to_hi().until(self.token.span.shrink_to_lo()),
934936
) && t == &token::Pound)
935937
}) && !expected.contains(&TokenType::Token(token::Comma))
936938
{

‎compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ supported_targets! {
10281028
("mipsel-sony-psp", mipsel_sony_psp),
10291029
("mipsel-unknown-none", mipsel_unknown_none),
10301030
("thumbv4t-none-eabi", thumbv4t_none_eabi),
1031+
("armv4t-none-eabi", armv4t_none_eabi),
10311032

10321033
("aarch64_be-unknown-linux-gnu", aarch64_be_unknown_linux_gnu),
10331034
("aarch64-unknown-linux-gnu_ilp32", aarch64_unknown_linux_gnu_ilp32),

‎compiler/rustc_trait_selection/src/traits/coherence.rs

+8-13
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,8 @@ fn equate<'cx, 'tcx>(
342342
};
343343

344344
let selcx = &mut SelectionContext::new(&infcx);
345-
let opt_failing_obligation = obligations
346-
.into_iter()
347-
.chain(more_obligations)
348-
.find(|o| negative_impl_exists(selcx, impl_env, o));
345+
let opt_failing_obligation =
346+
obligations.into_iter().chain(more_obligations).find(|o| negative_impl_exists(selcx, o));
349347

350348
if let Some(failing_obligation) = opt_failing_obligation {
351349
debug!("overlap: obligation unsatisfiable {:?}", failing_obligation);
@@ -359,18 +357,15 @@ fn equate<'cx, 'tcx>(
359357
#[instrument(level = "debug", skip(selcx))]
360358
fn negative_impl_exists<'cx, 'tcx>(
361359
selcx: &SelectionContext<'cx, 'tcx>,
362-
param_env: ty::ParamEnv<'tcx>,
363360
o: &PredicateObligation<'tcx>,
364361
) -> bool {
365-
let infcx = &selcx.infcx().fork();
366-
367-
if resolve_negative_obligation(infcx, param_env, o) {
362+
if resolve_negative_obligation(selcx.infcx().fork(), o) {
368363
return true;
369364
}
370365

371366
// Try to prove a negative obligation exists for super predicates
372-
for o in util::elaborate_predicates(infcx.tcx, iter::once(o.predicate)) {
373-
if resolve_negative_obligation(infcx, param_env, &o) {
367+
for o in util::elaborate_predicates(selcx.tcx(), iter::once(o.predicate)) {
368+
if resolve_negative_obligation(selcx.infcx().fork(), &o) {
374369
return true;
375370
}
376371
}
@@ -380,8 +375,7 @@ fn negative_impl_exists<'cx, 'tcx>(
380375

381376
#[instrument(level = "debug", skip(infcx))]
382377
fn resolve_negative_obligation<'cx, 'tcx>(
383-
infcx: &InferCtxt<'cx, 'tcx>,
384-
param_env: ty::ParamEnv<'tcx>,
378+
infcx: InferCtxt<'cx, 'tcx>,
385379
o: &PredicateObligation<'tcx>,
386380
) -> bool {
387381
let tcx = infcx.tcx;
@@ -390,7 +384,8 @@ fn resolve_negative_obligation<'cx, 'tcx>(
390384
return false;
391385
};
392386

393-
let errors = super::fully_solve_obligation(infcx, o);
387+
let param_env = o.param_env;
388+
let errors = super::fully_solve_obligation(&infcx, o);
394389
if !errors.is_empty() {
395390
return false;
396391
}

‎compiler/rustc_typeck/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
387387
tcx,
388388
param_env,
389389
item_hir_id,
390-
sig.output(),
390+
sig.inputs_and_output,
391391
// We also assume that all of the function signature's parameter types
392392
// are well formed.
393393
&sig.inputs().iter().copied().collect(),

‎library/core/src/mem/maybe_uninit.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,8 @@ use crate::slice;
130130
/// MaybeUninit::uninit().assume_init()
131131
/// };
132132
///
133-
/// // Dropping a `MaybeUninit` does nothing. Thus using raw pointer
134-
/// // assignment instead of `ptr::write` does not cause the old
135-
/// // uninitialized value to be dropped. Also if there is a panic during
136-
/// // this loop, we have a memory leak, but there is no memory safety
137-
/// // issue.
133+
/// // Dropping a `MaybeUninit` does nothing, so if there is a panic during this loop,
134+
/// // we have a memory leak, but there is no memory safety issue.
138135
/// for elem in &mut data[..] {
139136
/// elem.write(vec![42]);
140137
/// }

‎src/bootstrap/dist.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1226,17 +1226,10 @@ impl Step for Rustfmt {
12261226

12271227
let rustfmt = builder
12281228
.ensure(tool::Rustfmt { compiler, target, extra_features: Vec::new() })
1229-
.or_else(|| {
1230-
missing_tool("Rustfmt", builder.build.config.missing_tools);
1231-
None
1232-
})?;
1229+
.expect("rustfmt expected to build - essential tool");
12331230
let cargofmt = builder
12341231
.ensure(tool::Cargofmt { compiler, target, extra_features: Vec::new() })
1235-
.or_else(|| {
1236-
missing_tool("Cargofmt", builder.build.config.missing_tools);
1237-
None
1238-
})?;
1239-
1232+
.expect("cargo fmt expected to build - essential tool");
12401233
let mut tarball = Tarball::new(builder, "rustfmt", &target.triple);
12411234
tarball.set_overlay(OverlayKind::Rustfmt);
12421235
tarball.is_preview(true);

‎src/bootstrap/tool.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -778,12 +778,10 @@ impl Step for RustAnalyzerProcMacroSrv {
778778
macro_rules! tool_extended {
779779
(($sel:ident, $builder:ident),
780780
$($name:ident,
781-
$toolstate:ident,
782781
$path:expr,
783782
$tool_name:expr,
784783
stable = $stable:expr,
785784
$(in_tree = $in_tree:expr,)?
786-
$(submodule = $submodule:literal,)?
787785
$(tool_std = $tool_std:literal,)?
788786
$extra_deps:block;)+) => {
789787
$(
@@ -828,7 +826,6 @@ macro_rules! tool_extended {
828826
#[allow(unused_mut)]
829827
fn run(mut $sel, $builder: &Builder<'_>) -> Option<PathBuf> {
830828
$extra_deps
831-
$( $builder.update_submodule(&Path::new("src").join("tools").join($submodule)); )?
832829
$builder.ensure(ToolBuild {
833830
compiler: $sel.compiler,
834831
target: $sel.target,
@@ -854,12 +851,12 @@ macro_rules! tool_extended {
854851
// Note: Most submodule updates for tools are handled by bootstrap.py, since they're needed just to
855852
// invoke Cargo to build bootstrap. See the comment there for more details.
856853
tool_extended!((self, builder),
857-
Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, in_tree=true, {};
858-
CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {};
859-
Clippy, clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
860-
Miri, miri, "src/tools/miri", "miri", stable=false, {};
861-
CargoMiri, miri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, {};
862-
Rls, rls, "src/tools/rls", "rls", stable=true, {
854+
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true, in_tree=true, {};
855+
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {};
856+
Clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
857+
Miri, "src/tools/miri", "miri", stable=false, {};
858+
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, {};
859+
Rls, "src/tools/rls", "rls", stable=true, {
863860
builder.ensure(Clippy {
864861
compiler: self.compiler,
865862
target: self.target,
@@ -870,8 +867,8 @@ tool_extended!((self, builder),
870867
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
871868
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
872869
// and this is close enough for now.
873-
RustDemangler, rust_demangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {};
874-
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
870+
RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {};
871+
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
875872
);
876873

877874
impl<'a> Builder<'a> {

‎src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ target | std | host | notes
223223
`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI)
224224
`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)
225225
[`arm64_32-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | ARM Apple WatchOS 64-bit with 32-bit pointers
226+
`armv4t-none-eabi` | * | | ARMv4T A32
226227
`armv4t-unknown-linux-gnueabi` | ? | |
227228
`armv5te-unknown-linux-uclibceabi` | ? | | ARMv5TE Linux with uClibc
228229
`armv6-unknown-freebsd` | ✓ | ✓ | ARMv6 FreeBSD

‎src/test/ui/coherence/coherence-negative-outlives-lifetimes.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
// revisions: stock with_negative_coherence
12
#![feature(negative_impls)]
3+
#![cfg_attr(with_negative_coherence, feature(with_negative_coherence))]
24

35
// FIXME: this should compile
46

57
trait MyPredicate<'a> {}
6-
impl<'a, T> !MyPredicate<'a> for &T where T: 'a {}
8+
9+
impl<'a, T> !MyPredicate<'a> for &'a T where T: 'a {}
10+
711
trait MyTrait<'a> {}
12+
813
impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
914
impl<'a, T> MyTrait<'a> for &'a T {}
1015
//~^ ERROR: conflicting implementations of trait `MyTrait<'_>` for type `&_`

‎src/test/ui/coherence/coherence-negative-outlives-lifetimes.stderr ‎src/test/ui/coherence/coherence-negative-outlives-lifetimes.stock.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0119]: conflicting implementations of trait `MyTrait<'_>` for type `&_`
2-
--> $DIR/coherence-negative-outlives-lifetimes.rs:9:1
2+
--> $DIR/coherence-negative-outlives-lifetimes.rs:14:1
33
|
44
LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
55
| ---------------------------------------------- first implementation here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0119]: conflicting implementations of trait `MyTrait<'_>` for type `&_`
2+
--> $DIR/coherence-negative-outlives-lifetimes.rs:14:1
3+
|
4+
LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
5+
| ---------------------------------------------- first implementation here
6+
LL | impl<'a, T> MyTrait<'a> for &'a T {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0119`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// check-pass
2+
// compile-flags: -Zextra-const-ub-checks
3+
4+
#[derive(PartialEq, Eq, Copy, Clone)]
5+
#[repr(packed)]
6+
struct Foo {
7+
field: (i64, u32, u32, u32),
8+
}
9+
10+
const FOO: Foo = Foo {
11+
field: (5, 6, 7, 8),
12+
};
13+
14+
fn main() {
15+
match FOO {
16+
Foo { field: (5, 6, 7, 8) } => {},
17+
FOO => unreachable!(),
18+
_ => unreachable!(),
19+
}
20+
}

‎src/test/ui/generic-associated-types/self-outlives-lint.rs

+13
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,17 @@ trait StaticReturnAndTakes<'a> {
210210
fn bar<'b>(&self, arg: Self::Y<'b>);
211211
}
212212

213+
// We require bounds when the GAT appears in the inputs
214+
trait Input {
215+
type Item<'a>;
216+
//~^ missing required
217+
fn takes_item<'a>(&'a self, item: Self::Item<'a>);
218+
}
219+
220+
// We don't require bounds when the GAT appears in the where clauses
221+
trait WhereClause {
222+
type Item<'a>;
223+
fn takes_item<'a>(&'a self) where Self::Item<'a>: ;
224+
}
225+
213226
fn main() {}

‎src/test/ui/generic-associated-types/self-outlives-lint.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,16 @@ LL | type Fut<'out>;
163163
= note: this bound is currently required to ensure that impls have maximum flexibility
164164
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
165165

166-
error: aborting due to 15 previous errors
166+
error: missing required bound on `Item`
167+
--> $DIR/self-outlives-lint.rs:215:5
168+
|
169+
LL | type Item<'a>;
170+
| ^^^^^^^^^^^^^-
171+
| |
172+
| help: add the required where clause: `where Self: 'a`
173+
|
174+
= note: this bound is currently required to ensure that impls have maximum flexibility
175+
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
176+
177+
error: aborting due to 16 previous errors
167178

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// run-rustfix
2+
3+
#![allow(unused_variables, dead_code)]
4+
5+
fn for_struct() {
6+
let foo = 3; //~ ERROR expected `;`, found keyword `struct`
7+
struct Foo;
8+
}
9+
10+
fn for_union() {
11+
let foo = 3; //~ ERROR expected `;`, found `union`
12+
union Foo {
13+
foo: usize,
14+
}
15+
}
16+
17+
fn for_enum() {
18+
let foo = 3; //~ ERROR expected `;`, found keyword `enum`
19+
enum Foo {
20+
Bar,
21+
}
22+
}
23+
24+
fn for_fn() {
25+
let foo = 3; //~ ERROR expected `;`, found keyword `fn`
26+
fn foo() {}
27+
}
28+
29+
fn for_extern() {
30+
let foo = 3; //~ ERROR expected `;`, found keyword `extern`
31+
extern fn foo() {}
32+
}
33+
34+
fn for_impl() {
35+
struct Foo;
36+
let foo = 3; //~ ERROR expected `;`, found keyword `impl`
37+
impl Foo {}
38+
}
39+
40+
fn for_use() {
41+
let foo = 3; //~ ERROR expected `;`, found keyword `pub`
42+
pub use bar::Bar;
43+
}
44+
45+
fn for_mod() {
46+
let foo = 3; //~ ERROR expected `;`, found keyword `mod`
47+
mod foo {}
48+
}
49+
50+
fn for_type() {
51+
let foo = 3; //~ ERROR expected `;`, found keyword `type`
52+
type Foo = usize;
53+
}
54+
55+
mod bar {
56+
pub struct Bar;
57+
}
58+
59+
const X: i32 = 123; //~ ERROR expected `;`, found keyword `fn`
60+
61+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// run-rustfix
2+
3+
#![allow(unused_variables, dead_code)]
4+
5+
fn for_struct() {
6+
let foo = 3 //~ ERROR expected `;`, found keyword `struct`
7+
struct Foo;
8+
}
9+
10+
fn for_union() {
11+
let foo = 3 //~ ERROR expected `;`, found `union`
12+
union Foo {
13+
foo: usize,
14+
}
15+
}
16+
17+
fn for_enum() {
18+
let foo = 3 //~ ERROR expected `;`, found keyword `enum`
19+
enum Foo {
20+
Bar,
21+
}
22+
}
23+
24+
fn for_fn() {
25+
let foo = 3 //~ ERROR expected `;`, found keyword `fn`
26+
fn foo() {}
27+
}
28+
29+
fn for_extern() {
30+
let foo = 3 //~ ERROR expected `;`, found keyword `extern`
31+
extern fn foo() {}
32+
}
33+
34+
fn for_impl() {
35+
struct Foo;
36+
let foo = 3 //~ ERROR expected `;`, found keyword `impl`
37+
impl Foo {}
38+
}
39+
40+
fn for_use() {
41+
let foo = 3 //~ ERROR expected `;`, found keyword `pub`
42+
pub use bar::Bar;
43+
}
44+
45+
fn for_mod() {
46+
let foo = 3 //~ ERROR expected `;`, found keyword `mod`
47+
mod foo {}
48+
}
49+
50+
fn for_type() {
51+
let foo = 3 //~ ERROR expected `;`, found keyword `type`
52+
type Foo = usize;
53+
}
54+
55+
mod bar {
56+
pub struct Bar;
57+
}
58+
59+
const X: i32 = 123 //~ ERROR expected `;`, found keyword `fn`
60+
61+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
error: expected `;`, found keyword `struct`
2+
--> $DIR/recover-missing-semi-before-item.rs:6:16
3+
|
4+
LL | let foo = 3
5+
| ^ help: add `;` here
6+
LL | struct Foo;
7+
| ------ unexpected token
8+
9+
error: expected `;`, found `union`
10+
--> $DIR/recover-missing-semi-before-item.rs:11:16
11+
|
12+
LL | let foo = 3
13+
| ^ help: add `;` here
14+
LL | union Foo {
15+
| ----- unexpected token
16+
17+
error: expected `;`, found keyword `enum`
18+
--> $DIR/recover-missing-semi-before-item.rs:18:16
19+
|
20+
LL | let foo = 3
21+
| ^ help: add `;` here
22+
LL | enum Foo {
23+
| ---- unexpected token
24+
25+
error: expected `;`, found keyword `fn`
26+
--> $DIR/recover-missing-semi-before-item.rs:25:16
27+
|
28+
LL | let foo = 3
29+
| ^ help: add `;` here
30+
LL | fn foo() {}
31+
| -- unexpected token
32+
33+
error: expected `;`, found keyword `extern`
34+
--> $DIR/recover-missing-semi-before-item.rs:30:16
35+
|
36+
LL | let foo = 3
37+
| ^ help: add `;` here
38+
LL | extern fn foo() {}
39+
| ------ unexpected token
40+
41+
error: expected `;`, found keyword `impl`
42+
--> $DIR/recover-missing-semi-before-item.rs:36:16
43+
|
44+
LL | let foo = 3
45+
| ^ help: add `;` here
46+
LL | impl Foo {}
47+
| ---- unexpected token
48+
49+
error: expected `;`, found keyword `pub`
50+
--> $DIR/recover-missing-semi-before-item.rs:41:16
51+
|
52+
LL | let foo = 3
53+
| ^ help: add `;` here
54+
LL | pub use bar::Bar;
55+
| --- unexpected token
56+
57+
error: expected `;`, found keyword `mod`
58+
--> $DIR/recover-missing-semi-before-item.rs:46:16
59+
|
60+
LL | let foo = 3
61+
| ^ help: add `;` here
62+
LL | mod foo {}
63+
| --- unexpected token
64+
65+
error: expected `;`, found keyword `type`
66+
--> $DIR/recover-missing-semi-before-item.rs:51:16
67+
|
68+
LL | let foo = 3
69+
| ^ help: add `;` here
70+
LL | type Foo = usize;
71+
| ---- unexpected token
72+
73+
error: expected `;`, found keyword `fn`
74+
--> $DIR/recover-missing-semi-before-item.rs:59:19
75+
|
76+
LL | const X: i32 = 123
77+
| ^ help: add `;` here
78+
LL |
79+
LL | fn main() {}
80+
| -- unexpected token
81+
82+
error: aborting due to 10 previous errors
83+

‎src/tools/publish_toolstate.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@
3232
MAINTAINERS = {
3333
'miri': {'oli-obk', 'RalfJung'},
3434
'rls': {'Xanewok'},
35-
'rustfmt': {'topecongiro', 'calebcartwright'},
36-
'book': {'carols10cents', 'steveklabnik'},
35+
'book': {'carols10cents'},
3736
'nomicon': {'frewsxcv', 'Gankra', 'JohnTitor'},
38-
'reference': {'steveklabnik', 'Havvy', 'matthewjasper', 'ehuss'},
39-
'rust-by-example': {'steveklabnik', 'marioidival'},
37+
'reference': {'Havvy', 'matthewjasper', 'ehuss'},
38+
'rust-by-example': {'marioidival'},
4039
'embedded-book': {'adamgreig', 'andre-richter', 'jamesmunns', 'therealprof'},
41-
'edition-guide': {'ehuss', 'steveklabnik'},
40+
'edition-guide': {'ehuss'},
4241
'rustc-dev-guide': {'spastorino', 'amanjeev', 'JohnTitor'},
4342
}
4443

4544
LABELS = {
4645
'miri': ['A-miri', 'C-bug'],
4746
'rls': ['A-rls', 'C-bug'],
48-
'rustfmt': ['A-rustfmt', 'C-bug'],
4947
'book': ['C-bug'],
5048
'nomicon': ['C-bug'],
5149
'reference': ['C-bug'],
@@ -58,7 +56,6 @@
5856
REPOS = {
5957
'miri': 'https://github.com/rust-lang/miri',
6058
'rls': 'https://github.com/rust-lang/rls',
61-
'rustfmt': 'https://github.com/rust-lang/rustfmt',
6259
'book': 'https://github.com/rust-lang/book',
6360
'nomicon': 'https://github.com/rust-lang/nomicon',
6461
'reference': 'https://github.com/rust-lang/reference',

‎src/tools/tidy/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ cargo_metadata = "0.14"
99
regex = "1"
1010
lazy_static = "1"
1111
walkdir = "2"
12-
crossbeam-utils = "0.8.0"
1312

1413
[[bin]]
1514
name = "rust-tidy"

‎src/tools/tidy/src/main.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
77
use tidy::*;
88

9-
use crossbeam_utils::thread::{scope, ScopedJoinHandle};
109
use std::collections::VecDeque;
1110
use std::env;
1211
use std::num::NonZeroUsize;
1312
use std::path::PathBuf;
1413
use std::process;
1514
use std::str::FromStr;
1615
use std::sync::atomic::{AtomicBool, Ordering};
16+
use std::thread::{scope, ScopedJoinHandle};
1717

1818
fn main() {
1919
let root_path: PathBuf = env::args_os().nth(1).expect("need path to root of repo").into();
@@ -44,7 +44,7 @@ fn main() {
4444
handles.pop_front().unwrap().join().unwrap();
4545
}
4646

47-
let handle = s.spawn(|_| {
47+
let handle = s.spawn(|| {
4848
let mut flag = false;
4949
$p::check($($args),* , &mut flag);
5050
if (flag) {
@@ -102,8 +102,7 @@ fn main() {
102102
r
103103
};
104104
check!(unstable_book, &src_path, collected);
105-
})
106-
.unwrap();
105+
});
107106

108107
if bad.load(Ordering::Relaxed) {
109108
eprintln!("some tidy checks failed");

0 commit comments

Comments
 (0)
Please sign in to comment.