mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
Compile Servo with the latest version of rust stable (#30831)
This completes the transition to compiling Servo with rust stable. Some nightly-only features are still used when compiling the `script` and `crown` crates, as well as for some style unit tests. These will likely break with newer compiler versions, but `crown` can be disabled for them conditionally. This is just the first step. This has some caveats: 1. We need to disable setting up the special linker on Linux. The -Z option isn't supported with stable rust so using this is out -- meanwhile we can't be sure that lld is installed on most systems. 2. `cargo fmt` still uses some unstable options, so we need to rely on the unstable toolchain just for running `fmt`. The idea is to fix this gradually.
This commit is contained in:
parent
9c443cf2c1
commit
7e82c5c957
29 changed files with 76 additions and 78 deletions
|
@ -70,32 +70,32 @@ Stuff copied from clippy:
|
|||
*/
|
||||
|
||||
fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator<Item = DefId> + 'tcx {
|
||||
use rustc_middle::ty::fast_reject::SimplifiedType::*;
|
||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||
let ty = match name {
|
||||
"bool" => BoolSimplifiedType,
|
||||
"char" => CharSimplifiedType,
|
||||
"str" => StrSimplifiedType,
|
||||
"array" => ArraySimplifiedType,
|
||||
"slice" => SliceSimplifiedType,
|
||||
"bool" => SimplifiedType::Bool,
|
||||
"char" => SimplifiedType::Char,
|
||||
"str" => SimplifiedType::Str,
|
||||
"array" => SimplifiedType::Array,
|
||||
"slice" => SimplifiedType::Slice,
|
||||
// FIXME: rustdoc documents these two using just `pointer`.
|
||||
//
|
||||
// Maybe this is something we should do here too.
|
||||
"const_ptr" => PtrSimplifiedType(Mutability::Not),
|
||||
"mut_ptr" => PtrSimplifiedType(Mutability::Mut),
|
||||
"isize" => IntSimplifiedType(IntTy::Isize),
|
||||
"i8" => IntSimplifiedType(IntTy::I8),
|
||||
"i16" => IntSimplifiedType(IntTy::I16),
|
||||
"i32" => IntSimplifiedType(IntTy::I32),
|
||||
"i64" => IntSimplifiedType(IntTy::I64),
|
||||
"i128" => IntSimplifiedType(IntTy::I128),
|
||||
"usize" => UintSimplifiedType(UintTy::Usize),
|
||||
"u8" => UintSimplifiedType(UintTy::U8),
|
||||
"u16" => UintSimplifiedType(UintTy::U16),
|
||||
"u32" => UintSimplifiedType(UintTy::U32),
|
||||
"u64" => UintSimplifiedType(UintTy::U64),
|
||||
"u128" => UintSimplifiedType(UintTy::U128),
|
||||
"f32" => FloatSimplifiedType(FloatTy::F32),
|
||||
"f64" => FloatSimplifiedType(FloatTy::F64),
|
||||
"const_ptr" => SimplifiedType::Ptr(Mutability::Not),
|
||||
"mut_ptr" => SimplifiedType::Ptr(Mutability::Mut),
|
||||
"isize" => SimplifiedType::Int(IntTy::Isize),
|
||||
"i8" => SimplifiedType::Int(IntTy::I8),
|
||||
"i16" => SimplifiedType::Int(IntTy::I16),
|
||||
"i32" => SimplifiedType::Int(IntTy::I32),
|
||||
"i64" => SimplifiedType::Int(IntTy::I64),
|
||||
"i128" => SimplifiedType::Int(IntTy::I128),
|
||||
"usize" => SimplifiedType::Uint(UintTy::Usize),
|
||||
"u8" => SimplifiedType::Uint(UintTy::U8),
|
||||
"u16" => SimplifiedType::Uint(UintTy::U16),
|
||||
"u32" => SimplifiedType::Uint(UintTy::U32),
|
||||
"u64" => SimplifiedType::Uint(UintTy::U64),
|
||||
"u128" => SimplifiedType::Uint(UintTy::U128),
|
||||
"f32" => SimplifiedType::Float(FloatTy::F32),
|
||||
"f64" => SimplifiedType::Float(FloatTy::F64),
|
||||
_ => return [].iter().copied(),
|
||||
};
|
||||
|
||||
|
@ -329,7 +329,7 @@ pub fn implements_trait_with_env<'tcx>(
|
|||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
span: DUMMY_SP,
|
||||
};
|
||||
let ty_params = tcx.mk_substs_from_iter(
|
||||
let ty_params = tcx.mk_args_from_iter(
|
||||
ty_params
|
||||
.into_iter()
|
||||
.map(|arg| arg.unwrap_or_else(|| infcx.next_ty_var(orig).into())),
|
||||
|
|
|
@ -42,7 +42,8 @@ impl Callbacks for MyCallbacks {
|
|||
config.register_lints = Some(Box::new(move |sess, lint_store| {
|
||||
// Skip checks for proc-macro crates.
|
||||
if sess
|
||||
.crate_types()
|
||||
.opts
|
||||
.crate_types
|
||||
.contains(&rustc_session::config::CrateType::ProcMacro)
|
||||
{
|
||||
return;
|
||||
|
@ -58,7 +59,9 @@ impl Callbacks for MyCallbacks {
|
|||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
rustc_driver::init_env_logger("CROWN_LOG");
|
||||
let handler =
|
||||
rustc_session::EarlyErrorHandler::new(rustc_session::config::ErrorOutputType::default());
|
||||
rustc_driver::init_env_logger(&handler, "CROWN_LOG");
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
|
||||
match rustc_driver::RunCompiler::new(&args, &mut MyCallbacks).run() {
|
||||
|
|
|
@ -118,7 +118,7 @@ fn incorrect_no_trace<'tcx, I: Into<MultiSpan> + Copy>(
|
|||
let mut walker = ty.walk();
|
||||
while let Some(generic_arg) = walker.next() {
|
||||
let t = match generic_arg.unpack() {
|
||||
rustc_middle::ty::subst::GenericArgKind::Type(t) => t,
|
||||
rustc_middle::ty::GenericArgKind::Type(t) => t,
|
||||
_ => {
|
||||
walker.skip_current_subtree();
|
||||
continue;
|
||||
|
@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for NotracePass {
|
|||
if let hir::ItemKind::Struct(def, ..) = &item.kind {
|
||||
for ref field in def.fields() {
|
||||
let field_type = cx.tcx.type_of(field.def_id);
|
||||
incorrect_no_trace(&self.symbols, cx, field_type.0, field.span);
|
||||
incorrect_no_trace(&self.symbols, cx, field_type.skip_binder(), field.span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for NotracePass {
|
|||
hir::VariantData::Tuple(fields, ..) => {
|
||||
for field in fields {
|
||||
let field_type = cx.tcx.type_of(field.def_id);
|
||||
incorrect_no_trace(&self.symbols, cx, field_type.0, field.ty.span);
|
||||
incorrect_no_trace(&self.symbols, cx, field_type.skip_binder(), field.ty.span);
|
||||
}
|
||||
},
|
||||
_ => (), // Struct variants already caught by check_struct_def
|
||||
|
|
|
@ -77,7 +77,7 @@ fn is_unrooted_ty<'tcx>(
|
|||
let mut walker = ty.walk();
|
||||
while let Some(generic_arg) = walker.next() {
|
||||
let t = match generic_arg.unpack() {
|
||||
rustc_middle::ty::subst::GenericArgKind::Type(t) => t,
|
||||
rustc_middle::ty::GenericArgKind::Type(t) => t,
|
||||
_ => {
|
||||
walker.skip_current_subtree();
|
||||
continue;
|
||||
|
@ -191,7 +191,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
|||
if let hir::ItemKind::Struct(def, ..) = &item.kind {
|
||||
for ref field in def.fields() {
|
||||
let field_type = cx.tcx.type_of(field.def_id);
|
||||
if is_unrooted_ty(&self.symbols, cx, field_type.0, false) {
|
||||
if is_unrooted_ty(&self.symbols, cx, field_type.skip_binder(), false) {
|
||||
cx.lint(
|
||||
UNROOTED_MUST_ROOT,
|
||||
"Type must be rooted, use #[crown::unrooted_must_root_lint::must_root] \
|
||||
|
@ -214,7 +214,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
|||
hir::VariantData::Tuple(fields, ..) => {
|
||||
for field in fields {
|
||||
let field_type = cx.tcx.type_of(field.def_id);
|
||||
if is_unrooted_ty(&self.symbols, cx, field_type.0, false) {
|
||||
if is_unrooted_ty(&self.symbols, cx, field_type.skip_binder(), false) {
|
||||
cx.lint(
|
||||
UNROOTED_MUST_ROOT,
|
||||
"Type must be rooted, \
|
||||
|
@ -247,7 +247,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
|||
};
|
||||
|
||||
if !in_derive_expn(span) {
|
||||
let sig = cx.tcx.type_of(def_id).0.fn_sig(cx.tcx);
|
||||
let sig = cx.tcx.type_of(def_id).skip_binder().fn_sig(cx.tcx);
|
||||
|
||||
for (arg, ty) in decl.inputs.iter().zip(sig.inputs().skip_binder().iter()) {
|
||||
if is_unrooted_ty(&self.symbols, cx, *ty, false) {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
// compile-flags: --error-format=human
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
// compile-flags: --error-format=human
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
//@rustc-env:RUSTC_BOOTSTRAP=1
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
warning: must_not_have_traceable marked wrapper is not needed for types that implements empty Traceable (like primitive types). Consider removing the wrapper.
|
||||
--> $DIR/trace_in_no_trace_primitive.rs:15:12
|
||||
--> $DIR/trace_in_no_trace_primitive.rs:16:12
|
||||
|
|
||||
15 | struct Foo(NoTrace<i32>);
|
||||
16 | struct Foo(NoTrace<i32>);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(crown::empty_trace_in_no_trace)]` on by default
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue